2013-02-04 11:41 PM
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; } } }2013-02-05 05:03 AM
Check the clock and PLL settings, and confirm the CPU is running at the frequency you expect, use the MCO pin if required.
Invalid data rates almost always relate to a mismatch between actual and assumed clocks. If you were using the library the HSE_VALUE would be critical. The CMSIS library calls SystemInit() prior to main()