cancel
Showing results for 
Search instead for 
Did you mean: 

USART Problem on STM8L101K3

mandeep79
Associate II
Posted on December 07, 2009 at 18:35

USART Problem on STM8L101K3

3 REPLIES 3
mandeep79
Associate II
Posted on May 17, 2011 at 15:05

Hi All,

I am facing a problem with USART functionality and I am trying to debug it for last four days without success. Finally I am coming back to forum for some help.

I am trying to transmit three characters over USART in STM8L. Here is the code that i am using:

 

USART_DeInit();

 

GPIO_Init(GPIOC, GPIO_Pin_3, GPIO_Mode_Out_PP_High_Fast ); //UART_TX

 

GPIO_Init(GPIOC, GPIO_Pin_4, GPIO_Mode_Out_PP_High_Fast); //UART_CK

 

USART_ClockInit ( USART_Clock_Enable, USART_CPOL_Low , USART_CPHA_1Edge , USART_LastBit_Enable );

 

USART_Init(9600, USART_WordLength_8D, USART_StopBits_1, USART_Parity_No, USART_Mode_Tx);

 

USART_Cmd (ENABLE);

 

USART_SendData8 (97);

 

USART_SendData8 (98);

 

USART_SendData8 (99);

 

I am not seeing anything on TX pin (PC3). It remain high.

Please let me know what I am doing wrong. Has anyone else able to get USART working on STM8L. If yes, I would be very thankful if you can forward me the code.

Also i have verified that UART pins are not externally stuck in hardware by making pins configured as GPIO and changing them. I could see proper transitions when pins are GPIO.

Thanks & Regards,

Mandeep

baroudi
Associate II
Posted on May 17, 2011 at 15:05

Hi Mandeep,

You should perhaps add the line below.

/* Enable USART clock */

CLK_PeripheralClockConfig(CLK_Peripheral_USART, ENABLE);

In STM8L family, peripheral clock should be enabled to be able to access to peripheral registers.

With regards,

mandeep79
Associate II
Posted on May 17, 2011 at 15:05

Thanks Baroudi, You are right that was the problem. Now i am able to use USART.