cancel
Showing results for 
Search instead for 
Did you mean: 

UART3 in STM8S207 with HSE

baxingguachi
Associate
Posted on January 09, 2012 at 10:54

Please help me about

I use STM8S207 for HSI : I use UART3. I can be control it normally. with follow code -->

UART3_DeInit();
UART3_Init((u32)9600, UART3_WORDLENGTH_8D, UART3_STOPBITS_1,UART3_PARITY_NO, UART3_MODE_TXRX_ENABLE);
SerialPutChar('A');

And then I change to HSE. I can not control it such as I send 'A' char to PC but PC receive only garbage char not 'A' by I add this code -->

CLK_ClockSwitchConfig2(CLK_SWITCHMODE_AUTO, CLK_SOURCE_HSE, DISABLE, CLK_CURRENTCLOCKSTATE_DISABLE);

1 REPLY 1
baxingguachi
Associate
Posted on May 19, 2012 at 11:07

From I tried, it work if use Fosc external @24MHz, if use freq is not equal 24 MHz will be not wok.

So, we have to change a freq. of external crystal at file ''stm8s.h'' follow :

#if !defined HSE_Value
#if defined (STM8S208) || defined (STM8S207) || defined (STM8AF52Ax) || defined (STM8AF62Ax)
#define HSE_VALUE ((u32)24000000) /* Value of the External oscillator in Hz*/
#else
#define HSE_VALUE ((u32)16000000) /* Value of the External oscillator in Hz*/
#endif /* STM8S208 || STM8S207 || STM8AF62Ax || STM8AF52Ax */
#endif /* HSE_Value */

By change HSE_VALUE from 24000000 to real freq. of external crystal in Hz unit