Author Topic: problem with IAR code  (Read 1161 times)

0 Members and 1 Guest are viewing this topic.

Offline ُSTP.AsghariTopic starter

  • Newbie
  • Posts: 7
  • Country: ir
problem with IAR code
« on: January 10, 2023, 07:47:56 am »

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.
 

Offline ُSTP.AsghariTopic starter

  • Newbie
  • Posts: 7
  • Country: ir
Re: problem with IAR code
« Reply #1 on: January 10, 2023, 09:13:13 am »
it is very short code and the error occurs in the last line
and microcontroller modell is STM8S003F3
 

Offline ُSTP.AsghariTopic starter

  • Newbie
  • Posts: 7
  • Country: ir
Re: problem with IAR code
« Reply #2 on: January 10, 2023, 09:51:32 am »
the code is here :
Code: [Select]
#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 is in line 52
and the error message is :
Error while running C/C++ Compiler
 

Offline abyrvalg

  • Frequent Contributor
  • **
  • Posts: 898
  • Country: es
Re: problem with IAR code
« Reply #3 on: January 10, 2023, 10:12:37 am »
Replace double quotes around A with singles.
“A” produces a zero-terminated string and passes a pointer to it into the function call, but the SendData8 function expects a single character to be passed.
« Last Edit: January 10, 2023, 10:15:10 am by abyrvalg »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

- - -
-->