AnsweredAssumed Answered

UART communication using STM8L discovery

Question asked by Narendra Suthar on Aug 23, 2015
Latest reply on Oct 4, 2016 by kumar.munish.001
Hi,

I am new to use STM8L controller.
I am just trying to put Simple character on UART using STM8L discovery board.
But I am failed to do this.
Following is my code for this.

void main(void)
{
    
    u8 Data = 'N';
    
    CLK_DeInit();
    GPIO_DeInit(GPIOC); 
    
    CLK_HSICmd(ENABLE);
    CLK_SYSCLKSourceConfig(CLK_RTCCLKSource_HSI);
    CLK_SYSCLKDivConfig(CLK_SYSCLKDiv_1);
        
    GPIO_ExternalPullUpConfig(GPIOA, GPIO_Pin_3, ENABLE);
    GPIO_ExternalPullUpConfig(GPIOA, GPIO_Pin_2, ENABLE);
    
    USART_DeInit(USART1);
    CLK_PeripheralClockConfig(CLK_Peripheral_USART1, ENABLE);
    USART_Init(USART1, 9600, USART_WordLength_8b, USART_StopBits_1, USART_Parity_No, USART_Mode_Tx | USART_Mode_Rx);
    USART_ClockInit(USART1, USART_Clock_Disable, USART_CPOL_Low, USART_CPHA_1Edge, USART_LastBit_Disable);
    USART_Cmd(USART1, ENABLE);        
    
    while(USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET)             // Wait for transmition to complete
    {
    }
    
    USART_SendData8(USART1, Data);
             
    GPIO_Init(GPIOC, GPIO_Pin_7, GPIO_Mode_Out_PP_High_Fast);                   // Init Blue LED
//    GPIO_Init(GPIOE, GPIO_Pin_7, GPIO_Mode_Out_PP_High_Fast);                   // Init Green LED
    
    /* Infinite loop */
    while (1)
    {
  // Wait for transmition to complete
        {
        }
    
        USART_SendData8(USART1, Data);


        GPIO_SetBits(GPIOC, GPIO_Pin_7);
        delay_ms(1000);
        
        GPIO_ResetBits(GPIOC, GPIO_Pin_7);
        delay_ms(1000);
        
    }
}

I am using IAR workbetch for STM8 evolution version.

Outcomes