2010-03-13 01:53 PM
Hard Fault error
2011-05-17 04:43 AM
If I remove the LCD_WriteRAM function call, then the code runs without any hard failured.
So it has something to do with the LCD_WriteRAM function - but I'm using ST's LCD library??
Thomas
2011-05-17 04:43 AM
The Hard Fault indicates you are reading/writing to an illegal location.
You'll have to debug it. Suggest removing the LCD_xxx calls and see if it still traps. Try outputting some instrumentation to the serial debug port, etc.2011-05-17 04:43 AM
No ideas?
2011-05-17 04:43 AM
Add a debug trap as the first thing in your LCD_WriteRAM routine. Check the passed argument against the bounds. Output a message over your serial port when it is out of bounds. If it isn't the argument that is the problem then dig deeper and debug each string or array in the same way. 100% of the hard faults I've had are caused by variables accessing out of bounds. Looking past the end of a string is easy to do.
2011-05-17 04:43 AM
Hmm, I've already tried this, not with the serial port though, but with a debugging tool. Then I can just read the counting integer fx.
But I can't find the thing which makes the hard fault!
Also, the thing that keeps irretating me is, that the code works on the STM32F103RET6 without any problems, but on the STM32F103ZET6 the hard fault appears!
Thomas
2011-05-17 04:43 AM
Hi Thomas,
You'll have to step it along, could be a bug in the library, but much like the old 68K when you touch the wrong memory it faults. The Cortex-M3 pushes fault context on to the stack (some 8 dwords as I recall), I think Joseph Yiu has some example of instrumenting this. This could should permit you to determine the faulting PC. With this and the register info, and a map file you should be able to zero in on what is going on. MRS R0, PSP ; Read PSP LDR R1, [R0, #24] ; Read Saved PC from Stack http://forums.arm.com/lofiversion/index.php?t13632.html Boy this forum sucks chunks for finding and citing things. ST *please* get rid of this Microsoft junk?! https://my.st.com/public/STe2ecommunities/mcu/Lists/ARM%20CortexM3%20STM32/Flat.aspx?RootFolder=%2Fpublic%2FSTe2ecommunities%2Fmcu%2FLists%2FARM%20CortexM3%20STM32%2FHardFault%20Exception%20Why%20oh%20why%21 http://www.google.com/search?hl=en&q=Joseph+Yiu+hard+fault+exception+handler -Clive