This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Why not clear buffer

Please help me to find the problem:

In my program, I use UART to receive data by UART interrupt, please see following.

#define uchar unsigned char
#define DATALTH 255

volatile uchar SerBuffer;
volatile uchar I_ptr;

void isr_UART(void) interrupt SIO_VECTOR using 0
{
uchar c;

if(RI)
{
c = SBUF;
RI = FALSE;
SerBuffer[I_ptr & (DATALTH -1)] = c;
}
}

But when I use
memset(SerBuffer,0x00,DATALTH);
or
Addr = strchr(SerBuffer,0x22);
to clear "SerBuffer" or search
0x22 from "SerBuffer" and during the progress there are data received by UART, then there will be serious error.

Please tell me the reason.
thank you.

0