Main Loop
The pseudo code for the main loop is:
| Main: | ||||
|
Initialize and start PRS |
||||
| Loop: | ||||
| If BPF period is complete | ||||
|
Save current peak value |
||||
|
Save Offset Values |
||||
|
Set peak value to zero |
||||
| If A/D reading available | ||||
| If Filter has settled | ||||
|
Subtract offset from sample value |
||||
| Save new peak | ||||
Timer Tick
The Pseudo code for the Timer Tick which occurs 40000 times per second is:
| Get lower six bits of 16-bit PRS Write six bit value to DAC6 Decrement BPF_Counter If BPF_Counter =0 |
||||
| Load BPF_Counter with Count Value (4) | ||||
| Decrement BPF_Timer | ||||
| If BPF_Timer =0 | ||||
| Load parameters for next filter | ||||
| If Filter 0-3 | ||||
| Set Mux to 2Khz Filter | ||||
| Else | ||||
| Set Mux to no Filter | ||||
|
Increment Filter Index |
||||
| Else | ||||
| If SAMPLE=FALSE | ||||
|
Decrement Settling_Timer |
||||
| Decrement Disp_Timer | ||||
| If Disp_Timer = 0 | ||||
|
Load Disp_Timer with Count Value (50) |
||||
Note that the Timer Tick occurs at 40Khz, the BPF event occurs at 10Khz, and the Display Event occurs at 800Hz. Since the display has eight columns, the refresh rate is 100Hz.
advertisement
advertisement