I2C lockup stm32f4discovery
Moderators: RoccoMarco, lbednarz, tfAteba
I2C lockup stm32f4discovery
Hi
Are there known problems with the i2c driver for stm32f4? I am raeding an MPU6050, checking for new data, and it works fine for about 20 seconds, and then a lockup occurs in i2cMasterTransmitTimeout despite the specification of a 50ms timeout - reboot then required.
hal.console->println("acq");
i2cAcquireBus(&I2CD2);
hal.console->println("rd");
rdymsg = i2cMasterTransmitTimeout(&I2CD2, addr, ®, 1, data, len, MS2ST(timeout));
hal.console->println("rl");
i2cReleaseBus(&I2CD2);
hal.console->println("rlc");
After a while, a transaction only gets to "rd" and then stops.
Best
Gareth
Are there known problems with the i2c driver for stm32f4? I am raeding an MPU6050, checking for new data, and it works fine for about 20 seconds, and then a lockup occurs in i2cMasterTransmitTimeout despite the specification of a 50ms timeout - reboot then required.
hal.console->println("acq");
i2cAcquireBus(&I2CD2);
hal.console->println("rd");
rdymsg = i2cMasterTransmitTimeout(&I2CD2, addr, ®, 1, data, len, MS2ST(timeout));
hal.console->println("rl");
i2cReleaseBus(&I2CD2);
hal.console->println("rlc");
After a while, a transaction only gets to "rd" and then stops.
Best
Gareth
- Giovanni
- Site Admin
- Posts: 14895
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: I2C lockup stm32f4discovery
Hi,
Does it stop inside the i2cMasterTransmitTimeout() function? also, do you have debug options enabled? if so, is anything caught by an assertion?
Giovanni
Does it stop inside the i2cMasterTransmitTimeout() function? also, do you have debug options enabled? if so, is anything caught by an assertion?
Giovanni
Re: I2C lockup stm32f4discovery
Yes its crashing in master timeout. I don't have debug enabled... cant get openocd working. Will try printing out the asserts.
- Giovanni
- Site Admin
- Posts: 14895
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: I2C lockup stm32f4discovery
drgowen wrote:Yes its crashing in master timeout. I don't have debug enabled... cant get openocd working. Will try printing out the asserts.
Try ChibiStudio, it includes everything is required.
Giovanni
Re: I2C lockup stm32f4discovery
OK, I just had to reconfig pins to enable jtag.
It's getting stuck in unhandled_exception() - I cant see any way to get a stack trace and work out the cause of the exception.
There's also nothing shown in the eclipse console that would indicate the cause.
Best
Gareth
It's getting stuck in unhandled_exception() - I cant see any way to get a stack trace and work out the cause of the exception.
There's also nothing shown in the eclipse console that would indicate the cause.
Best
Gareth
- Attachments
-
- Untitled.png (283.4 KiB) Viewed 6940 times
- Giovanni
- Site Admin
- Posts: 14895
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: I2C lockup stm32f4discovery
Hi,
It could be something not directly related like a stack overflow. Does the error happen always at the same time or randomly?
When an error is caught by an asserion then the system stops in port_halt() and the global pointer dbg_panic_msg points to a description string.
Giovanni
It could be something not directly related like a stack overflow. Does the error happen always at the same time or randomly?
When an error is caught by an asserion then the system stops in port_halt() and the global pointer dbg_panic_msg points to a description string.
Giovanni
Re: I2C lockup stm32f4discovery
It happens at the same time.
I've just tried doubling the stack size (using THD_WA_SIZE) but no effect - my code isn't being called in a recursive fashion, just a loop to check register values.
There is only one thread [afaik] - so the exception is definitely happening in the i2c master transmit function....
Best
Gareth
I've just tried doubling the stack size (using THD_WA_SIZE) but no effect - my code isn't being called in a recursive fashion, just a loop to check register values.
There is only one thread [afaik] - so the exception is definitely happening in the i2c master transmit function....
Best
Gareth
- Giovanni
- Site Admin
- Posts: 14895
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: I2C lockup stm32f4discovery
You have 4 stacks there:
- main thread stack
- your thread stack
- idle thread stack (unlikely)
- IRQ stack
You you have complex code in the main() function or into some interrupt handler?
If not, increase a counter each time you do the transfer and see in which iteration it happens, then stop just before and step into the function.
Giovanni
- main thread stack
- your thread stack
- idle thread stack (unlikely)
- IRQ stack
You you have complex code in the main() function or into some interrupt handler?
If not, increase a counter each time you do the transfer and see in which iteration it happens, then stop just before and step into the function.
Giovanni
Re: I2C lockup stm32f4discovery
Thanks for your time again Giovanni.
It appears the bug was actually elsewhere, but the print statements weren't outputting to the USB quickly enough leaving me to erroneously believe it was in the i2c handler.
Sorry
Gareth
It appears the bug was actually elsewhere, but the print statements weren't outputting to the USB quickly enough leaving me to erroneously believe it was in the i2c handler.
Sorry
Gareth
- Giovanni
- Site Admin
- Posts: 14895
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times