Hi,
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 5 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)
{
}
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 5 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(1){
}SPBRG = 64;// 19200 bps, 20MHz clock
TXSTAbits.TXEN = 1;// Transmit enable
RCSTAbits.SPEN = 1; // Enable serial port
while(1){
while (PIR1bits.TXIF == 0) {;} // Wait until Peripheral Interrupt Request Register Transmit Flag is set // (transmit complete, TXREG empty)
TXREG = 'U';
Delay10KTCYx(50);
TXREG = 'U';
Delay10KTCYx(50);
}