[MKW01] TPM pulse counter in VLPS

cancel
Showing results for 
Search instead for 
Did you mean: 

[MKW01] TPM pulse counter in VLPS

Jump to solution
428 Views
giancarlozanuz
Contributor III

Hello, I'm having some trouble to use the TPM as a pulse counter in VLPS.

In RUN mode it counts the pulses, but when I put in VLPS it stops counting.

I'm using the input pin PTE16 - ALT4 (TPM_CLKIN0).

Some question, do the TPM source clock needs to be active in VLPS to count pulses? Isn't it an async operation? Cause the TPM clock source is 'kClockTpmSrcPllFllSel', which is disabled in VLPS.

Thanks in advance.

------------------------------------

EDIT: Ok, when I change the clock source to 'kClockTpmSrcOsc0erClk', it works normally. But now it is generating a wakeup interrupt every ~60s, which is strange, since the interruptions are off. I'm using an external xtal at 32.768kHz as the clock source.

Here is the source code:

            configure_tpm_pins(DEFAULT_PULSES_TPM_INSTANCE);
            
            tpm_general_config_t TPMConfig = {
                .isDBGMode                  = false,
                .isGlobalTimeBase           = false,
                .isTriggerMode              = false,
                .isStopCountOnOveflow       = false,
            };
            if(TPM_DRV_Init(DEFAULT_PULSES_TPM_INSTANCE, &TPMConfig) != kStatusTpmSuccess)
                return false;
            
            CLOCK_SYS_SetTpmSrc(DEFAULT_PULSES_TPM_INSTANCE, kClockTpmSrcOsc0erClk);
            TPM_DRV_SetClock(DEFAULT_PULSES_TPM_INSTANCE, kTpmClockSourceExternalClk, kTpmDividedBy1);
            CLOCK_SYS_SetTpmExternalSrc(DEFAULT_PULSES_TPM_INSTANCE, kSimTpmClkSel0);
            TPM_DRV_CounterStart(DEFAULT_PULSES_TPM_INSTANCE, kTpmCountingUp, 0xFFFF, false);

Thanks,

Labels (1)
Tags (3)
0 Kudos
1 Solution
93 Views
gerardo_rodriguez
NXP Employee
NXP Employee

Hello Giancarlo,

The TPM external clock is synchronized to the TPM counter clock, so when you selected 'kClockTpmSrcPllFllSel' (disabled in VLPS), the external clock was not being synchronized. You can see in the following table that the OSCERCLK is enabled in VLPS, so that is why with this clock source it works correctly.

pastedImage_1.png

In the Figure 27-1. TPM block diagram, you can see the synchronizer of the external clock.

pastedImage_2.png

About the interrupt, can you verify that the TPMx_SC[TOIE] bit is set to 0? You could also try, disabling the interrupt from the NVIC module with the INT_SYS_DisableIRQ(g_tpmIrqId[instance]) function.

Let me know any question you may have.

Regards,

Gerardo

View solution in original post

0 Kudos
4 Replies
94 Views
gerardo_rodriguez
NXP Employee
NXP Employee

Hello Giancarlo,

The TPM external clock is synchronized to the TPM counter clock, so when you selected 'kClockTpmSrcPllFllSel' (disabled in VLPS), the external clock was not being synchronized. You can see in the following table that the OSCERCLK is enabled in VLPS, so that is why with this clock source it works correctly.

pastedImage_1.png

In the Figure 27-1. TPM block diagram, you can see the synchronizer of the external clock.

pastedImage_2.png

About the interrupt, can you verify that the TPMx_SC[TOIE] bit is set to 0? You could also try, disabling the interrupt from the NVIC module with the INT_SYS_DisableIRQ(g_tpmIrqId[instance]) function.

Let me know any question you may have.

Regards,

Gerardo

View solution in original post

0 Kudos
93 Views
giancarlozanuz
Contributor III

Hello Geraldo,

Thanks for your answer, now its working perfectly. For the interruptions it was the PHYtimer enabled. But I think the consumption is a little high for VLPS, i'm getting around 140uA. In LLS I'm getting ~1uA. Maybe I'm missing something?

Here is my routine for deep-sleep.

    /* Disable interrupts */
    OSA_EXT_InterruptDisable();
    
    /* Disable systick */
    uint32_t temp = SysTick->CTRL & (SysTick_CTRL_ENABLE_Msk | SysTick_CTRL_TICKINT_Msk);
    SysTick->CTRL &= ~(SysTick_CTRL_ENABLE_Msk | SysTick_CTRL_TICKINT_Msk);
    
    /* Disable PHYtimer */
    PhyTimerStop();
    
    /* Put the radio in sleep */
    XCVRDrv_RadioSleepReq();

    /* Enter Sleep */
    CLOCK_SYS_UpdateConfiguration(CLOCK_XTAL_LOW_POWER, kClockManagerPolicyForcible);
    power_manager_error_code_t ret = POWER_SYS_SetMode(mode, kPowerManagerPolicyAgreement);
    CLOCK_SYS_UpdateConfiguration(CLOCK_XTAL, kClockManagerPolicyForcible);
    
    /* Wakeup the rádio */
    XCVRDrv_RadioWakeUpReq();
    
    /* Enable the PHYtimer */
    PhyTimerStart();
    
    /* Return the systick state */
    SysTick->CTRL |= temp;
    
    /* Enable interrupts */
    OSA_EXT_InterruptEnable();

Thanks in advance!

0 Kudos
93 Views
gerardo_rodriguez
NXP Employee
NXP Employee

Hello Giancarlo,

This extra current that you are seeing may be from the TPM that is operating during VLPS. You can refer to the Table 6. Low power mode peripheral adders in the datasheet for some current values that the TPM can add during low power modes. It will depend on the clock selection and speed. 

As a test, you could disable the clock to the TPM module in the SIM_SCGC6 register before entering VLPS to see how much current it is adding.

0 Kudos
93 Views
giancarlozanuz
Contributor III

Hello Gerardo,

I've found the problem, it was the ADC16 that was enabled. After de-initialization of the driver the consumption went to around ~2uA in VLPS, which is OK.

Thanks for your help!

0 Kudos