How to use a variable as a parameter in a function that only suports constant expresssion

前端 未结 3 600
南笙
南笙 2021-01-20 21:02

I\'m using this function:

__delay_cycles(var); 

and I get the following error:

Argument to _delay_cycles

3条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-20 21:10

    if(var==1)
      __delay_cycles(1);
    else if(var==2)
      __delay_cycles(2);
    else if(var==3)
      __delay_cycles(3);
    

    ...and so on.

提交回复
热议问题