Help w/ C code.. how to clear array pointer buffer?

Status
Not open for further replies.

DanD

New Member
Hey all,

I have thoroughly confused myself. I am working with the code below:

Code:
void displaySensor(int address, char typeChar, int sensVal){
	char tmpString[5];
	
	WaitXLCD();
	SetDDRamAddr(address+6);
	WaitXLCD();
	putsXLCD(itoa(sensVal,tmpString));
}


The function displaySensor is repeatedly called from another function called from an infinite loop in main(). Basically main calls goSensor() which collects the data from the ADC and then goSensor() calls displaySensor to display the value on the LCD. sensVal is reinitialed and then reset in goSensor().

If i call goSensor() once, (outside of the main loop) it works fine. However, when i call it repeated i get some junk on the screen after the first call. So it seems to me like i need to reinitialize something.

itoa is a C18 function which converts the integer, sensVal, to a string, tmpString, and returns a pointer to this data. putsXLCD() then displays the buffer at this pointer location. I think this pointer location is getting messed up or something.

Can you guys think of a better way to do this or a way to tidy it up to avoid data corruption?

Thanks a lot
 
nevermind, i figured it out

it was some other *seemingly* unrelated code far far away..
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…