Quantcast
Channel: MSP low-power microcontroller forum - Recent Threads
Viewing all articles
Browse latest Browse all 22733

sprintf() with XMSP4301R custom board

$
0
0

Hi guys,

I want to use sprintf to fill different char arrays with strings since the exact strings that fill the arrays is program run dependable. the problem is, that I need to fill three different char arrays of 18 Elements. When I use sprintf() on two of them everything works fine. When I add the third one my first entry in the second char array gets corrupted. It's arepeatable fault, so I think there might be something wrong with the memory access.

Does anyone have a clue on that problem?

Here's the code for the routine:

void create_files_on_SD(void)
{
	if(heartcoreConfigBuf.recID<10)
	{
		sprintf(filenameData, "M:\\MEAS00%d\\HCO.DAT", heartcoreConfigBuf.recID);
		sprintf(filenameHeader,"M:\\MEAS00%d\\HCO.HEA",heartcoreConfigBuf.recID);
		sprintf(filenameEventLog,"M:\\MEAS00%d\\HCO.LOG",heartcoreConfigBuf.recID);
	}
	else if(heartcoreConfigBuf.recID<100)
	{
		sprintf(filenameData, "M:\\MEAS0%d\\HCO.DAT", heartcoreConfigBuf.recID);
		sprintf(filenameHeader,"M:\\MEAS0%d\\HCO.HEA",heartcoreConfigBuf.recID);
		sprintf(filenameEventLog,"M:\\MEAS0%d\\HCO.LOG",heartcoreConfigBuf.recID);
	}
	else
	{
		sprintf(filenameData, "M:\\MEAS%d\\HCO.DAT", heartcoreConfigBuf.recID);
		sprintf(filenameHeader,"M:\\MEAS%d\\HCO.HEA",heartcoreConfigBuf.recID);
		sprintf(filenameEventLog,"M:\\MEAS%d\\HCO.LOG",heartcoreConfigBuf.recID);
	}

}

The function changes the string depending on the value of heartcoreConfigBuf.recID

After running sprintf() for the third time the "M" (as the first entry) is changed. I don't get it why. I also have a quite big heap size (4096 byte) so i don't think thats the problem.

best regards

Benni


Viewing all articles
Browse latest Browse all 22733

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>