cancel
Showing results for 
Search instead for 
Did you mean: 

Missing ')' error while building code for STM8S105.

ankhola
Associate III

Hi guys,

I am a newbie in STM world. I am struggling with a small code but failing every attempt modifying the code googling for several times. Please have a look to my code. I have defined three functions, i.e. inv_on(), inv_off(), and sw_state().  When these functions are called in other defined functions, two errors, i.e. missing ')' and missing ';' are showing against each called functions. But when called in main(), one error i.e. missing ')' is showing. The error messages are given as comment. Suggestion is solicited please.

 

Regards

ankhola

 

#include "STM8S.h"
#include "ccp.h" 


void inv_on(void);
void inv_off(void);
void sw_state(void);

unsigned int pwm_duty1 = 40;
unsigned int pwm_duty2 = 50;
unsigned int i=0;
unsigned int duty;
unsigned char toggle=0;
unsigned char off_state;
unsigned char on_state;


@far @interrupt void TIM2_UPD_OVF_IRQHandler(void) {
    // 1. Clear the Interrupt Pending Bit
   if (TIM2->SR1 & TIM2_SR1_UIF)
    {
    if (toggle == 0)  { 
   TIM1_SetCompare2 (0);
	 i++;
     if(i == 125) {
		 i = 0;	
     toggle = ~ toggle;  
		 	
								  }
				 TIM1_SetCompare1(table[i]);
		  

										  }
	else             { 
   TIM1_SetCompare1 (0);
	 i++;
     if(i == 125) {
		 i = 0;	
	 toggle = ~ toggle;
	 
		 	                }
				 TIM1_SetCompare2(table[i]);
		  

									  }
                 
        TIM2->SR1 &= ~TIM2_SR1_UIF;
    }
}


void sw_state(void)  {
	if (GPIO_ReadInputPin, SW == 1)
	on_state = 1;
	else
	on_state = 0;
							}
							

void inv_on()  {
Clock_Config();
	TIM1_ComplementaryPWM_Init();
	TIM2_OC_Init();
	//GPIO_Init(GPIOD,GPIO_PIN_7, GPIO_MODE_OUT_PP_HIGH_FAST); 
	 enableInterrupts();
do  {
	sw_state(void);      //  #error cpstm8 main.c:79(9) missing )
                             //  #error cpstm8 main.c:79(15) missing ;
	}  while (on_state == 1);
							}
							
	void inv_off () {
TIM1 -> CCER1 &= 0xFA;
TIM2 -> IER = TIM2_IER_UIF;

do  {
	sw_state(void);     //  #error cpstm8 main.c:79(9) missing )
                             //  #error cpstm8 main.c:79(15) missing ;
	} while (on_state == 0);
								 }
	  

	
										 
	

void main(void)
{
	
	do  {
 sw_state(void);   //  #error cpstm8 main.c:79(9) missing )
if (on_state == 1)
inv_on(void);       //  #error cpstm8 main.c:79(9) missing )
else
inv_off(void);       //  #error cpstm8 main.c:79(9) missing )
		} while (1);
		    
	
//while(1) {
        // Main loop can be used for other tasks or dynamically changing PWM values
 //   }
}

#ifdef USE_FULL_ASSERT
void assert_failed(uint8_t* file, uint32_t line)
{
  while (1)
  {
		
  }
}
#endif

 

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Super User

When you call a function with no parameters, you don't put void.

//sw_state(void);  // invalid
sw_state();  // valid
If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

2 REPLIES 2
TDK
Super User

When you call a function with no parameters, you don't put void.

//sw_state(void);  // invalid
sw_state();  // valid
If you feel a post has answered your question, please click "Accept as Solution".
ankhola
Associate III

Thanks TDK. Problem is over.