Author Topic: PIC184520 USART Lab - Virtual Terminal  (Read 9200 times)

0 Members and 1 Guest are viewing this topic.

Offline leovivaldiTopic starter

  • Newbie
  • Posts: 1
  • Country: ca
PIC184520 USART Lab - Virtual Terminal
« on: November 25, 2017, 12:07:29 pm »
I am using the PIC18F4520 on Proteus 8. I want to use the USART to display the 'U' character all the time on the virtual terminal.
The baud rate is 19200 and I changed it on the virtual terminal as it was displaying wrong characters to baud rate set as 9600 (default).
I am getting 4 dashes at a time ----- instead of Us. See attached.

Can you help and explain why I am getting this? Or give a hint or point to the part in the source code that is causing it to do this?

The source code is:

#pragma config OSC = HS //set Osc mode to HS high speed clock
#pragma config WDT = OFF // set watchdog timer off
#pragma config LVP = OFF // Low Voltage Programming Off
#pragma config DEBUG = OFF // Compile without extra Debug compile Code
// Include Files

#include <p18f4520.h> // Device used is the PICF4520
#include <delays.h> // Include delays headers

void main (void)
TXSTA = 0x24;// Select high baud rate, 8 bit
SPBRG = 64;// 19200 bps, 20MHz clock
TXSTAbits.TXEN = 1;// Transmit enable
RCSTAbits.SPEN = 1; // Enable serial port
while (PIR1bits.TXIF == 0) {;} // Wait until Peripheral Interrupt Request Register Transmit Flag is set // (transmit complete, TXREG empty)
TXREG = 'U';

Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo