AnsweredAssumed Answered

How do I track down a bus fault exception

Question asked by rydh.marcus on Apr 7, 2012
Latest reply on Apr 8, 2012 by Clive One
Hi,

I've been trying to write some code, but I'm running into a bus fault. I'm new to programming, especially with regards to microcontrollers/stm32, so I don't really know how to debug efficiently. I'm using Keil uVision4 with my STM32VL Discovery. I'm trying to communicate with some inertial sensors over I2C, and I've written some functions using the I2C optimized examples firmware available from ST. If I use these functions I've written, I can communicate fine with the sensors. However, I recently came across the example code for STM's LSM303DLHC sensor, which has some rather more involved functions for altering the sensor's register values. When I use these functions, and just run my code, I get a bus fault. When I step through the program, the bus fault disappears. I haven't understood, and have had no luck in figuring out how to use the debug information (core registers and disassembly) to help me track down the problem. Can someone help explain what information I need to look for and how to use it to track down a problem like this? Would including my source code help?

Outcomes