AnsweredAssumed Answered

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

Question asked by marco mangraviti on Sep 23, 2019
Latest reply on Sep 25, 2019 by Mario Ignacio Castaneda Lopez
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

Outcomes