Problem with UART on STM8L151
I've been struggling with this problem for some time. Currently I'm porting my application from STM8L051 to STM8L151. Whenever I start USART1 Receiver, the USART Status Register (USART->SR) shows "0xfa", indicating Parity and Overrun Error. I tried with a different chip and still the same results. I'm using a bare chip soldered to QFP32 board with 100nF capacitor between VDD and VSS. The same program works ok on STM8L051. When I turn on USART TX only, USART->SR shows 0xC0. However when I turn on receiver, I get errors on USART and they won't disappear even after reading from DR and SR registers. I tried different power supply and still the same issues....
I'm using internal clock with default frequency of 2Mhz (HSI/8). If I change the prescaler to DIV1, still no progress.
Here's USART code:
CLK_PeripheralClockConfig(CLK_Peripheral_USART1, ENABLE);
//GPIO_Init(GPIOA, GPIO_Pin_3, GPIO_Mode_In_PU_No_IT);
//GPIO_ExternalPullUpConfig(GPIOA, GPIO_Pin_2 | GPIO_Pin_3, ENABLE);
USART_DeInit(USART1);
USART_Init(USART1, 9600, USART_WordLength_8b, USART_StopBits_1, USART_Parity_No, (USART_Mode_Rx));
USART_Cmd(USART1, ENABLE);