2019-08-26 04:11 AM
Hi,
I am trying to get the NMEA data over UART and print it over another uart .But when i try read in loop after writing data to PC ,I'm not receiving any data. what could be the issue?
any ideas ??
Solved! Go to Solution.
2019-09-02 11:13 PM
just use this function to make the pointers the same
void clearRxBuffer(void) {
U1RxBufferPtrIN = U1RxBufSize - huart1.hdmarx->Instance->CNDTR;
U1RxBufferPtrOUT = U1RxBufferPtrIN;
}
then readable will return a zero, until a byte is received.
2019-09-03 12:23 AM
actually, you should never clear the buffer.. just keep reading bytes from the circular DMA buffer like this:
I use this to check a frame... initialise haveGPSstringbytes = false;
if( ! haveGPSstringbytes){
int length = readableU1();
if (length >= 2)
{
char firstByte = peekRxU1(0);
char secondByte = peekRxU1(1);
char readByte = readU1(); // read and dump byte if not start of frame
if ((firstByte == '$') && (secondByte == 'G'))
{
GPSlength = 0;
haveGPSstringbytes = true;
GPSstring[GPSlength++] = readByte;
}
}
}else{
char readByte = readU1();
GPSstring[GPSlength++] = readByte;
//read in frame to end
// when you have a complete frame
haveGPSstringbytes = false; //start new frame detector
flagGPSFrameReceived = true;
}
2019-09-03 05:19 AM
Thanks TJ,
code is working ,before i was using normal mode instead of circular mode.