Page 1 of 1

stm32f103C and chibios 2.5.0: i2cd1 driver hangs!

Posted: Tue Oct 02, 2012 5:59 pm
by ucasano
Hello, this time I am facing a problem with I2CD1 driver of ChibiOS 2.5.0.

After initialization, I do:

i2cAcquireBus(i2cp);
i2c_ret = i2cMasterTransmitTimeout(i2cp, I2C_ADDR, txbuf, 3, rxbuf, 0, MS2ST(6));
i2cReleaseBus(i2cp);

i2cAcquireBus(i2cp);
i2c_ret = i2cMasterTransmitTimeout(i2cp, I2C_ADDR, txbuf, 8, rxbuf, 0, MS2ST(6));
i2cReleaseBus(i2cp);

The second writing sequence hangs!

I tried in the following manners:
1) just the second writing sequence;
2) with no other peripherals enabled (uart, spi, ecc...)
3) double checked board.h configuration, and it's fine, PB6 and PB7 configured as alternate open drain.

I have 2k pullup resistor on each lines.

Could you please help me?
-g

Re: stm32f103C and chibios 2.5.0: i2cd1 driver hangs!

Posted: Tue Oct 02, 2012 6:03 pm
by Giovanni
Hi,

Hangs exactly where? does it go into an unhandled exception or what?

Giovanni

Re: stm32f103C and chibios 2.5.0: i2cd1 driver hangs!

Posted: Tue Oct 02, 2012 6:05 pm
by ucasano
Well, each time I strike ctrl-c on debugger, it shows up:

port_halt() at ....... chcore.c:43

does it help?

Re: stm32f103C and chibios 2.5.0: i2cd1 driver hangs!

Posted: Tue Oct 02, 2012 6:13 pm
by Giovanni
Are you running with debug options enabled? port_halt() is called when some assertion fails.

When you get this kind of errors 90% of times it is a problem of stack overflow, you should verify that.

If you debug from inside Eclipse the ChibiOS debug plugin can also retrieve the error message for you.

Giovanni

Re: stm32f103C and chibios 2.5.0: i2cd1 driver hangs!

Posted: Tue Oct 02, 2012 6:25 pm
by ucasano
Ok, could be a buffer overflow, but I am just managing a few bytes, and rx and tx buffer are 256 bytes long.

PS. I enhanced the stack size of the process from 128 bytes to 256 bytes and it worked.

Now, could you please suggest me a lecture or a link, in order to find the right size for process stack?
Why does it happened?

-g

Re: stm32f103C and chibios 2.5.0: i2cd1 driver hangs!

Posted: Tue Oct 02, 2012 6:31 pm
by Giovanni
Hi, the debug plugin shows exactly how much stack is used for each thread. Alternatively, activate the stack filler option and inspect memory (this is what the plugin does automatically).

Giovanni

Re: stm32f103C and chibios 2.5.0: i2cd1 driver hangs!

Posted: Tue Oct 02, 2012 6:46 pm
by ucasano
Ok Giovanni, I will try to do it (I do not use eclipse).

Well, for the second time in one day, let me thank you for your great cooperation.

Bye
-g

Re: stm32f103C and chibios 2.5.0: i2cd1 driver hangs!

Posted: Tue Oct 02, 2012 7:00 pm
by Giovanni
You are welcome.

I am stressing with Eclipse because the debug facility is really important, it is worth to invest some time for the setup.

Giovanni