2009-12-07 09:35 AM
USART Problem on STM8L101K3
2011-05-17 06:05 AM
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
2011-05-17 06:05 AM
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,2011-05-17 06:05 AM
Thanks Baroudi, You are right that was the problem. Now i am able to use USART.