TI中文支持网
TI专业的中文技术问题搜集分享网站

SensorControllerStudio开发

在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 us
timer0Start(TIMER0_MODE_SINGLE, 2400, 0);
gpioSetOutput(AUXIO_O_LED);

// Wait for the timeout
timer0Wait();
gpioClearOutput(AUXIO_O_LED); 

Periodical Events

// Generate timer events at every 100 us
timer0Start(TIMER0_MODE_PERIODICAL, 2400, 0);

// Generate one pulse right away
gpioSetOutput(AUXIO_O_LED);
gpioClearOutput(AUXIO_O_LED);

// Generate another 3 pulses
for (U16 n = 0; n < 3; n++) {

// Wait for timer event before generating each pulse
timer0Wait();
gpioSetOutput(AUXIO_O_LED);
gpioClearOutput(AUXIO_O_LED);
}

// Stop the timer
timer0Stop(); 

Timeout

// Start an 8 ms timeout
timer0Start(TIMER0_MODE_SINGLE, 24000, 3);

// Wait for sensor interrupt or timeout, whichever comes first
U16 interrupt;
do {

// Check whether the timeout has occured
U16 timer0IsRunning;
timer0CheckState(timer0IsRunning);
U16 timeout = timer0IsRunning ^ 0x0001;

// Check whether the interrupt has occurred
gpioGetInputValue(AUXIO_I_INTERRUPT; interrupt);

U16 done = interrupt | timeout;
} while (done == 0);

// Stop the timer
timer0Stop(); 

赞(0)
未经允许不得转载:TI中文支持网 » SensorControllerStudio开发
分享到: 更多 (0)