Datasheet
Thursday, 17 July 2003 MiniProject: Design Aspects Colin K McCord
EEE512J2 – Electronic Product Design Page 37 Chapter 7: Electronic / Software Design
Figure 7.5a shows a simplified block diagram of the main routine, this routines first setups the ports
(configure as input / output), sets the baud rate as specified by the DIP switches, and the ADC. Timer 2 is
setup to interrupt the main routine 128-times a second, and then the main routine is stuck in a loop forever
contentiously scanning through the array refreshing the CRT display.
Figure 7.5b shows a simplified block diagram of the interrupt routine, this routine interrupts the main routine
128 times a second and returns back to the main routine after it has been successfully executed. Basically it
reads the ADC, stores the reading at the end of the array, and transmits the reading through RS232 so the
PC can display / log the ECG data.
It was decided to use interrupts, this allows for the CRT display and the sampling of the ECG to be
completely separated and allow the PIC to do two things at once (time slicing). It did not have to be written
this way as it is possible to write the entire program in the main routine, but the code would be intertwined
and difficult to debug.
Obviously calculation of the ECG bpm and sounding of the buzzer has not been included yet as its good
software design practice to build the code up step-by-step (e.g. get part A programmed before moving to part
B, etc…). This code could be placed in the main program or another interrupt routine (using timer 0 or 1 to
cause the interrupt).