Skip to main content
Visitor II
December 7, 2009
Question

USART Problem on STM8L101K3

  • December 7, 2009
  • 3 replies
  • 763 views
Posted on December 07, 2009 at 18:35

USART Problem on STM8L101K3

    This topic has been closed for replies.

    3 replies

    mandeep79Author
    Visitor II
    May 17, 2011
    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

    Visitor II
    May 17, 2011
    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,

    mandeep79Author
    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 15:05

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