STM32F411RE UART not working with IAR debugger

0

I am currently learning to work with stm32f411re. I use PA9/10 as TX and RX with baud rate 9600 and 1 start 8 bit word and 1 stop without parity. I connected PA9/PA10 with FTDI to my PC and i am trying to send from serial terminal. Trying to do this with interrupts. As i can see from debugger it is entering into ISR, but its echoing wrong characters. 16Mhz RC oscillator was used as clk. No prescalers. Oversampling default (16). Thank you for your time

#include "stm32f4xx.h"
#include "system_stm32f4xx.h"
#define DELAY 0xFFFFFFFF
#define SEK 16000000
void USART1_IRQHandler  (void) ;
int main() {
  RCC->AHB1ENR|=(1<<0); //GPIOA
  RCC->APB2ENR|=(1<<4); // Clock za USART1
  GPIOA->MODER|=(1<<10);
  GPIOA->MODER|=0x3;
  GPIOA->MODER|=0x280000; //PA9 I PA10 ALTERNATIVE MODE
  GPIOA->AFR[1]|=0x770; //0111 AF07 
  USART1->CR1|=(1<<13); //enable usart
  USART1->BRR=0x683; //9600
  USART1->CR1|=((1<<3) | (1<<2)); //TX I RX ENABLE 
  USART1->CR1|=(1<<5); //ENABLE USART INTERRUPT RECEIVE

__NVIC_EnableIRQ( USART1_IRQn );
   USART1->DR='a';

  while(1){

   }


return 0;
} 

void USART1_IRQHandler  (void) 
{
    char c;
    c=USART1->DR;
    USART1->DR=c;
}

stm32
uart
iar
stm32f4
usart
asked on Stack Overflow Feb 7, 2020 by Alexandar13

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0