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.

MSPM0G3519: MSPM0G3519: Capture or Compare Register is reset after start counter timer

Part Number: MSPM0G3519

Dear TI Expert,

I am trying to configure the TIMA0 timer in PWM mode.
However, I am encountering an issue: when I start the counter by setting the EN bit in the CTRCTL register, the Capture/Compare Register (CC) is reset to zero. As a result, I need to reconfigure the CC register again.

When I compare this behavior with the results from the SDK example code, I notice a difference — in the SDK example, the CC register does not change when the timer is enabled.

I am wondering whether I might have made a mistake in the initialization sequence, perhaps configuring the registers in the wrong order.

Could you please help me understand what might be causing this issue?

Thank you!

  • I expect this has to do with the setting of CTRCTL:CVAE [Ref TRM (SLAU846C) Table 27-68]. You want it to be set to =1 (no change), but (skimming the Driverlib source) it is normally set to =0 (LDVAL).

    I don't see a way to request an alternate value of CVAE in the PWMConfig, but it looks like you can use something resembling:

    > DL_Timer_setCounterValueAfterEnable(<your-timer>, DL_TIMER_COUNT_AFTER_EN_NO_CHANGE); // CVAE=1

    between configuring and starting the timer.

  • Sorry, you said CC registers, not CTR.

    I expect this has to do with the use of shadow registers. When they're enabled, writing the CC writes to the shadow register, not the CC register (the CC register will only be updated after the CCACT trigger) and vice versa.

    To get the startup behavior one usually wants, you have to write the CC twice, i.e. write/enable-shadow/write.

  • Hello Hoc,

    I don't expect the CCx register to change when you EN the timer... well in most modes.  I guess in some input modes, it might clear a CC register it's using for a capture.  

    Can you share your configuration settings?  Copy past of these small section of code would be good.  

    Overall, I would just recommend copy what the SDK example is doing.  I don't know of a specific order required but who ever wrote the example probably did.  

    Thanks,

    JD

  • Now it's clear.
    Thanks for your support.