3.4 Software Design
As mentioned in the beginning of this application note, CIPs drive much of this application, significantly reducing the CPU’s overhead. However, software still plays an important role beyond system initialization. The software on the microcontroller is responsible for enabling the Peltier, updating the user-interface, reading rotary encoder counts, converting ADC readings to temperature, and detecting soft errors. In this case, soft errors are failures that can be handled directly by the microcontroller while a hard error would be an issue that trips a physical safety device, such as a fuse.
Due to resource limitations, the software was architected with simple cooperative multitasking, in which an executing task voluntarily yields so another task may run. A heartbeat function, derived from Timer0, is used to run non-blocking tasks periodically. Additionally, the heartbeat function generates flags to indicate instances where a more complex task must run when the system is not busy with another task.