CAN Reception Data Integrity
I am facing the problem of data integrity, the logic is something as shown below i am taking the CAN rx data from the interrupt and processing in while loop.
uint8_t g_candata_u8=0;
int main(void)
{
Initilializations();
while()
{
if(CanMessageReceived == TRUE)
{
LCDDisplay(g_candata_u8);
}
}
void CanRxInterrupt()
{
g_candata_u8 = RxBuffer[0];
}
The problem i am facing is the g_candata_u8 is getting corrupted. The value g_candata_u8 which is acclerator pedal percentage from 0 - 100% received from vehicle shall be less than 100, but the value displayed on the LCD is sometimes shows greater than 200, most of the time it is less than 100 and as expected.
I am suspecting the above method of code implementation is a problem. What is the best method to process the rx data?
