In one of our highly classified secret 'X' Project, a small module consisted of a UART Tx. and Rx. modules to be built and demonstrated. So we started out with the transmitter, to transmit data for certain bytes. We choose PIC16F628A as it has the built in USART function and the datasheet has all the relevant details as to setup the registers and also has explained the baud rates to be set and necessary steps and actions for receiving and transmitting.
The datasheet can be downloaded from this official site:
Click Here.
The details of the USART is given under Section 12 in the datasheet. As per the data sheet, three registers have to be configured for Tx. and Rx. The TXSTA, RCSTA and SPBRG. The TXSTA is the configuration register for the Transmitting and the RCSTA is the configuration register of the Receiving. SPBRG is loaded with the correct value specified in the baud table provided in the datasheet. SPBRG is used to mention the correct baud rate of Tx. and Rx. accordingly to the Crystal Oscillator, Internal Clock or RC Clock used in the circuit. Aslo the datasheet has provided the bits to be set/cleared and registers where data is loaded/received for Tx. and Rx.
As in our project we are using Asynchronous Tx. with a 16MHx crystal, the values of the TXSTA, RCSTA and SPBRG were loaded according. Also a special mention to this website for a very helpful project which helped us a lot.
16F628 UART test
There are few changes that were incorporated in final project. We have used PIC16F628A, 16MHz XTAL and MAX485. Whereas the website project has used PIC16F628, Internal RC Clock (asbsent in PIC16F628A but has Internal Oscillator far more stable than RC), MAX232. Also the baud rates are different as we have used 19.23 Kbaud and the website project has used 9.6 Kbaud.
Since we are using 19.23 Kbaud, the byte transmission was quite fast to be captured on the oscilloscope and we wrote a continuous loop to show us the transmitted byte. You can refer the below picture to see the byte being transmitted and captured on the oscilloscope.
More details on UART Tx and Rx will be updated soon on this post along with code, schematic and more pictures and suggestion. Stay tuned to this blog!!!!!!!!!!!!