| ||
SP3_2: Prog_Timer design phase #1. FSM and external interrupts |
||
NOTE: This subproject must be solved only after having completed successfully lab session Lab10 because you will copy and adapt materials from it. |
1. Specifications
Prog_Timer design phase #1: Adapting FSM to μC using external interrupts. The aim of this preparatory laboratory assignment is to analyse the given circuit for the programmable timer and complete hardware and software.
|
Fig. 1. Circuit. |
2. Planning
Project organisation is similar to other Chapter projects in P10 and Lab10. Study all the project sections given in this page and draw the truth table and its equivalent flowchart for state_logic().
Hardware planning
Fig. 2. Schemetic of the harware circuit that has to be developed in Proteus. |
Software planning
Paper work on diagrams, sketches, flowcharts and materials for studying the project in detail and completing it.
Fig. 3. is an example of hardware-software diagram. |
Fig. 4. General software organisation. |
Fig. 5. RAM variables. |
Fig. 6. State diagram. |
Fig. 7. Initialising the system. |
Fig. 8. Reading inputs. |
Fig. 9. Writing outputs. |
Fig. 10. ISR() |
Fig. 11.Counter datapath. |
|
Fig. 12.Truth table and flowchart for the function output_logic(). |
Thus, once analysed all these materials, you are ready for discussing the state_logic() truth table and its equivalent flowchart.
Fig. 13.Truth table and flowchart for the function state_logic() yet to be planned. |
Project location:
C:\CSD\P_Ch3\SP3_2\(files)
3. Developing and 4. testing
This Prog_Timer.pdsprj is the capture of the hardware schematic in Fig. 2 above.
Start a new MPLABX project Prog_Timer_prj using this seed Prog_Timer.c source file. Compile and verify in Proteus that your application runs with no errors. Tranlate into C the state_logic() function planned above in Fig. 13. Run, debug and make measurements as represented in Fig. 14 to show how your circuit works for different PC values.
Fig. 14. Example of oscilloscope measurements and watch window for debugging purposes. |
Additional measurements and questions once the circuit is in operation:
Measure the circuit precision in timing periods when for instance PC = 6; PC = 4000.
Measure using breakpoints how long does it takes to execute the main loop.
What is the larger timing period?
Measure how long does it takes to execute ISR().
What happens if the μC OSC crystal is replaced by 4 MHz? Elaborate your answer.
How to make TRG sensitive to rising edges?
5. Report
Follow this rubric for writing reports.