Wrong routing for TPM input capture source

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

Wrong routing for TPM input capture source

Jump to solution
1,053 Views
kawk
Contributor I

Hi,

I'm converting a Processor Expert/KSDK 1.2.0-based project from KL27Z64 to KL17Z64.

A configuration for TPM1 channel 0 for input capture from pin PTA12/TPM1_CH0 (which is available and the same on both MCUs) does work on the KL27Z64 but is not set up correctly on KL17Z64. A line is generated in Generated_Code/pin_mux.c which is (IMHO) plain wrong and doesn't allow proper operation unless overridden in user code.

The SIM_HAL_SetTpmChSrcMode(SIM,TPM1_IDX,0,) should IMHO select KSimTpmChSrc0 on both MCUs. The KSimTpmChSrc2, selected on KL17Z64, seems to refer to a source mode which is "reserved" according to the reference manual.

To ensure that no other components affect this outcome, I tried with fresh, new KL17 vs KL27 projects, just added the fsl_tpm component for TPM1 and configured that pin and the result is the same. If I add SIM_HAL_SetTpmChSrcMode(SIM,TPM1_IDX,0,kSimTpmChSrc0) in user code or just zero SIM_SOPT4 register after normal HW initialization, all starts functioning as desired.

KL27Z64 init_tpm_pins():

void init_tpm_pins(uint32_t instance)

{

  switch(instance) {   

    case TPM1_IDX:                      /* TPM1_IDX */

      /* Affects PORTA_PCR12 register */

      PORT_HAL_SetMuxMode(PORTA,12UL,kPortMuxAlt3);

      SIM_HAL_SetTpmChSrcMode(SIM,TPM1_IDX,0,kSimTpmChSrc0);

KL17Z64 init_tpm_pins():

void init_tpm_pins(uint32_t instance)

{

  switch(instance) {   

    case TPM1_IDX:                      /* TPM1_IDX */

      /* Affects PORTA_PCR12 register */

      PORT_HAL_SetMuxMode(PORTA,12UL,kPortMuxAlt3);

      SIM_HAL_SetTpmChSrcMode(SIM,TPM1_IDX,0,kSimTpmChSrc2);

Thanks for any hints how to prevent this in the configuration..

Kolja

0 Kudos
Reply
1 Solution
885 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Kolja,

      Yes, I check it, I think it is the bug of KDS with PE, actually SIM_SOPT4[TPM1CH0SRC] should choose TPM1_CH0 signal, not reserved.

      I will report this problem to the according department.

    Now, when you use the KL17, after you finished the configuration of fsl_tpm module, you can modify the init_tpm_pins code,:

    change SIM_HAL_SetTpmChSrcMode(SIM,TPM1_IDX,0,kSimTpmChSrc2);

  to

  SIM_HAL_SetTpmChSrcMode(SIM,TPM1_IDX,0,kSimTpmChSrc0);

    Then lock the TPM module like this:

36.jpg

   Then your modified code will not be updated.

   Wish it helps you!

Have a great day,
Jingjing

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

0 Kudos
Reply
3 Replies
886 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Kolja,

      Yes, I check it, I think it is the bug of KDS with PE, actually SIM_SOPT4[TPM1CH0SRC] should choose TPM1_CH0 signal, not reserved.

      I will report this problem to the according department.

    Now, when you use the KL17, after you finished the configuration of fsl_tpm module, you can modify the init_tpm_pins code,:

    change SIM_HAL_SetTpmChSrcMode(SIM,TPM1_IDX,0,kSimTpmChSrc2);

  to

  SIM_HAL_SetTpmChSrcMode(SIM,TPM1_IDX,0,kSimTpmChSrc0);

    Then lock the TPM module like this:

36.jpg

   Then your modified code will not be updated.

   Wish it helps you!

Have a great day,
Jingjing

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply
885 Views
kawk
Contributor I

Thanks for the confirmation.

At the moment, we put an extra SIM_HAL_SetTpmChSrcMode(SIM,TPM1_IDX,0,kSimTpmChSrc0) in user code right after the HW initialization. We don't like to have to put any "Generated_Code" under version control. I'll rather wait for updated generator.

0 Kudos
Reply
885 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Of course, if you don't want to modify it, you just can solve it by calling SIM_HAL_SetTpmChSrcMode(SIM,TPM1_IDX,0,kSimTpmChSrc0) in your main function.

  It has the same results.


Have a great day,
Jingjing

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply