Other Parts Discussed in Thread: MSPM0G3507, SYSCONFIG
-
How to configure two-sided edge detection for timers?
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
How to configure two-sided edge detection for timers?
Hi RU,
You can find an example for timer edge detection in [SDK Install Path]\mspm0_sdk_1_30_00_03\examples\nortos\LP_MSPM0G3507\driverlib\timx_timer_mode_compare_edge_count
To modify this example to check for both rising and falling edges, open the Sysconfig window, click on the TIMER - COMPARE tab, then scoll down to the "Compare Configuration" section. Open the dropdown for "Edge Detection Mode" and select "Rising and Falling Edge detection". Now the interrupt should execute on both rising and falling edges.
Thank you, but i need to get count value. the first "DL_TimerG_startCounter(COMPARE_0_INST);"
when i enter the interrupt, the function "DL_Timer_getCaptureCompareValue(COMPARE_0_INST, DL_TIMER_CC_1_INDEX);"or DL_Timer_getCaptureCompareValue(COMPARE_0_INST, DL_TIMER_CC_10_INDEX); value =0,
Hi RU,
If you want to get the counter's value in the interrupt, you should use the DL_Timer_getTimerCount(GPTIMER_Regs *gptimer) function, which returns the counter register's value. The two functions you mention in your first response will get the capture compare value instead of the current count value.
I think that the capture compare up event and down event can't both occur as they depend on the count direction. The compare up event will only occur when the timer is counting up, and the compare down event will only occur when the timer is counting down. It sounds like your current set-up has the counter going down. Try switching it to count up and the compare up event should occur, while the compare down event should not. Additionally, please ensure that you have properly enabled the interrupt.
For your final reply, a zero event occurs when a timer is loaded with the value 0. A load event occurs when the timer count register is loaded with the load value. Channel 0 compare down refers to when the counter value has counted down to the compare value.