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.

LP-MSPM0L2228: How to do a 32-bit Read of TIMG12 Current Counter Value

Part Number: LP-MSPM0L2228
Other Parts Discussed in Thread: MSPM0L2228

Tool/software:

How is a 32 bit read of TIMG12 or TIMG13 performed? The counter value register only has a 16 bit value and the SDK function to read the register enforces a 16 bit read. I’m assuming two 16 bit reads need to be performed somehow.

  • According to the docs, the driverlib function returns a 32 bit value

  • Bits 16 - 31 of the CTR are reserved; the current count value is returned in bits 0 - 15. The SDK function to read the CTR masks off bits 16 - 31.

    __STATIC_INLINE uint32_t DL_Timer_getTimerCount(GPTIMER_Regs *gptimer)
    {
    return (gptimer->COUNTERREGS.CTR & GPTIMER_CTR_CCTR_MASK);

  • This might be a bug - you can read it directly - but the high word is reserved for *writing*, not *reading*

  • Actually the mask expands to:

    #define GPTIMER_CTR_CCTR_MASK                    ((uint32_t)0xFFFFFFFFU)         /* !< Current Counter value */
    not much of a mask at all!
  • The mask for the SDK I have is defined as:

    #define GPTIMER_CTR_CCTR_MASK ((uint32_t)0x0000FFFFU) /* !< Current Counter value */

    The define is located in: \ti\devices\msp\peripherals\hw_gptimer.h

    The SDK I have is:mspm0_sdk_2_00_01_00

    The MSPM0L Reference manual I have is: Literature Number: SLAU847D OCTOBER 2022 – REVISED MAY 2024

    It shows the following for the TIMx CTR.

    I checked the disassembly in the debugger for the DL_Timer_getTimerCount funtion:

    The mask is being applied via the uxth instruction.

    There's some type of miss-match between what you have and what I have. The MCU selection symbol we are using is: __MSPM0L2228__. We don't have much functionality in the software yet, but what we have is operational -- including a free-running 16-bit timer TIMG0. Not sure what the source of the miss-match is between our two mask defines. I haven't tried building with TIM12 (32-bit counter) yet; seems like it wouldn't work which is what prompted my original question.

  • I just pulled the timer example after setting Resource Explorer to the MSPM0L2228 Launchpad.

    Your TRM reference is the same as mine. At this point, I think we need to have TI comment.

  • I also checked a more recent version of the SDK. The mask is 0xFFFFFFFFU in that version. Looks like it was corrected. Thanks for your help, much appreciated.