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

Msp432p401能用在程序中随时访问TA定时器的TAR计数值吗?

Msp432p401能用在程序中随时访问TA定时器的TAR计数值吗?访问丅AR的值及时准确不?

Susan Yang:

您可以尝试使用 Timer_A_getCounterValue

uint16_t Timer_A_getCounterValue
(
uint32_t 
timer
)

Returns the current value of the specified timer. Note that according to the Timer A user guide, reading the value of the counter is unreliable if the system clock is asynchronous from the timer clock. The API addresses this concern by reading the timer count register twice and then determining the integrity of the value. If the two values are within 10 timer counts of each other, the value is deemed safe and returned. If not, the process is repeated until a reliable timer value is determined.

Parameters

timer
is the instance of the Timer_A module. Valid parameters vary from part to part, but can include:

TIMER_A0_BASE
TIMER_A1_BASE
TIMER_A2_BASE
TIMER_A3_BASE

ReturnsThe value of the specified timer

References TIMER_A_CMSIS, and TIMER_A_THRESHOLD.

另外建议您阅读以下 TRM 的 19.2.1 16-Bit Timer Counter

The 16-bit timer/counter register, TAxR, increments or decrements (depending on mode of operation) with each rising edge of the clock signal. TAxR can be read or written with software. Additionally, the timer can generate an interrupt when it overflows.

TAxR may be cleared by setting the TACLR bit. Setting TACLR also clears the clock divider and count direction for up/down mode.

NOTE: Modifying Timer_A registers It is recommended to stop the timer before modifying its operation (with exception of the interrupt enable, interrupt flag, and TACLR) to avoid errant operating conditions. When the timer clock is asynchronous to the CPU clock, any read from TAxR should occur while the timer is not operating or the results may be unpredictable. Alternatively, the timer may be read multiple times while operating, and a majority vote taken in software to determine the correct reading. Any write to TAxR takes effect immediately.

赞(0)
未经允许不得转载:TI中文支持网 » Msp432p401能用在程序中随时访问TA定时器的TAR计数值吗?
分享到: 更多 (0)