cancel
Showing results for 
Search instead for 
Did you mean: 

UART Receive issue

EtienneLJ
Associate III

Hello,

I'm struggling with a really strange issue. I'm trying to make UART RX working on a STM32G4 custom board.

I've followed the UART Interrupt tutorial. (https://wiki.st.com/stm32mcu/wiki/Getting_started_with_UART)

I've tested it with Nucleo-G431RB and it works fine.

Now I'm running the exact same code on my custom board and I have nothing, when using the debugger I can see that the interrupt is never fired. I've check hardware connections and everything seems OK.

I've also tried to implement UART_Receive by polling mode => I can see in the debugger that characters are received, so Hardware is OK.

Can someone help me with this issue ?

Thanks

31 REPLIES 31

The waveform you've posted above is 2 bytes (0x4D 0x0A), that would explain the overrun.

Here is a generic checklist to troubleshoot "interrupt does not fire" problems.

JW

I've setup an interrupt on a GPIO and it doesn't fire also. 

Then you have disabled interrupts globally, or your program entirely runs in some other interrupt of same or higher priority, or your program never reached the code enabling the interrupts.

If you pause execution, where does the PC (Program Counter) point to?

JW

EtienneLJ
Associate III

It points to the if statement of the while(1) loop in main.c.

The program never reaches HAL_EXTI_IRQHandler. (I tried to toggle a GPIO in it)

EtienneLJ
Associate III

Looking at EXTI registers. the bit 5 of EXTI_FTSR1 is well set and when applying a 0 level on this pin the bit 5 of EXTI_PR1 is set to 1.

EXTI ?

Start by establishing the EXTIxx_IRQHandler() that's called by the NVIC, you are then responsible for calling into the HAL which then calls your function.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

EXTI9_5_IRQHandler what should points to this function ? 

EtienneLJ
Associate III

I found a solution by adding "#define USER_VECT_TAB_ADDRESS" to the beginning of system_stm32g4xx.c. The interrupt vector table was not set correctly.

So what I did wrong when I've generate the code with MXCube ?

And why my old code was working on the Nucleo and not on my custom board ?

Did you power-cycle your board since first programming?

Maybe this - empty FLASH resulting in starting bootloader thus remapping the System memory instead of User FLASH at 0x0000'0000?

JW

EtienneLJ
Associate III

What do you mean by power-cycle ? Just cut off power and re-power ? if so, yes i did it multiple times.

Anyways, thanks for your precious help, both of you.