Page 1 of 1

I2C lockup stm32f4discovery

Posted: Thu Sep 12, 2013 10:02 pm
by drgowen
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, &reg, 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

Re: I2C lockup stm32f4discovery

Posted: Thu Sep 12, 2013 10:21 pm
by Giovanni
Hi,

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

Posted: Thu Sep 12, 2013 10:38 pm
by drgowen
Yes its crashing in master timeout. I don't have debug enabled... cant get openocd working. Will try printing out the asserts.

Re: I2C lockup stm32f4discovery

Posted: Fri Sep 13, 2013 8:04 am
by Giovanni
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

Posted: Fri Sep 13, 2013 7:35 pm
by drgowen
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

Re: I2C lockup stm32f4discovery

Posted: Fri Sep 13, 2013 7:45 pm
by Giovanni
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

Re: I2C lockup stm32f4discovery

Posted: Fri Sep 13, 2013 7:55 pm
by drgowen
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

Re: I2C lockup stm32f4discovery

Posted: Fri Sep 13, 2013 8:00 pm
by Giovanni
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

Re: I2C lockup stm32f4discovery

Posted: Fri Sep 13, 2013 8:47 pm
by drgowen
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

Re: I2C lockup stm32f4discovery

Posted: Fri Sep 13, 2013 9:31 pm
by Giovanni
NP, I am glad it's fixed.

Giovanni