STM32H743 I2C3 problem

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

Moderator: RoccoMarco

Post Reply
dflogeras
Posts: 232
Joined: Tue Sep 03, 2013 8:16 pm
Has thanked: 8 times
Been thanked: 22 times

STM32H743 I2C3 problem

Post by dflogeras »

Hi all,

Still tinkering with this H743 board. I am running ChibiOS_21.21.4 and attempting to use the I2C3 peripheral. I am running into a weird one, where as soon as I attempt to initiate a transfer, I lose contact with my openocd/stlink and can only recover by power cycling. It seems to be happening as soon as the TCIE bit is set in CR1.

I have:
  • tested on two different boards (both STM32H743) and they both do the same thing.
  • tested with and without DMA, and they both do the same thing
  • tried various ram segments (although when not using DMA I'd expect it to not matter), same outcome.
  • tested by leaving the pins un-configured (obviously they wont talk to the outside world, but the peripheral should not care) and this still does the same thing
  • checked the device errata and nothing really stuck out.
  • tested on a different MCU (STM32H723 vs 743) and the I2C seems to work fine on that MCU
I've boiled it down to a simple test program below. This simply configures a UART and the I2C3 peripheral, then waits for a character on the UART (so I can catch it in openocd after a reboot), then attempts to use the I2C. The timing values are right from the reference manual, as I'm feeding the I2C an 8MHz clock.

Any suggestions are very welcome, as I'm running out of ideas.

Thanks,
Dave

Code: Select all

#include "ch.h"
#include "hal.h"

const I2CConfig i2c_cfg = {
  .timingr = STM32_TIMINGR_PRESC(0xB) |
             STM32_TIMINGR_SCLDEL(0x4) | STM32_TIMINGR_SDADEL(0x2) |
             STM32_TIMINGR_SCLH(0xF)  | STM32_TIMINGR_SCLL(0x13),
  .cr1 = 0,
  .cr2 = 0,
};

static const SerialConfig uart_config = {
  .speed = 9600,
  .cr1 = 0,
  .cr2 = 0,
  .cr3 = 0,
};

static uint8_t __nocache_buf[2];

int main(void) {

  halInit();
  chSysInit();

  SCB_DisableDCache();

  sdStart( &SD1, &uart_config );
  sdWrite( &SD1, (const uint8_t*)"test\r\n", 6 );

  {
    i2cStart( &I2CD3, &i2c_cfg );
    __nocache_buf[0] = 0x06;
    __nocache_buf[1] = 0x0f;
    uint8_t rx[1];
    sdRead( &SD1, &rx[0], 1 );
    chThdSleepMilliseconds( 10000 );
    const uint8_t addr = 0x20;
    i2cMasterTransmitTimeout( &I2CD3, addr,
                              &__nocache_buf[0], sizeof( __nocache_buf ),
                              0x0, 0,
                              1000 );
  }

  sdWrite( &SD1, (const uint8_t*)"done\r\n", 6 );

  while(1) {
    chThdSleepMilliseconds(1);
  }

}

dflogeras
Posts: 232
Joined: Tue Sep 03, 2013 8:16 pm
Has thanked: 8 times
Been thanked: 22 times

Re: STM32H743 I2C3 problem

Post by dflogeras »

Well I made some progress.

I tried another I2Cx (from the same 1,2,3) and it still didn't work. Then I tried switching the I2C123 clock mux to use CSI_KER_CK (4 MHz instead of my PLL3_R_CK which is 8MHz) and now it successfully completes the i2cMasterTransmitTimeout() call.

Switching back to PLL3_R_CK but dividing it down to 4MHz does not work again, so it seems it is related to the clock source and not the speed.

Still searching for a reason for that.
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: STM32H743 I2C3 problem

Post by Giovanni »

Hi,

Try checking clock limits in the Data Sheet (not the Reference Manual).

Giovanni
dflogeras
Posts: 232
Joined: Tue Sep 03, 2013 8:16 pm
Has thanked: 8 times
Been thanked: 22 times

Re: STM32H743 I2C3 problem

Post by dflogeras »

Thanks, will do next session. I was using CubeMX to verify the clock tree as I set it up, but who knows... all software can have bugs (or more likely, I didn't transpose it to mcuconfig.h exactly).

I'll post back when I have more info.
Post Reply