dual use of ble's TPM. How to do a correct config?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

dual use of ble's TPM. How to do a correct config?

639 Views
mangramarco
Contributor III
Hello, i've a code with a configuration of all 3 tpms in kw41z mcu.
The TPM1 is used for an encoder knob.
In this code, i've a status machine and i need to create a new status for ble using, but since i've all tpms busy, i need to remove at least one configuration of tpm.
In my system,  there is not need any encoder when it stay in "ble status" so i want to remove its configuration of TPM1 for use it for BLE stack.
i tried to configure a ble stack and it works fine if i don't use any configuration of TPM1 for encoder.
However , i created a new status of machine so if the code switch to this, TPM1 stops and deinit, and successively the BLE stack can be launch.
unfortunately, it do not work.
Can you help me?
this is the tpm configuration for encoder

 tpm_config_t tpmInfo;
 CLOCK_SetTpmClock(1U);
 TPM_GetDefaultConfig(&tpmInfo);
 tpmInfo.prescale = kTPM_Prescale_Divide_128;
 /* Initialize TPM module */
 TPM_Init(TPM1, &tpmInfo);
    //SR: set up quadrature decoder for encoder
    const tpm_phase_params_t phaseParams = {
      .phaseFilterVal = 15,
   .phasePolarity = kTPM_QuadPhaseNormal,
    };
    TPM_SetupInputCapture(TPM1, kTPM_Chnl_0, kTPM_RiseAndFallEdge);
    TPM_SetupInputCapture(TPM1, kTPM_Chnl_1, kTPM_RiseAndFallEdge);
    TPM_SetupQuadDecode(TPM1, &phaseParams, &phaseParams, ENCODER_TPM_QUADMODE);
 PORT_SetPinMux(ENC_1_PORT, ENC_1_PIN, ENC_1_A);
 PORT_SetPinMux(ENC_2_PORT, ENC_2_PIN, ENC_2_A);
TPM1->MOD = 0xFFFF;
 TPM_StartTimer(TPM1, kTPM_SystemClock);

I make de deinit for this row:

 TPM_StopTimer(TPM1);
 TPM_Deinit(TPM1);

for ble i set only the clock:

CLOCK_SetTpmClock(2);

thank you 


Marco

Labels (1)
0 Kudos
3 Replies

521 Views
mangramarco
Contributor III

Hello, i SOLVED!
after the  TPM_StopTimer(TPM1); i need to clear the TPM1->QDCTRL register. Successively i need to use TPM_Deinit(TPM1);

thakns anyway

Marco

0 Kudos

521 Views
mangramarco
Contributor III

i've forget to say that when i do the riconfiguration of TPM for BLE, i use teh  TPM_GetDefaultConfig(); and TPM_Init() for reconfigure the TPM with default settings.
Now i'm trying to remove a single instructions and i discovered that TPM_SetupQuadDecode() create annoy.

0 Kudos

521 Views
mario_castaneda
NXP TechSupport
NXP TechSupport

Hi Marco,

The KW41 provides 2 Channels of TPMs.

In this code, i've a status machine and i need to create a new status for ble using,

Where did you create this new status?

Is the Bluetooth LE  stack working in your application?

I am confused when you mention remoe the TPM1 configuration and you do not need an encoder.

Regards,

Mario

0 Kudos