EmbeddedHW_MX1_comparatorInterrupt
Created: Apr 12, 2017
-
- 607
- 0
- 0
- 0
Description
No description available.
Summary
Program 3:
Description
In this program, use interrupts generated by the Analog Comparator to sense the input voltage.The comparator takes in an analog voltage and compares it to a reference voltage.If the voltage is higher than the reference it outputs a logic '1' while the inverse results in a logic '0'.It can also generate interrupts on rising or falling signal edges.
Your software should do nothing in the main loop.Instead everything will be done in the interrupt service routines (ISRs).The software should count the number of signal edges in the comparator ISR.These should be totaled up over one second to determine the frequency.
The general actions this program should take are shown below.One's program does not need to follow this precise series of actions, and in fact performance improvements may be possible by deviating from them.That said, for this program to be valid it must find its result through using interrupts generated by the analog comparator.
General Pseudocode
Main Loop:
1 Second Timer Interrupt Service Routine:
Stop and Reset the Timer
Calculate and Print the Frequency
Restart the Timer
Clear the Timer Interrupt (often handled by MCC generated code)
Comparator Edge Interrupt Service Routine:
Increment the Counter
Clear the Comparator Interrupt (often handled by MCC generated code)
Hardware Setup and Threshold Setting:This setup should be identical to Program 2.
Details
Components:
- No components added