Part Number: LP-
Other Parts Discussed in Thread: MSPM0G3507
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.
> if ((temp2 & DL_TIMER_IIDX_CC0_UP) == DL_TIMER_IIDX_CC0_UP)
The IIDX is a small integer, not a bit vector [Ref TRM (SLAU846B) Table 27-38]. In particular, CCU0 is 0x09 and CCD0 is 0x05. This works by accident since (I suppose) you only have the two interrupts enabled. This should properly be:
> if (temp2 == DL_TIMER_IIDX_CC0_UP)
------------
> DL_TimerG_clearInterruptStatus(TIMER_HALL_C_INST, DL_TIMER_IIDX_CC0_UP);
This function expects a bit vector, not an IIDX value [Ref TRM Table 27-56], so this clears some other conditions. If you wanted to do this, it would look like:
> DL_TimerG_clearInterruptStatus(TIMER_HALL_C_INST, DL_TIMER_INTERRUPT_CC0_UP_EVENT);
but reading the IIDX register clears the interrupt condition automatically, so you don't need this line at all.
it often mixes up the edges when it detects a falling edge on a rising edge.
All edges are recognized
I don't see anything in this code that recognizes a rising vs a falling edge. Generally, you need two channels (one for rising and the other for falling) tied to a single pin to do this.
The CCU/CCD events indicate the direction that the counter is counting (at that moment) not the pin edge.
Hello Mr. McKenney,
and how can I implement this? unfortunately, I am not yet so fit in it.
This is described in (e.g.) the "Combined Pulse Width and Period Time" Use Case [TRM (SLAU846B) Sec 27.2.3.1.2.4]. The key is in Step (6) which sets IFCTL:ISEL to assign both timer channels to the same input pin [Ref TRM Table 27-80]; and in Step (5) where the CCCTL:CCONDs for the two channels are set opposite (rising vs falling edge) to one another [Ref TRM Table 27-73].
This is illustrated in example "timx_timer_mode_capture_duty_and_period" here:
https://dev.ti.com/tirex/explore/node?node=A__ACdsrKl.4hX4Pw9rSp1lsA__MSPM0-SDK__a3PaaoK__LATEST
The timer setup is done using a synthesized timer "mode" (DL_TIMER_CAPTURE_COMBINED_MODE_PULSE_WIDTH_AND_PERIOD) so most of the setup is in the Driverlib code.
[Unfortunately, the Forum seems to have lost your original post, so I'm guessing that you're using the MSPM0G3507 (or similar).]
[Edit: Fixed typo.]