K66 TPM external trigger

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

K66 TPM external trigger

Jump to solution
1,579 Views
RadaD
Contributor III

Hi all!

I'd like to use an external trigger event to trigger TPM0/1 modules on a K66 (MK66FN2M0VMD18 on FRDM-K66F board).

In the reference manual, Section 43.1.3, in Table 43-2 'External Trigger' is mentioned as an option.
However, I am struggling to find a description of the available external trigger options and how to configure and use them.

Thanks in advance for your help!

0 Kudos
1 Solution
1,519 Views
EdwinHz
NXP TechSupport
NXP TechSupport

This is precisely what I mean when I mentioned that the RM is not very descriptive about these pins. In the RM, the pins are described as external triggers for the PDB module only, instead of specifying that they are external triggers for both PDB and TPM. This is why they are labeled as PDB0_EXTRG under Section 11.3.1.

EdwinHz_0-1636050433235.png

 

However, as we saw from the Pin ConfigTools, C8 and B12 provide an external trigger for the TPM modules as well. When I set up C8 as trigger for the TPM module, the Pin tool updates the code describing it as the PDB0_EXTRG, even though I set it up for the TPM module:

    /* PORTC6 (pin C8) is configured as PDB0_EXTRG */
    PORT_SetPinMux(BOARD_INITPINS_I2S_MCLK_PORT, BOARD_INITPINS_I2S_MCLK_PIN, kPORT_MuxAlt3);

In fact, I’m able to set C8 as external trigger for both modules and they will share the same pin without conflict.

EdwinHz_1-1636050433258.png

 

I hope this helps to clear the confusion,

Edwin.

View solution in original post

0 Kudos
6 Replies
1,570 Views
RadaD
Contributor III

Hi @EdwinHz!
Thanks for answering!

Option '0000' for TPMx_CONF[TRGSEL] is described as 'External Trigger'. What exactly is 'External Trigger' and how can I use it?
I specifically want to start TPM1 and 2 when a signal event on an external pin happens, i.e., I want to avoid starting TPM1 and 2 in the ISR of an port pin interrupt via a software method and rather start it "from hardware".
(How) can I achieve that?

Thanks!

0 Kudos
1,551 Views
EdwinHz
NXP TechSupport
NXP TechSupport

Admittedly, the RM isn’t very descriptive about the usage of the this “external trigger”. This option should enable using an external pin as trigger for the TPM modules like you need.

With ConfigTools in MCUXpresso, we see that the TPM modules have two TRG signals routed to two pins that are described external trigger inputs for the TPMs. The usage of these pins is what the “external trigger” (0000) option is referring to.

EdwinHz_0-1635969522316.png

I will consult with my colleagues as to why the RM isn’t more descriptive about these two pins. Sorry for the inconvenience this might have caused.

 

Best regards,

Edwin.

 

0 Kudos
1,541 Views
RadaD
Contributor III

Thanks for the reply, @EdwinHz!

Unfortunately, the only thab I have in the 'Pins' ConfigTool is the 'Routing Details'.
Can you give me information on which pins are available as external triggers and how to configure them or a document that describes this?

Thanks!

EDIT: From your picture I suspect the TRG pins for TPM1 are B12 and C8, but Section 11.3.1 'K66 Signal Multiplexing and Pin Assignments' doesn't state the external trigger function as ALT functionality for those pins, as for no other pin.

0 Kudos
1,520 Views
EdwinHz
NXP TechSupport
NXP TechSupport

This is precisely what I mean when I mentioned that the RM is not very descriptive about these pins. In the RM, the pins are described as external triggers for the PDB module only, instead of specifying that they are external triggers for both PDB and TPM. This is why they are labeled as PDB0_EXTRG under Section 11.3.1.

EdwinHz_0-1636050433235.png

 

However, as we saw from the Pin ConfigTools, C8 and B12 provide an external trigger for the TPM modules as well. When I set up C8 as trigger for the TPM module, the Pin tool updates the code describing it as the PDB0_EXTRG, even though I set it up for the TPM module:

    /* PORTC6 (pin C8) is configured as PDB0_EXTRG */
    PORT_SetPinMux(BOARD_INITPINS_I2S_MCLK_PORT, BOARD_INITPINS_I2S_MCLK_PIN, kPORT_MuxAlt3);

In fact, I’m able to set C8 as external trigger for both modules and they will share the same pin without conflict.

EdwinHz_1-1636050433258.png

 

I hope this helps to clear the confusion,

Edwin.

0 Kudos
1,493 Views
RadaD
Contributor III

Thanks @EdwinHz!

Configuring the timers to external trigger ( TRGSEL = 0000, TRGsrc=0 ) and configuring the port pin as ALT3 did the trick:

PORT_SetPinMux(PORTC, 0U, kPORT_MuxAlt3);

TPM1->CONF &= 0x0FC00000; // Set bits 27-22 zero, i.e., TRGSEL = 0000, TRGsrc=0, TRGPOL = 0
TPM1->CONF |= 0x00010000; // Set bit 16 to one, i.e., CSOT = 1
0 Kudos
1,573 Views
EdwinHz
NXP TechSupport
NXP TechSupport

Table 43-2 describes all of the available triggers that are external to the TPM module itself. The three internal triggers are specified under the TRGSEL field description.

To use an external trigger, you would set the TRGSRC field to 0 and set the TRGSEL field with one of the options specified in Table 43-2.

 

I hope this helps,

Edwin.

0 Kudos