在SensorControllerStudio里面
此函数 timer0Start(#mode, mant, #exp)如何通过input 输入参数更改第三个参数#exp,函数说明中此变量只能是常数,有没有类型转换什么的。
Felix ZF:
在SCS的help文档中,有这个函数的介绍
timer0Start
Prototype: timer0Start(#mode, mant, #exp)
Sets up AUX Timer 0 to generate events, either one-shot after the specified delay or repeatedly at the specified interval.
Parameter value(s)
#mode – Select single event or periodical events (TIMER0_MODE_XYZ)
mant – Delay/interval mantissa value (2-65535). Resulting delay/interval is mant * 2^exp [Sensor Controller clock periods].
#exp – Delay/interval exponent value (0-15). Resulting delay/interval is mant * 2^exp [Sensor Controller clock periods].同时,help文档中也有Timer0的示例代码
Examples
Single Event
// Generate timer event after 100 ustimer0Start(TIMER0_MODE_SINGLE, 2400, 0);gpioSetOutput(AUXIO_O_LED);// Wait for the timeouttimer0Wait();gpioClearOutput(AUXIO_O_LED);Periodical Events
// Generate timer events at every 100 ustimer0Start(TIMER0_MODE_PERIODICAL, 2400, 0);// Generate one pulse right awaygpioSetOutput(AUXIO_O_LED);gpioClearOutput(AUXIO_O_LED);// Generate another 3 pulsesfor (U16 n = 0; n < 3; n++) {// Wait for timer event before generating each pulsetimer0Wait();gpioSetOutput(AUXIO_O_LED);gpioClearOutput(AUXIO_O_LED);}// Stop the timertimer0Stop();Timeout
// Start an 8 ms timeouttimer0Start(TIMER0_MODE_SINGLE, 24000, 3);// Wait for sensor interrupt or timeout, whichever comes firstU16 interrupt;do {// Check whether the timeout has occuredU16 timer0IsRunning;timer0CheckState(timer0IsRunning);U16 timeout = timer0IsRunning ^ 0x0001;// Check whether the interrupt has occurredgpioGetInputValue(AUXIO_I_INTERRUPT; interrupt);U16 done = interrupt | timeout;} while (done == 0);// Stop the timertimer0Stop();