STM32H7 I2C
Posted: Sun Mar 29, 2020 2:17 am
Hello,
I've got a project where none of the I[sup]2[/sup]C ports seem to respond in any way to the settings in the TIMINGR register. I put the I2C clock on a scope and noticed it running way too fast, so I tried different clock divider settings in TIMINGR to no effect, and even just set the register to 0 or ffffffff just to see if there was any change at all.
This is running up-to-date ChibiosOS from github, on an STM32H753. I'm also using the C++ wrapper, in case that matters. I'm using the internal clocks only, no external oscillator connected. I have a Cube project running to validate that all of the hardware is capable of working, via Cube's HAL.
I suspect this is more like a MCU configuration error rather than an Chibios error, but I can't figure it out. Any ideas? Here's a transcript of a debug session where TIMINGR is written to and then doesn't actually change:
[font=Courier New]Info : Device: STM32H74x/75x
Info : flash size probed value 2048
Info : STM32H flash has dual banks. Bank (0) size is 1024kb, base address is 0x8000000
0x08005ee4 in _idle_thread (p=0x0) at ../ChibiOS/os/rt/src/chsys.c:72
72 static void _idle_thread(void *p) {
(gdb) b hal_i2c_lld.c:989
Breakpoint 1 at 0x80047c8: file ../ChibiOS/os/hal/ports/STM32/LLD/I2Cv3/hal_i2c_lld.c, line 989.
(gdb) monitor reset halt
(gdb) c
Continuing.
Note: automatically using hardware breakpoints for read-only addresses.
Breakpoint 1, i2c_lld_start (i2cp=0x240004f8 <I2CD1>) at ../ChibiOS/os/hal/ports/STM32/LLD/I2Cv3/hal_i2c_lld.c:989
989 dp->TIMINGR = i2cp->config->timingr;
(gdb) p dp
$1 = (I2C_TypeDef *) 0x40005400
(gdb) p *dp
$2 = {CR1 = 49297, CR2 = 0, OAR1 = 0, OAR2 = 0, TIMINGR = 0, TIMEOUTR = 0, ISR = 1, ICR = 0, PECR = 0, RXDR = 0,
TXDR = 0}
(gdb) p i2cp->config->timingr
$3 = 547407071
(gdb) n
992 dp->CR1 |= I2C_CR1_PE;
(gdb) p *dp
$4 = {CR1 = 49297, CR2 = 0, OAR1 = 0, OAR2 = 0, TIMINGR = 0, TIMEOUTR = 0, ISR = 1, ICR = 0, PECR = 0, RXDR = 0,
TXDR = 0}[/font]
Alternatively, are there any demo projects for the STM32H7 that include I2C?
I've got a project where none of the I[sup]2[/sup]C ports seem to respond in any way to the settings in the TIMINGR register. I put the I2C clock on a scope and noticed it running way too fast, so I tried different clock divider settings in TIMINGR to no effect, and even just set the register to 0 or ffffffff just to see if there was any change at all.
This is running up-to-date ChibiosOS from github, on an STM32H753. I'm also using the C++ wrapper, in case that matters. I'm using the internal clocks only, no external oscillator connected. I have a Cube project running to validate that all of the hardware is capable of working, via Cube's HAL.
I suspect this is more like a MCU configuration error rather than an Chibios error, but I can't figure it out. Any ideas? Here's a transcript of a debug session where TIMINGR is written to and then doesn't actually change:
[font=Courier New]Info : Device: STM32H74x/75x
Info : flash size probed value 2048
Info : STM32H flash has dual banks. Bank (0) size is 1024kb, base address is 0x8000000
0x08005ee4 in _idle_thread (p=0x0) at ../ChibiOS/os/rt/src/chsys.c:72
72 static void _idle_thread(void *p) {
(gdb) b hal_i2c_lld.c:989
Breakpoint 1 at 0x80047c8: file ../ChibiOS/os/hal/ports/STM32/LLD/I2Cv3/hal_i2c_lld.c, line 989.
(gdb) monitor reset halt
(gdb) c
Continuing.
Note: automatically using hardware breakpoints for read-only addresses.
Breakpoint 1, i2c_lld_start (i2cp=0x240004f8 <I2CD1>) at ../ChibiOS/os/hal/ports/STM32/LLD/I2Cv3/hal_i2c_lld.c:989
989 dp->TIMINGR = i2cp->config->timingr;
(gdb) p dp
$1 = (I2C_TypeDef *) 0x40005400
(gdb) p *dp
$2 = {CR1 = 49297, CR2 = 0, OAR1 = 0, OAR2 = 0, TIMINGR = 0, TIMEOUTR = 0, ISR = 1, ICR = 0, PECR = 0, RXDR = 0,
TXDR = 0}
(gdb) p i2cp->config->timingr
$3 = 547407071
(gdb) n
992 dp->CR1 |= I2C_CR1_PE;
(gdb) p *dp
$4 = {CR1 = 49297, CR2 = 0, OAR1 = 0, OAR2 = 0, TIMINGR = 0, TIMEOUTR = 0, ISR = 1, ICR = 0, PECR = 0, RXDR = 0,
TXDR = 0}[/font]
Alternatively, are there any demo projects for the STM32H7 that include I2C?