Sunday, July 3, 2011

Using Serial UART

UART is an essential interface to PC. Below shows how to use and set the configuration bits in C18. The purpose of the codes below is to loop back to the Hyperterminal the word "Hello" to make sure the settings of the PIC works accordingly. OpenUSART() function is provided by C18 and it is used to set the neccessary registers in PIC18F series microcontroller.



For some that uses a USB to Serial converter, they are required to test the converter is working properly. Some have been reported not working. The converter can be test by connecting pin 2 and pn 3 together. This allows the data sent from Hyperterminal to loop back to the terminal. After this is done, the above codes can be used to make sure the serial is function properly.



Figure 1: Connecting pin 2 and pin 3 of seriall




Figure 2: Terminal showing the loop back

Conclusion


These test allows you to save time by debugging the necessary erroneous parts in your development.

No comments:

Post a Comment