View previous topic :: View next topic |
Author |
Message |
rlgreen
Joined: 07 Dec 2007 Posts: 8
|
Corrupted Array |
Posted: Mon Dec 17, 2007 10:13 am |
|
|
I have just completed a search of the forums and have not found an answer to this: I am talking to another CPU via the uart. I have declared the array as a global variable. The first time I read the string, it is fine. Loaded all characters correctly. If I try to load array again, the data is corrupted and never loads correctly again. Any help would be welcomed!
PIC 16F876
CCS Ver 4.023
Code: Just the function listed. Am I doing something stupid?
Code: | void Get_String(void)
{
int8 i = 0;
Read_Rx();// clear rxreg, reading x3
Rx_Tmr_On();
while((i<=17)&& (int_count<=6))
{
rx_buffer[i]=getg();
i++;
}
Rx_Tmr_Off();
printf(lcd_putc,"\n");
i=0;
while(i<=10)
{
printf(lcd_putc,"%c",rx_buffer[i]);
i++;
}
} |
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Dec 17, 2007 12:03 pm |
|
|
You didn't give us enough information.
1. Post all your variable declarations, such as the rx_buffer[] array.
2. Post the routines that you're calling, such as "getg()", etc.
If you're using RDA interrupts to receive the characters, then post the isr.
Here's one thread where I explain problems with incorrect buffer
contents. But without more information, I can't be sure if it applies
to your case.
http://www.ccsinfo.com/forum/viewtopic.php?t=25425 |
|
|
rlgreen
Joined: 07 Dec 2007 Posts: 8
|
|
Posted: Mon Dec 17, 2007 6:48 pm |
|
|
Thanks PCM for the reply. I was doing something stupid. Not clearing the overflow bit. The uart doesn't like that.
Thanks again! |
|
|
|