Reply To: Retrieving UART data on LCD using PIC16F877A

Home Forums Microcontrollers PIC Microcontroller Retrieving UART data on LCD using PIC16F877A Reply To: Retrieving UART data on LCD using PIC16F877A

#11086
sandeep
Participant

Hi sir,

code is concerned, i m trying to debug the code from the basics, the basic code is as shown below, I tried it with the led’s, like,
if the format is correct then RB1 to blink or else RB3 to blink, but it is not happening.suggestions pls.

void main()
{
  //unsigned char data;
  TRISC = 0xC0;
  TRISB = 0x00;
  TRISD = 0x00;
  PORTC = 0x00;
  PORTD = 0x00;
  PORTB = 0x00;

  UART_Init();
  Lcd4_Init();
  delay(500);
  GIE = 1;
  PEIE = 1;
  char i,c;
  int j,k,l;

  delay(6000); //delay provided for the gsm to get signal stable.

  RCREG = 0;
  UART_Write_Text("AT+CMGF=1");
  UART_Write(0x0D);
  UART_Write(0x0A);

  UART_Write_Text("AT+CNMI=2,0,0,0,0"); // as suggested by u sir, but as per datasheet, it might be 2,1,0,0,0
  UART_Write(0x0D); // it remains same even after changing to AT+CNMI=2,1,0,0,0
  UART_Write(0x0A);

  while(RCIF) // checking data ready
  {
    for(i=0;i<=64;i++)
    {
      x[i]=UART_Read();
    }

    if(x[2]=='+'&& x[3]=='C')
    {
      RB1 = 1;
      lcd4_delayms(1000);
      RB1 = 0;
    }
    else if(x[2]!='+'&&x[3]!='C')
    {
      RB3 = 1; 
      lcd4_delayms(1000);
      RB3 = 0;
      RCREG=0;
    }
    continue;
  }
  i=0;
  x[i]=0;

  RCREG=0;

  delay(1000);
}
>