[SOLVED] problem with IAR code

Thread Starter

STP.Asghari

Joined Nov 22, 2022
12
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.
 

Attachments

  • 612.7 KB Views: 1

Thread Starter

STP.Asghari

Joined Nov 22, 2022
12
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
 

Ya’akov

Joined Jan 27, 2019
9,165
Welcome to AAC.

No one is going to download and decompress your file, so you‘ll need to use [CODE] tags available in the 1673342628001.png menu in the editor toolbar and paste in the text.

You will also need to provide the error message(s) in the same way.

Remember, you know what is going on but we don’t and we aren’t telepathic so “I get an error” is as good as “it doesn’t work” as an explanation of your problem.

Try fixing the code and we’ll see if someone can help you.
 

Thread Starter

STP.Asghari

Joined Nov 22, 2022
12
UART1 code:
#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();


    
}
 
Top