This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

problem with IAR code

Hello
I wrote a program in IAR. The program has an error when executing the following line.

UART1_SendData8("A");

The complete program file is available below.
I would be grateful if you could tell me the mistakes of my code.

it is very short code and the error occurs in the last line
and microcontroller modell is STM8S003F3

2.zip

Parents
  • #include "stm8s.h"
    #include "stm8s_gpio.c"
    #include "stm8s_uart1.h"
    #include "stm8s_uart1.c"
    #include "stm8s_clk.h"
    
    
    #include "stm8s_gpio.h"
    #include "stm8s_conf.h"
    
    #include "stm8s_clk.c"
    
    void Clk_Config(void){
      CLK_DeInit();
      CLK_HSECmd(ENABLE);
      CLK_ClockSwitchConfig(CLK_SWITCHMODE_AUTO,CLK_SOURCE_HSE,DISABLE,CLK_CURRENTCLOCKSTATE_DISABLE);
      CLK_SYSCLKConfig(CLK_PRESCALER_CPUDIV1);
      CLK_ClockSecuritySystemEnable();
      CLK_PeripheralClockConfig(CLK_PERIPHERAL_UART1,ENABLE);
    }
    
    
    
    
    
    void UART1_setup(void)
    {
         UART1_DeInit();
                    
         UART1_Init(9600, 
                    UART1_WORDLENGTH_8D, 
                    UART1_STOPBITS_1, 
                    UART1_PARITY_NO, 
                    UART1_SYNCMODE_CLOCK_DISABLE, 
                    UART1_MODE_TXRX_ENABLE);              
                    UART1_Cmd(ENABLE);
                    UART1_ITConfig(UART1_IT_RXNE_OR, ENABLE);
    }
    
    
    
    int main( void )
     
    { 
             char var;
             Clk_Config();
             UART1_setup();
             GPIO_DeInit(GPIOD);       
             GPIO_Init(GPIOD, GPIO_PIN_5, GPIO_MODE_OUT_PP_HIGH_FAST);
             GPIO_Init(GPIOD, GPIO_PIN_6, GPIO_MODE_IN_PU_NO_IT);
             enableInterrupts();         
             UART1_SendData8("A");
             var = UART1_ReceiveData8();
    
    
     	
    }

    the error occurs in line 52 and error massage is : Error while running C/C++ Compiler

Reply
  • #include "stm8s.h"
    #include "stm8s_gpio.c"
    #include "stm8s_uart1.h"
    #include "stm8s_uart1.c"
    #include "stm8s_clk.h"
    
    
    #include "stm8s_gpio.h"
    #include "stm8s_conf.h"
    
    #include "stm8s_clk.c"
    
    void Clk_Config(void){
      CLK_DeInit();
      CLK_HSECmd(ENABLE);
      CLK_ClockSwitchConfig(CLK_SWITCHMODE_AUTO,CLK_SOURCE_HSE,DISABLE,CLK_CURRENTCLOCKSTATE_DISABLE);
      CLK_SYSCLKConfig(CLK_PRESCALER_CPUDIV1);
      CLK_ClockSecuritySystemEnable();
      CLK_PeripheralClockConfig(CLK_PERIPHERAL_UART1,ENABLE);
    }
    
    
    
    
    
    void UART1_setup(void)
    {
         UART1_DeInit();
                    
         UART1_Init(9600, 
                    UART1_WORDLENGTH_8D, 
                    UART1_STOPBITS_1, 
                    UART1_PARITY_NO, 
                    UART1_SYNCMODE_CLOCK_DISABLE, 
                    UART1_MODE_TXRX_ENABLE);              
                    UART1_Cmd(ENABLE);
                    UART1_ITConfig(UART1_IT_RXNE_OR, ENABLE);
    }
    
    
    
    int main( void )
     
    { 
             char var;
             Clk_Config();
             UART1_setup();
             GPIO_DeInit(GPIOD);       
             GPIO_Init(GPIOD, GPIO_PIN_5, GPIO_MODE_OUT_PP_HIGH_FAST);
             GPIO_Init(GPIOD, GPIO_PIN_6, GPIO_MODE_IN_PU_NO_IT);
             enableInterrupts();         
             UART1_SendData8("A");
             var = UART1_ReceiveData8();
    
    
     	
    }

    the error occurs in line 52 and error massage is : Error while running C/C++ Compiler

Children
No data