Hi, i wanted to see if someone can help me, im new on this so i dont understand very good, any way, im trying to make a pic that show de characters that recive by bluetooth, to do that im using UART and a LCD, if someone can help with this error or give me a device i would really aprecciate it :)

sbit LCD_RS at RB2_bit;
sbit LCD_EN at RB3_bit;
sbit LCD_D4 at RB4_bit;
sbit LCD_D5 at RB5_bit;
sbit LCD_D6 at RB6_bit;
sbit LCD_D7 at RB7_bit;

sbit LCD_RS_Direction at TRISB2_bit;
sbit LCD_EN_Direction at TRISB3_bit;
sbit LCD_D4_Direction at TRISB4_bit;
sbit LCD_D5_Direction at TRISB5_bit;
sbit LCD_D6_Direction at TRISB6_bit;
sbit LCD_D7_Direction at TRISB7_bit;

char recive[20]= " ", delimitadorD = 'D', delimitadorH = 'H', delimitadorV = 'V', delimitador = '#';
char registro;
char ND;

int i=0;

void comparar (){

  if(recive[0]=='d'){

   Lcd_cmd(_Lcd_Clear);
   Uart1_Write_Text("DosCentimetros");
   Lcd_Out(1,1,"Dato recibido");
   Lcd_Out(2,1,"Exitosamente");
   delay_ms(2000);
   Lcd_cmd(_Lcd_Clear);

   }
   if(recive[0]=='c'){

   Lcd_cmd(_Lcd_Clear);
   Uart1_Write_Text("CincoCentimetros");
   Lcd_Out(1,1,"Dato recibido");
   Lcd_Out(2,1,"Exitosamente");
   delay_ms(2000);
   Lcd_cmd(_Lcd_Clear);

   }

   if(recive[0]=='t'){

   Lcd_cmd(_Lcd_Clear);
   Uart1_Write_Text("Trigo");
   Lcd_Out(1,1,"Dato recibido");
   Lcd_Out(2,1,"Exitosamente");
   delay_ms(2000);
   Lcd_cmd(_Lcd_Clear);

   }

   if(recive[0]=='f'){

   Lcd_cmd(_Lcd_Clear);
   Uart1_Write_Text("Frigol");
   Lcd_Out(1,1,"Dato recibido");
   Lcd_Out(2,1,"Exitosamente");
   delay_ms(2000);
   Lcd_cmd(_Lcd_Clear);

   }

}

void interrupt(){

  if(RCIF_bit == 1){
   RCIF_bit = 0;
   recive[i] = Uart1_Read();
   i++;
   if(recive[i-1]==delimitador){
    RCIE_bit = 0;
    i=0;
    comparar();
    RCIE_bit=1;
    Lcd_Out(2,1,i);

   }
   if(recive[i-1]==delimitadorD){
    RCIE_bit = 0;
    i=0;
    RCIE_bit=1;
    Lcd_Out(2,1,i);

   }
   if(recive[i-1]==delimitadorH){
    RCIE_bit = 0;
    i=0;
    RCIE_bit=1;
    Lcd_Out(2,1,d);
   }
   if(recive[i-1]==delimitadorV){
    RCIE_bit = 0;
    i=0;
    RCIE_bit=1;
    Lcd_Out(2,1,s);
   }
  }
}

void main(){

     Lcd_Init();
     Lcd_cmd(_Lcd_Clear);

     Uart1_Init(9600);
     delay_ms(100);

     GIE_bit = 1;
     PEIE_bit = 1;
     RCIE_bit = 1;

}

im using mikro c by the way

Recommended Answers

All 2 Replies

It's been years since I've been on the MicroChip PIC but it appears your code call to Lcd_cmd() is the issue.
This is very similar to the discussion at https://forum.mikroe.com/viewtopic.php?t=24108

Refactor/rewrite to not call those functions in your interrupt routine.

Another observation.

Look at the array recive[]. Now let's say a character arrives in this array. How does recive[0] get cleared?

Seems like future trouble from my reading.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.