We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
hi,I write an algorithm running in cortex M0. It has some floating point multiplication.But the program always resets when encounter a floating point multiplication.And the code showed below:
for (k = 0; k < 4; k++) { tmpx = dbuffer[0] * a[k + 1]; dbuffer[k + 1] = dbuffer[k + 1] - tmpx; }
dbuffer[] and a[] are float array. tmpx is a float variable. When I debug the program, the M0 resets at line "tmpx = dbuffer[0] * a[k + 1];" .And the value of dbuffer[0] is 1429983,a[k+1] is 0.00974910986. I have tested this multiplication in a new project.And the code goes well and result is right.The test code is like below:
float a = 1429983; float b = 0.00974910986; float c; c = a* b;
So, I know M0 use softVFP. I have seen asm code such as __aeabi_fmul corresponding to my code. Could anybody tell me what's wrong with my code? Thank you very much.
I would rule out that the floating point code itself causes the reset.
What about interrupts in your system? Did you check for stack overflows?
The default stack, in startup_arch.s is usually very small. If you hold your arrays in local/auto variables it's going to break unless you make the stack sufficiently large.
Does it end up in the Hard Fault Handler?
Thank you,Reinhard,I resize the stack size and cut my code to 100 point filter.Then the program runs well.So,it's obviously caused by stack overflow.
hi,Westonsupermare,Thank you for reply.It's indeed caused by stack overflow. By the way, I'd like to ask another question:How can I know the program ends up in the Hard Fault Handler?
If you stop the debugger you could observe where it's stuck, often a while(1) loop.
You can break-point the handler. You can have the handler output status/diagnostic information on the serial port.
This may help you further: http://www.keil.com/appnotes/docs/apnt_209.asp
community.arm.com/.../17345