AnsweredAssumed Answered

USART on the STM32F051

Question asked by schwarz.dennis on Oct 28, 2013
Latest reply on Oct 28, 2013 by schwarz.dennis
Hi Folks,

I am a little bit confused about the USART built in in the STM32F051. He is don`t talking to me although I am asking really polite.

This is my init-code:

RCC -> AHBENR |= (RCC_AHBENR_GPIOAEN);

//PA9
GPIOA->OSPEEDR  |= (1UL<< 18);               //MEDIUM SPEED
GPIOA->OTYPER     &= ~(1UL<<9);             //Push-pull
GPIOA->MODER    |= (1UL<<19);                  //AF-Mode
GPIOA->AFR[1]   |= (1UL << 4);                     //AF1 selected

//PA10   
GPIOA->MODER    |= (1UL<<21);                  // AF-Mode
GPIOA->AFR[1]   |= (1UL<<8);                       // AF1 selected

RCC ->APB2ENR |= (1UL<<14);

USART1  -> CR1 = 0x0000000C;                     // enable TX and RX
USART1  -> CR2 = 0x00000000;
USART1  -> CR3 = 0x00000000;             
USART1  -> BRR = 0x00000034;
USART1 -> CR1 |= (1UL << 0);

And this here is my  TX-Routine:

void USART1_tx (char TX_char){

    while (!(USART1 -> ISR  &  ( 1UL << 6))) { __NOP();}        
    
    USART1 -> TDR = TX_char;  

}

Anyone an idea, where the problem is?


Outcomes