LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

UART PIC24FJ128GA010

hello ,
 
I am using UART in PIC 24FJ128GA010 for receing data from Hyperterminal & displaying on LCD. After 4th character Receive Buffer overflows & U2STAbits.OERR becomes set. I am detecting OERR bit, then clears the same & transfering 5th character onwords... but program is not working.. it overflows after 5th character... Please suggest any solution . I m herewith giving my code....
 
 
 
/****************************************
void lcdCmd(int);
void lcdWrite(char *);
void delay(int);
#define RS PORTBbits.RB15
#define RW PORTDbits.RD5 
#define EN PORTDbits.RD4 

main()
{
    const unsigned char MyString[15]; //
 RS232Init();       //This function has to be defined by me to get data (UART in receive mode)
 LCDInit();
    int i = 0;
while(1)
    {
      MyString[i] = GetRS232();
     while(MyString[i]!=0)
          {
            lcdWrite(MyString);
             i++;
             MyString[i] = GetRS232();
             delay(500);
             while(U2STAbits.OERR)
              {
            
              U2STAbits.OERR=0;
              U2RXREG=0X0000;
              delay(500);
             MyString[i] = GetRS232();
              }
         }
          i=0;
        }
     
  
 
}
/************************************************
#include <p24FJ128GA010.h>

RS232Init()
{
    char p;
 TRISFbits.TRISF5 = 0;
 U2MODE = 0x0800;
 U2BRG = 0x0019;     //0x26;
 U2MODEbits.UARTEN = 1;
 U2STAbits.UTXEN = 0;
}

char GetRS232()
{
   char P;
   while(!U2STAbits.RIDLE);
 
    {
    
       P=U2RXREG;
       delay(500);
     }
    return (P);
   
}
 
thanks in advance..
rgds,
Dhanashree
Message 1 of 3
(2,876 Views)
And this question is related to LabVIEW in what way?
0 Kudos
Message 2 of 3
(2,871 Views)
I've been using LabVIEW with PICs for years and never had a UART issue. Note I said LabVIEW, not C++! Smiley Happy
Richard






0 Kudos
Message 3 of 3
(2,845 Views)