|
||
|
Serial receiver and transmitter (USART) |
|
|
1. Specifications
Project is under development, in preparation. Implement a 4-bit Serial_receiver as the dual circuit of the 4-bit Serial_transmitter presented in P10.
Fig 1. Symbol. |
Features:
Fig 2. Waveforms |
2. Planning
Fig. 3. Hardware circuit. |
Fig. 4. Hardware-software diagram. |
Draw the state diagram.
Fig. 5. State diagram. |
Represent the RAM variables required in this application.
Fig. 6. RAM variables. |
Draw the main ideas of init_system(). Configure input and output pins. Consider as well interrupts configuration.
Fig. 7. TRIS, data direction registers configuration. |
read_inputs() flowchart.
Fig. 8. Reading inputs. |
write_outputs() flowchart.
Fig. 9. Writing outputs. |
Infer how to organise the interrupt service routine ISR() to handle edge detections.
Fig. 10. ISR() function. |
Draw state_logic() truth table and flowchart.
Fig. 11. State logic flowchart is a behavioural interpretation of the truth table CC1. |
Draw output_logic() truth table and flowchart.
Fig. 12. Output logic flowchart is a behavioural interpretation of the truth table CC2. |
Organise a MPLABX - XC8 IDE project targetting a PIC18F4520 at location:
C:/CSD/P10/Serial_receiver/(files)
3. Development - 4. Testing interactively
This is a file Serial_receiver.pdsprj containing the circuit represented in Fig. 13.
Fig. 13. Circuit running. |
The planning ideas in the previous section are translated to Serial_receiver.c source file.
Run the microcontroller's IDE to develop and compile the C code to obtain executable files.
Run the Proteus simulator. Do it in step by step mode while watching variables and placing break points, specially for following interrupt flags.
In this application we have two options for generating input stimulus:
(1) Generate a test waveform to drive input RX simulating transmitted frames.
(2) Include in the same project the Serial_transmitter to drive the receiver
Remember that development and testing must be carried out step by step, one feature at a time.
Fig. 14. Waveforms in Proteus |
5. Report
6. Prototyping