Displaying UART data on LCD – PIC 16F877A

Home Forums Microcontrollers PIC Microcontroller Displaying UART data on LCD – PIC 16F877A

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #10227
    nitin ahuja
    Participant

    I want to display data read from UART on 16×2 LCD with MikroC compiler & PIC16F877A microcontroller …
    In my program I am sending data through USART terminal of MikroC, it is receiving correctly on virtual terminal in Proteus but not displaying on LCD.
    Please check the code written in MikroC

    sbit LCD_RS at RB0_bit; 
    sbit LCD_EN at RB1_bit; 
    sbit LCD_D4 at RB2_bit; 
    sbit LCD_D5 at RB3_bit; 
    sbit LCD_D6 at RB4_bit; 
    sbit LCD_D7 at RB5_bit; 
    sbit LCD_RS_direction at TRISB0_bit; 
    sbit LCD_EN_direction at TRISB1_bit; 
    sbit LCD_D4_direction at TRISB2_bit; 
    sbit LCD_D5_direction at TRISB3_bit; 
    sbit LCD_D6_direction at TRISB4_bit; 
    sbit LCD_D7_Direction at TRISB5_bit; 
    
    char gps; 
    void main() 
    { 
      Lcd_Init(); 
      Lcd_Cmd(_LCD_CLEAR); 
      Lcd_Cmd(_LCD_CURSOR_OFF); 
      Lcd_Out(1,1,"log"); 
      Lcd_Out(2,1,"lat"); 
    
      UART1_Init(9600); 
    
      here: 
        if (UART1_Data_Ready() == 1) 
        { // if data is received 
          gps = UART1_Read(); 
          delay_ms(100); 
        } 
        Lcd_Out(1,6,gps); 
        Delay_ms(2000); 
        goto here; 
      }
    
    #10236
    Ligo George
    Keymaster

    It is not a good practice to use goto statements in your programs.

    Try like this to display UART data on LCD :

    void main() 
    { 
      Lcd_Init(); 
      Lcd_Cmd(_LCD_CLEAR); 
      Lcd_Cmd(_LCD_CURSOR_OFF); 
    
      UART1_Init(9600); 
    
      while(1)
      { 
        if(UART1_Data_Ready()) 
        { 
          gps = UART1_Read(); 
          Lcd_Chr_Cp(gps); 
       } 
     }

     

    #10237
    nitin ahuja
    Participant

    sir , i wana ask that in gps module the time we get is 24 hour format ,,?

     

    #10255
    Ligo George
    Keymaster

    Yes, it is in 24 hour format.

    #13095
    Dona Mary John
    Participant

    Can you please send the program for USART with lcd without function oriented.

    #13096
    Ligo George
    Keymaster

    Dear Dona,

    Kindly open a new topic for asking your doubts.

    You can see our complete UART code in the following article.

    Using UART of PIC Microcontroller – MPLAB XC8

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.
>