Problem with changing I2C speed or dutycycle

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
fuga
Posts: 3
Joined: Tue Jul 15, 2014 1:35 pm

Problem with changing I2C speed or dutycycle

Post by fuga »

hi
I'm testing testhal, I2C example on STM32F4-Discovery.
I've noticed that in this example board.h is NONSTANDARD_STM32F4_BARTHESS1 and not ST_STM32F4_DISCOVERY.
When I've changed board.h to DISCOVERY, I2CD2 was not working. Then I realized that GPIOB_CLK_IN, GPIOB_SDA are connected to (PIN10,PIN9), while according to the datasheet it should be connected as follow: GPIOB_CLK_IN, GPIOB_SDA (PIN10,PIN11). BTW, on NONSTANDARD_STM32F4_BARTHESS1 I2CD2 are set according to the datasheet - please note.
my problem now is that I cannot change I2C speed or dutycycle: when I change default I2CConfig values: 400KHz or FAST_DUTY_CYCLE_2 I don't get any I2C output signal (I'm checking with both scope and logic analyzer).
any idea? thanks
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Problem with changing I2C speed or dutycycle

Post by Giovanni »

I cannot test that scenario, are you sure you are specifying valid values? there are restrictions according to the Reference Manual.

Giovanni
steved
Posts: 834
Joined: Fri Nov 09, 2012 2:22 pm
Has thanked: 12 times
Been thanked: 138 times

Re: Problem with changing I2C speed or dutycycle

Post by steved »

I'm using I2C no problem on a Discovery F4 with the following configuration:

Code: Select all

static I2CConfig i2cfg1 = {
     OPMODE_I2C,
     100000,
     STD_DUTY_CYCLE
};
fuga
Posts: 3
Joined: Tue Jul 15, 2014 1:35 pm

Re: Problem with changing I2C speed or dutycycle

Post by fuga »

Thanks a lot for your quick reply...
from any reason this is the only configuration that is working for me:

Code: Select all

static const I2CConfig i2cfg2 = {
    OPMODE_I2C,
    400000,
    FAST_DUTY_CYCLE_2,
};


any chnge in speed or dutycycle is not working. same resaults on I2CD1 or I2CD2...
while testing I2C with my own code, without ChibiOs I'm getting 100KHz I2C.
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Problem with changing I2C speed or dutycycle

Post by Giovanni »

Are I/Os programmed correcty?

Giovanni
fuga
Posts: 3
Joined: Tue Jul 15, 2014 1:35 pm

Re: Problem with changing I2C speed or dutycycle

Post by fuga »

hi,

I2C I/O settings is as follow:

Code: Select all

  palSetPadMode(GPIOB, 10, PAL_MODE_ALTERNATE(4) | PAL_STM32_OTYPE_OPENDRAIN);   /* SCL */
  palSetPadMode(GPIOB, 11, PAL_MODE_ALTERNATE(4) | PAL_STM32_OTYPE_OPENDRAIN);   /* SDA */


After some more speed & duty-cycle combination checking, the followings are working:
400kKHz+FAST_DUTY_CYCLE_2, 100KHz+STD_DUTY_CYCLE - WORKING
400kKHz+STD_DUTY_CYCLE, 100KHz+FAST_DUTY_CYCLE_2 - NOT WORKING

For me it's OK now, but it would be nice to know if others see the same results and to understand why.

Thanks for the help!
Post Reply