Connect with us

PIC184520 USART Lab - Virtual Terminal

Discussion in 'Microcontrollers, Programming and IoT' started by Mohammad Al-Hiyali, Nov 25, 2017.

Scroll to continue with content
  1. Mohammad Al-Hiyali

    Mohammad Al-Hiyali

    6
    0
    Apr 8, 2015
    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)
    {
    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){
    while (PIR1bits.TXIF == 0) {;} // Wait until Peripheral Interrupt Request Register Transmit Flag is set // (transmit complete, TXREG empty)
    TXREG = 'U';
    Delay10KTCYx(50);​
    }
    }
     

    Attached Files:

Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-