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

前端 未结 3 648
南笙
南笙 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:07

    One suggestion that immediately springs to mind is to call __delay_cycles() with a constant argument, but do it in a loop, and vary the number of loop iterations.

    The loop will add some overhead, so if you need precision you'll have to subtract the (constant) cost of one loop iteration from the (constant) argument to __delay_cycles().

提交回复
热议问题