AnsweredAssumed Answered

USART1 Doesn't transmit

Question asked by black.mike on Sep 28, 2015
Latest reply on Sep 29, 2015 by black.mike
I have been trying to get my code to work but I cannot get any output on PA9 (USART1_Tx) on my STM32f0discovery board. Any help would be greatly appreciated.

CODE ==========================================================

void InitUART() {
    
    // RCC Setup
    
    RCC->CFGR = 0;
    RCC->CFGR3 &= 0xFFFFFFFC;
    RCC->APB2ENR |= (1<<14);
    RCC->AHBENR |= (1<<17);
    
    // GPIO Setup
    
    GPIOA->MODER &= 0xFFC3FFFF; GPIOA->MODER |= 0x00280000L;     
    GPIOA->OSPEEDR = 0x003c0000;     
    GPIOA->OTYPER = 0;
    GPIOA->PUPDR &= 0xFFC3FFFF; GPIOA->PUPDR|=0x00140000;   // Pull up on both lines
    
    // USART Setup
    
    USART1->CR2 = 0;
    USART1->CR3 = 0;
    USART1->BRR = 69;         // 8MHz clock, 115200 rate
    USART1->GTPR = 1;
    USART1->RTOR = 0;
    USART1->RQR = 0;
    
    USART1->CR1 = USART_CR1_RE | USART_CR1_TE | USART_CR1_UE;
    
    }

void SendByte(unsigned char b) {
    
    while ((USART1->ISR & USART_ISR_TXE) == 0);
    USART1->TDR=b;
    while ((USART1->ISR & USART_ISR_TXE) == 0);
    }

int main() {

    InitUART();
    
    
    for(;;) {
        SendByte(0xF0);
        SendByte(0x55);
        for(i=0;i<50;i++) ;
        }
    }

==============================================================

Outcomes