AnsweredAssumed Answered

Testing if USART works?

Question asked by ashraf.salahuddin on Mar 23, 2014
Latest reply on Jul 8, 2015 by tadla.jeremy
Hi everyone, 
I'm a newbie with stm32f4Discovery kit, and I've just finished writing a code for implementing sending and receiving a character using USART, I'm using Keil uV5
Here is my code which is an example found on the web with some modification to suite stm32f407 microcontroller 
#include <stm32f4xx.h>

void USARTSetup(void);
int SendChar(int ch);
int GetChar(void);

int main(void)
     int input,output;
     output += output;
     input += input;
return 0;

void USARTSetup(void)
       //USART1 clock enable / port A clock enable
          RCC->AHB1ENR |= ((1<<0)|(1<<4));       
    //configure GPIOA 
          /*Each pin in portA has two corresponding bits in MODER, 00->input(default), 01->output, 10->alternate function
        *bit 18,19 = "10" to make PA9 as alternate function, bit 20,21 = "00" to make PA10 as input*/
    GPIOA->MODER |=(1<<19) ;          
       // step lightly , no pull up nor pull down resistors, 00->not pull nor push, 01->pull-up, 10->pull-down
    GPIOA->PUPDR = 0;                                   
          //speed of PA9 50MHz, 11->50MHz
          GPIOA->OSPEEDR |= ((1<<18)|(1<<19));
          //configure USART1
          //baud rate
          USART1->BRR = 64000000L/115200L;
          //enable Tx and Rx 
          USART1->CR1 |= ((1<<2)|(1<<3));
          //enable USART
          USART1->CR1 |= (1<<13);

int SendChar(int ch)
//Check if DR is empty and the previous sent data is sent or not, with checking <RXNE> bit
while(!( USART1->SR & (1<<7)));     
return (ch);

int GetChar(void)
//Check if data is recceived or not with checking <RXNE> bit
while(!(USART1->SR & (1<<5))); 
return ((int)(USART1->DR & 0xFF));

I've compiled this code and it was compiled without any errors or warning.. 
now I want to find out if my code function properly or not
I've installed RealTerm and plugged in my Kit and burn the code on the microcontroller, but nothing happened or appeared on RealTerm

Notes: every time I open RealTerm application an error appears 
"Error in GetComDevicesList opening registry key:..."
and I've no idea how to configure RealTerm to work well with Keil, stm32f4Discovery kit, and Windows 7??

so I'll be gratitude if anyone help
thanks a lot