Skip to main content
theforeignman
Associate
June 9, 2013
Question

LIS302DL problem

  • June 9, 2013
  • 2 replies
  • 762 views
Posted on June 09, 2013 at 13:01

Hi,

I've been using an STM32F4 Discovery board with uVision4 for around 10 months now, and have learnt how to use the basic features (ADC, LCD, USART etc) and I'm now tackling the accelerometer (LIS302DL). I've looked at various examples from the net including the one(s) supplied by ST, however I always seem to get a HardFault Exception before main code is even reached! I've researched this HardFault error and tried to work my way around it, to no success. The Fault Report has NOCP ticked in the Usage Faults box and FORCED in the Hard Faults box.

I've reloaded previous projects and they work fine. So it seems to be a problem whenever I try to write code relating to the accelerometer.

Could someone please help me out? All I want to do is read from the accelerometer, and not encounter the HardFault Exception.

Thanks

Tom

#accelerometer #lis302dl #stm32f4
This topic has been closed for replies.

2 replies

Tesla DeLorean
Guru
June 9, 2013
Posted on June 09, 2013 at 13:41

What tool chain is this with? Are you using floating point code that might be using the FPU without enabling it?

There are a couple of things which will cause a Hard Fault, most are read/write access to memory that isn't present, or attempts to execute 32-bit ARM instructions.

You need to make a determination about what assembler instruction is faulting.

[DEAD LINK /public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/How%20to%20debug%20hard%20fault%20handler%20exceptions&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&currentviews=617]https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=%2Fpublic%2FSTe2ecommunities%2Fmcu%2FLists%2Fcortex_mx_stm32%2FHow%20to%20debug%20hard%20fault%20handler%20exceptions&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B¤tviews=617
Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
theforeignman
Associate
June 9, 2013
Posted on June 09, 2013 at 14:32

Hi clive1,

Thanks for your reply. I went through the assembly code and the compiler may have been generating floating point code without me knowing. In any case, I seem to have now solved the issue by enabling the FPU in the startup_stm32f4xx.s file, as done so at the beginning of this thread : [DEAD LINK /public/STe2ecommunities/mcu/Lists/STM32Discovery/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/STM32Discovery/stm32f4%20random%20hard%20faults%20%28solved%29&FolderCTID=0x01200200770978C69A1141439FE559EB459D75800084C20D8867EAD444A5987D47BE638E0F&currentviews=1610]https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32Discovery/Flat.aspx?RootFolder=%2Fpublic%2FSTe2ecommunities%2Fmcu%2FLists%2FSTM32Discovery%2Fstm32f4%20random%20hard%20faults%20(solved)&FolderCTID=0x01200200770978C69A1141439FE559EB459D75800084C20D8867EAD444A5987D47BE638E0F&currentviews=1610

Many thanks again

Tom