Comunicacion de Pc a un LCD de Pic18F45K22

Me podrian ayudar con este tema, quisiera mostrar un mensaje que yo desee en el LCD 2x16 mediante comunicacion Rs232.
De los ejemplos del Mikrobasic tengo este codigo
Código:
dim cadena as byte
 dim LCD_RS as sbit at LATB4_bit
    LCD_EN as sbit at LATB5_bit
    LCD_D4 as sbit at LATB0_bit
    LCD_D5 as sbit at LATB1_bit
    LCD_D6 as sbit at LATB2_bit
    LCD_D7 as sbit at LATB3_bit

dim LCD_RS_Direction as sbit at TRISB4_bit
    LCD_EN_Direction as sbit at TRISB5_bit
    LCD_D4_Direction as sbit at TRISB0_bit
    LCD_D5_Direction as sbit at TRISB1_bit
    LCD_D6_Direction as sbit at TRISB2_bit
    LCD_D7_Direction as sbit at TRISB3_bit
\' End Lcd module connections

dim txt1 as string[16]
    txt2 as char[16]
    txt3 as char[16]
    txt4 as char[7]
    i    as byte
main:
  ANSELC = 0                           \' Configure PORTC pins as digital

  UART1_Init(9600)                     \' Initialize UART module at 9600 bps
  Delay_ms(100)
   Lcd_Init()                     \' Initialize Lcd

while (TRUE)
    if (UART1_Data_Ready() <> 0) then  \' If data is received,
     cadena = UART1_Read()           \' read the received data,
      UART1_Write(cadena)
      UART1_Write(10)                      \' Line Feed
      UART1_Write(13)                     \' Carriage Return
     ByteTostr(cadena, txt1)
     Lcd_Cmd(_LCD_CLEAR)            \' Clear display
     Lcd_Cmd(_LCD_CURSOR_OFF)       \' Cursor off
     Lcd_Out(1,1,txt1)
    end if
                 wend
end.

Pero solo me muestra el código ascii de la ultima letra que escribo en el USART terminal! :(
Soy nueva en esto, apreciare cualquier comentario! ...
 
Hola AmandaS. Por lo que veo en el código:

Lcd_Cmd(_LCD_CLEAR) //aquí estas limpiando el LCD
Lcd_Cmd(_LCD_CURSOR_OFF)
Lcd_Out(1,1,txt1) //finalmente envías el dato byte al LCD

Por esta razón siempre verás el último dato recibido mediante:
cadena = UART1_Read // esta función solo lee un byte del puerto, no todo

Saludos .
 
Atrás
Arriba