Content originally posted in LPCWare by cakehuang on Fri Apr 12 04:31:09 MST 2013
Quote: frame
Fine, but actually, that doesn't help much. The C code does not give new hints toward the reason.
The assembler instruction at the vicinity of the hardfault is interesting.
[FONT=Courier New]printf [/FONT]uses [B]huge [/B]amounts of stack, even [FONT=Courier New]small_printf[/FONT] consumes considerably.
Did you check the stack at this time ?
What keeps you from starting up your debugger ?
And, BTW, you don't need floating point (even [FONT=Courier New]double[/FONT]) at this point. This simple scaling
can as well be done in integer. Double calculations are a waste of performance,
it will take about 10 .. 50 times as long as using integer.
1, Please check the attached picture. First one is just before brance to library.Second one is just before hardware fault happen. If that instruction gets executed, hardfault occurs.
2, Before hardware fault, no printf ever gets exectued.
3, I did not check the stack carefully. What I saw is that "b.w 0x1e24" is causing hardwarefault. This branch instruction will not consume any more stack usage.
4, If I use ver4, everything is OK. But since ver5 has great update, I would like to switch to this new version.
5, I am using adc to measure a signal ranging from 0v to 1.8v. Althrough I can avoid using floating point library in my real project like by using integer, I still want to use floating point which is more straight forward. And performance is OK as I am measuring PWM signal which has several kHz.
6, In my real project, I had another hardware fault which is something like " blx 0xxxxxxxxx". This is disassembly code inside the debugger. But user manual of cortex m0 shows there is only "blx Rm" which means blx can only use register as destination address. This is also puzzling me a lot.