PIC16F877A – Serial communication(USART)

The USART module of PIC 16F877A uses pins RC6 & RC7 for transmission & reception respectively. The mini development board can communicate with PC/external modules through

  1. USB port via CP2102
  2. Serial port via MAX232
  3. RMC connector  K15 in 5V level
  4. RMC connector  K17 in 3.3V level

Besides, USART is also used for interfacing Zigbee & RFID reader.

Schematic

 

 

Note:

  1. 3V3 USART communication through K17 is possible only if the jumpers J13 and J14 (XBTX, XBRX) are shorted.
  2. For communicating through K15 & K17, remove jumpers J3 & J4

Sample Code

The sample code to check USART module is given below. Initially the letter ‘A’  gets transmitted. Then, upon receiving a character, the same gets retransmitted.

Value in SPBRG is calculated as follows
           Baud Rate = Fosc / (16 (X + 1))

The desired baudrate is 9600 bps and crystal frequency, Fosc is 20 MHz. This gives X as 129 (81 in hexadecimal) which is loaded in SPBRG. Any change in crystal frequency/baudrate  changes this value as per the above equation.

 Output

The following screenshots explain how to test the sample code using RealTerm (click to download).

  • Step 1: Open  RealTerm
  • Step 2: RealTerm opens as shown below
  •  Step 3: Go to ‘Port’ option, set correct baudrate (which is set as 9600 in the sample code) and correct port
  •  Step 4: Click ‘Change’ (encircled in red) to apply the changes. Now check the status of Port. If it is closed, click ‘Open’ button (encircled in green) to open it.
  • Step 5: To check reception, go to Send option, type the string in the space provided(encircled in green) and click Send ASCII button. The first “hello” in green colour is  transmitted from PC & that in yellow colour is retransmitted by the controller

Topics related to PIC16F877A Development Board-Mini

  1. PIC16F877A Mini Development Board – Overview
  2. PIC16F877A Mini Development Board – Interfacing LED
  3. PIC16F877A Mini Development Board – Interfacing LCD
  4. PIC16F877A Mini Development Board – Serial communication(USART)
  5. PIC16F877A Mini Development Board – Interfacing Switch
  6. PIC16F877A Mini Development Board – Interfacing Buzzer
  7. PIC16F877A Mini Development Board – Interfacing  POT(ADC)
  8. PIC16F877A Mini Development Board – Interfacing Temperature sensor
  9. PIC 16F877A Mini Development Board – Interfacing Servo Motor
  10. PIC 16F877A Mini Development Board – Interfacing μRFID Reader

Resources

How to buy?

SupportPlease share your ideas with us, visit our forum for discussion

Leave a Reply