cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G431KBTx (Nucleo-32 board), UART and I2C EEPROM makes problems

Heinrich
Associate III

Hello together,

I'm using Nucleo-32 board (with a STM32G431KBTx) and have got some problems...

In my project I'm using:

-> UART (here I'm using RX-DMA and interrupt with an IDLE-flag)

-> ADC, one channel

-> I²C with an EEPROM (no DMA, no Interrupt)

Problems and attempted solutions

Problem 1: if I write some bytes to EEPROM (I'm using HAL_I2C_Mem_Write(...) for that), and wait 5ms after the writing a page, the MCU stucks in HAL_Delay forever. After some googling I found a solution for this, increase interrupt priority for SysTick_Handler. Okay, all my interrupts have 0 as "preemption priority", so I've configured priorities like this:

0693W00000VOcyGQAT.pngAfter that fix, reading/writing from/to EEPROM runs like a charm.

BUT:

The uart communication broke. That means, I request some data (exactly 70 Bytes) from MCU by sending a character (i.e. an V), but I get just 65 bytes, or 67 bytes, or 70 bytes, or 64 bytes... so it's not deterministic, but in 98% the requests I get less then 70bytes...

If I set all the priorities to 0, the uart communication is fine, but HAL_Delay stuck...

Any ideas? I've attached the whole project (STM32CubeIDE 1.10.1)

Thank you very much & kind regards,

Heinrich

1 ACCEPTED SOLUTION

Accepted Solutions
MM..1
Chief II

Primary dont use haldelay in interrupt routines.NEVER

View solution in original post

4 REPLIES 4
MM..1
Chief II

Primary dont use haldelay in interrupt routines.NEVER

Heinrich
Associate III

I'm using HAL_Delay in a function, which is called from interrupt routine, after clearing the IDLE flag.

Regards,

Heinrich

gbm
Lead III

And that's exactly what you should NOT do.

My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice
Heinrich
Associate III

Okay, my mistake...

After I reimplemented the UART stuff, I²C seems to run fine.

Thank you guys!