cancel
Showing results for 
Search instead for 
Did you mean: 

STMG01 Baremetal UART not Working

PLee.3
Associate III

Hi, I wonder has anyone experience with baremetal USART implementation as I have attached a Source file for USART for a 'STM32G0B1RET' discovery board but it just sits there and doesn't transmit anything? See attached (usart.c). I have basically just copied this from a working F4 board and modified it for a G0 board (assuming it would work!?)...

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

> 'STM32G0B1RET' discovery board

Do you mean Nucleo board?

I compiled your code (commenting out SetSystemClockTo16Mhz() as you did not provide that function, but simply leaving the default HSI16 clock, that's 16MHz too), and on Nucleo I can see the transmitted data on PA2 (and also LED on PA5 blinking slowly).

JW

 

PS. You set USART2_BRR in USART1 setup, but you don't call that function here.

View solution in original post

4 REPLIES 4

> 'STM32G0B1RET' discovery board

Do you mean Nucleo board?

I compiled your code (commenting out SetSystemClockTo16Mhz() as you did not provide that function, but simply leaving the default HSI16 clock, that's 16MHz too), and on Nucleo I can see the transmitted data on PA2 (and also LED on PA5 blinking slowly).

JW

 

PS. You set USART2_BRR in USART1 setup, but you don't call that function here.

Hi JW,

Thanks for trying it out I have just had a closer look and something really odd is happening if you use "UART2_send" it transmits to UART1 TX (PC4) and if you use "UART1_send" it transmits to UART2 TX (PA2)? I can't workout why it's doing this as the UART send commands it clearly states the correct Registries:-

void UART1_send(char *msg, size_t len){
for (uint64_t i=0; i<len; i++)
{
     // send character
     USART1->TDR = msg[i];
     // wait for transmit complete (ts)
     while(!(USART1->ISR & (1 << 6)));
}
}

 

PLee.3
Associate III

Hi JW, Now it explains as I used the incorrect pinouts and the pins where swapped! as below diagram (wrong one is at the bottom).

G070RB Pinout.PNG

STMF32G01B1RE.PNG

 

Thanks for coming back with the solution. Please click on "Accept as solution" in that post so that the thread is marked as solved.

Where is that incorrect picture from?

JW