• We recently switched our forum platform. If you experience any issues please email support@crystalfontz.com

interfacing CFA-635 with PIC microcontroller

bwalex

New member
Hi, I'm currently trying to interface a CFA-635 with a PIC16F877A. I'm using CCS PICC compiler and everything's working fine... except reading from the CFA-635.
This is my code, CFA_clear clears the LCD screen and CFA_sendcmd does exactly what it says, sending a command. I tried without delays, with delays, with higher delays... everything. The LCD does send it correctly and does recognize every command and does reply correctly. Problem is that it doesn't read anything; it keeps stuck at the getc in the first iteration of the do while trying to read something, but it doesn't seem it is able to read anything. I don't understand why there isn't anything to be read at the UART. Btw, I'm using hardware UART on C6 and C7.

Any answer is welcome, no matter if in PIC assembly, hitech C or whatever!

Thank you in advance,

Alex


Code:
   CFA_clear();
   
   
   
   //printf("Looping until reaching infinity... \r\n\n");
   
   for (;;)
   {
      while (kbhit())
         getc();
      delay_ms(20);
      CFA_sendcmd(CFA635_READ_KEYPAD, NULL, 0);
      delay_us(65);
      
      i = 0;
      do
      {
         buffer[i] = getc();
         i=0;
      } while (/* i < 7 */ kbhit());
       
     sprintf(line, "i is = %d", i);
     CFA_sendline(2, 0, line);        
     if (buffer[0] != 0x58)
     {
         sprintf(line, "CRAP! != 0x58");
         CFA_sendline(1, 0, line);     
         continue;
     }
     else
     {
         sprintf(line, "Its good! == 0x58");
         CFA_sendline(1, 0, line);        
     }
     delay_ms(100);
Looking for additional LCD resources? Check out our LCD blog for the latest developments in LCD technology.
 
USB LCD Displays - Graphic and Character LCDs with a Keypad
Top