In general, if you don't know what is going on, gather more data.
You say you transfer the data via USB to PC for plotting. Do you know if your data looks good before passing it to the PC? I would do something like this : Fill your buffers with some known data - a specific byte-value, or an incrementing pattern maybe; whatever. Add some test code to check the values in your arrays, before passing it to the PC. If it's good, you might suspect that your data is not being passed to the PC correctly. If it's not good, step through your code and watch what's happening as it happens.
So, I have a strange problem. I have an array that is filling it self with strange values. I'm using two global arrays and I fill them with values and send the values via USB to a PC where I plot them. The size of the arrays are 1000 and the type is short:
Code:
short acc_y[1000]; short vel_y[1000]; If I use a loop:
Code:
for (i = 0; i < 1000; i++) { vel_y[i] = buf[i]; acc_y[i] = buf[i]; } The result will be like in the plot1, what's wrong with vel_y? Even if I assign both arrays to zero there are still those strange values between index 163- But not acc_y. The red line is acc_y and the blue line is vel_y. Plot1:
Does the pattern shift if you move the vel_y array in memory (by for example making acc_y 1100 elements)? If it doesn't, search your code for references to vel_y, maybe some old debug code lying around.
Check your interrupt routines if they write to memory. Make sure they don't have some hard coded pointer values. Do you use DMA? Is it set up correctly?
I have output the data on an LCD and I get the same numbers. I have also made checks in the code when these large positive numbers fill the array, to me it looks like some form of memory corruption. But I don't know, because the same pattern repeats every time I fill the array, regardsless of what I fill it with.
If you have any idea what I should check for, please share. Anyone have any ideas?
The problem does not occur. Am I running out of memory? Should perhaps reduce number of global variables. [ This message was edited by: sarling on 06-04-2009 10:57 ] [ This message was edited by: sarling on 06-04-2009 10:58 ]
@andreas1: It doesn't shift if I set acc_y[1100], but if I declare vel_y[1100], the pattern is shifted right to index 263-282 (+100). I did use DMA for ADC but I disabled it and no change. I also use SysTick_Handler for data sampling, but before I do anyt
>Hi - interesting topic - thank you. You're welcome, but I thought you said the topic is ill-defined. >when one of our forum ''crew'' NEEDS this info next week/month NEEDS which info? >HOW will they