Bare Metal UART - Need Help

I am hoping someone could help me with this UART issue. I am completely new to this embedded programming. Just exploring the world of arm.

I have a problem, I don't see anything output to the Tera Term Terminal. My board is Nucleo STM32L476RG. I hope someone can point me in the right direction

Here is the code.
#include "stm32L4xx.h"

char msg[] = "Hello World";
int main(void){
	
	uint32_t Baudrate = 115200;
	
	// USART1 / GPIOA clock Enable
	
	RCC -> APB2ENR |= RCC_APB2ENR_USART1EN;
	RCC -> AHB2ENR |= RCC_AHB2ENR_GPIOAEN;
	
	GPIOA -> MODER |= GPIO_MODER_MODER9_1;
	GPIOA -> OTYPER &= ~(GPIO_OTYPER_OT9);
	GPIOA -> OSPEEDR |= GPIO_OSPEEDER_OSPEEDR9;
	
	USART1 -> BRR = SystemCoreClock / Baudrate; // for 80Mhz on APB2
	
	USART1 -> CR1 |= USART_CR1_TE | USART_CR1_UE;
	
	while(1){
		
		USART1 -> TDR = msg[1];  // TDR = Transmist Data Register
		
	}
}
Parents Reply Children
No data