comunicación RS232 tarjeta RFid REDBEE con pic18f4550 en MikroC

Bueno mi problema es que no puedo configurar el pic para que pueda leer los datos que me envía la tarjeta RFID para poder mostrarlo en el LCD.

Mi programa esta muy sencillo, por favor se los agradecería mucho si me echaran una mano.

Código:
// LCD configuración
sbit LCD_RS at RD2_bit;
sbit LCD_EN at RD3_bit;
sbit LCD_D4 at RD4_bit;
sbit LCD_D5 at RD5_bit;
sbit LCD_D6 at RD6_bit;
sbit LCD_D7 at RD7_bit;

sbit LCD_RS_Direction at TRISD2_bit;
sbit LCD_EN_Direction at TRISD3_bit;
sbit LCD_D4_Direction at TRISD4_bit;
sbit LCD_D5_Direction at TRISD5_bit;
sbit LCD_D6_Direction at TRISD6_bit;
sbit LCD_D7_Direction at TRISD7_bit;
// End LCD module connections

char ID[11];

void main() {
    
    ADCON1 =192;
    ADCON0 =128;
    TRISC = 0x00;
    PORTC = 0x128;
    TRISB = 0x00;
    Lcd_Init();                      
    Lcd_Cmd(_LCD_CLEAR);              
    Lcd_Cmd(_LCD_CURSOR_OFF);          
    UART1_Init(9600);
    Delay_ms(100);                 
    CMCON = 0x07;
    RCSTA = 0x98;
    BAUDCON = 0x1B;
    SPBRG = 0xCF;
    Lcd_Cmd(_LCD_CLEAR);
    Lcd_out(2, 6, "Cargando...");
    
   if(UART1_Data_Ready()==1){     
       do {
       Lcd_cmd(_LCD_CLEAR);
       Lcd_Out(2,6,"Leyendo...");
       delay_ms(1000);
       ID = UART1_Read();                  
       Lcd_Cmd(_LCD_CLEAR);
       Lcd_Out(1,10,"ID");
       delay_ms(5000);
       }while(1);
   }
}
nunca entra a la condición IF.
 
Última edición por un moderador:
Aunque no se MikroC y como van sus funciones UART, el do { no tendría que estar antes del if?

Tal como lo tienes entiendo que si no hay datos cuando se chequea Data_Ready() (solo una vez), sale del programa directamente, ya que el bucle solo se ejecutará si hay datos en el buffer de la UART, no?
 
Atrás
Arriba