stm32f103C and chibios 2.5.0: i2cd1 driver hangs!

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
ucasano
Posts: 57
Joined: Mon Aug 06, 2012 1:05 pm
Has thanked: 1 time

stm32f103C and chibios 2.5.0: i2cd1 driver hangs!

Post 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
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: stm32f103C and chibios 2.5.0: i2cd1 driver hangs!

Post by Giovanni »

Hi,

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

Giovanni
ucasano
Posts: 57
Joined: Mon Aug 06, 2012 1:05 pm
Has thanked: 1 time

Re: stm32f103C and chibios 2.5.0: i2cd1 driver hangs!

Post by ucasano »

Well, each time I strike ctrl-c on debugger, it shows up:

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

does it help?
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: stm32f103C and chibios 2.5.0: i2cd1 driver hangs!

Post 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
ucasano
Posts: 57
Joined: Mon Aug 06, 2012 1:05 pm
Has thanked: 1 time

Re: stm32f103C and chibios 2.5.0: i2cd1 driver hangs!

Post 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
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: stm32f103C and chibios 2.5.0: i2cd1 driver hangs!

Post 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
ucasano
Posts: 57
Joined: Mon Aug 06, 2012 1:05 pm
Has thanked: 1 time

Re: stm32f103C and chibios 2.5.0: i2cd1 driver hangs!

Post 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
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: stm32f103C and chibios 2.5.0: i2cd1 driver hangs!

Post 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
Post Reply