Skip to main content
Associate
October 30, 2023
Solved

UART Receive issue

  • October 30, 2023
  • 31 replies
  • 10180 views

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

This topic has been closed for replies.
Best answer by EtienneLJ

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 ?

31 replies

EtienneLJAuthorBest answer
Associate
October 31, 2023

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 ?

Tesla DeLorean
Guru
October 31, 2023

Why ST couldn't have used a symbol for the vector table basis into SCB->VTOR is honestly beyond me...

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
waclawek.jan
Super User
October 31, 2023

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

EtienneLJAuthor
Associate
October 31, 2023

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.

Karl Yamashita
Principal
October 31, 2023

Your code you've posted is working on my Nucleo-G431B just fine.

docklightcapture.png

With the exception is that you should use strlen instead of guessing the length of the string. I was getting some null characters when i sent SONAR. 

usestrlen.png

Also remove the flag as i was getting double "msg_available"

removeflag.png

Now you're probably wondering why I was able to get your code to work? I saw the link to the tutorial and nowhere did it mention to enable the NVIC interrupt. How ST left that vital information out is beyond me?

 

enableinterrup.png

 

If a reply has proven helpful, click on Accept as Solution so that it'll show at top of the post.CAN Jammer an open source CAN bus hacking toolCANableV3 Open Source