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.

MSPM0G3507: Timer capture mode

Part Number: MSPM0G3507


Tool/software:

I'm using the timx_timer_mode_capture_edge_capture_LP_MSPM0G3507_nortos_ticlang example for edge captures.

After reading the capture value, I want to reset the Capture/Compare value (CC_01) back to zero. I tried using the DL_Timer_getCaptureCompareValue() function, but it didn’t work.

Is there a way to reset the Capture/Compare value (CC_01) to zero after reading it?

  • As far as I know the CC registers are writeable in Capture mode. I expect you can use something like:

    > DL_Timer_setCaptureCompareValue(CAPTURE_0_INST, 0, DL_TIMER_CC_0_INDEX);

    Keep in mind that this introduces a race, where you lose the capture value for an edge which arrives in the meantime. Also, the value of doing this is not obvious.

  • DL_Timer_setCaptureCompareValue(CAPTURE_0_INST, 0, DL_TIMER_CC_0_INDEX);

    I used the same function but it it not working.

  • How do you tell that it doesn't work? What is your test case?

  • My test setup is such that I don’t read the capture value inside the capture interrupt. Instead, I read it periodically from another timer interrupt. After reading the capture register value, I want to reset it to zero, so that if no new capture occurs in the next timer cycle, I’ll read 0.

    But when I write the capture register value as 0 after reading, the value doesn’t change.

  • I see what you mean. Poking with the debugger it appears you can't write a CC register if its COC=1. [I had this idea I had done this once but evidently I didn't check very carefully.]

    If your goal is to avoid having an ISR for the capture, you could instead poll/clear the relevant bit in the Raw Interrupt Status (RIS:CCD0 in the Example). [Ref TRM (SLAU846C) Table 27-40]

    [Edit: Added reference]