AnsweredAssumed Answered

Basic USART Communication

Question asked by b.arumugam.001 on Feb 5, 2013
Latest reply on Feb 5, 2013 by Clive One
I am using stm32f107rct6 with 25Mhz freq for usart communication. i am sending character 'a' from PC but i am receiving some unwanted data like 'FE' and i am receiving the same data no change , so pls let me known why is this happening , i have tested the same code in  stm32f103rb series in 8Mhz frequency its working fine 
 the configuration and the code  i have done is shown below ,plz solve this as early as possible and its very critical , it is an online project.even i have attached the .c-file

#include<stdio.h>
#include<stm32f10x_lib.h>


void RCC_Config(void);
void GPIO_Config(void);


unsigned int temp,x;
char ch;
main()
{                           
     RCC_Config();
//     SystemInit();
     GPIO_Config();
     USART1->BRR=0x341;//0xA2C;     //9600 baud rate
     USART1->CR1=0x0000006D;      //TCIE &RXNEIE(read data reg not empty interrupt enable)
     USART1->CR2=0x000;            //eable clock
     USART1->CR1|=0x2000;
     NVIC->ISER[1] = 0x25;//USART1_IRQChannel //(1 << (USART1_IRQChannel & 0x1F));//0x00000020;
     USART1->CR1|=0x00002000;
     while(1)
     {     
     ;
     }
 }


void RCC_Config(void)
{
      RCC->APB2ENR=0x00004004;
}


void GPIO_Config(void)
{
       AFIO->MAPR=0x00000000;
       GPIOA->CRH = (GPIOA->CRH & 0xFFFFF00F)|0x4B0;
}
                  
void USART1_IRQHandler(void)
{
     if ((USART1->SR & 0x20))
     {
          temp=1;
          ch=USART1->DR;
          x=USART1->SR;
     }
     else if ((USART1->SR & 0x40))
     {
          if (temp==1)
          {
               x=USART1->SR;
               temp=0;
               USART1->DR=ch;      
          }
     
}


Attachments

Outcomes