Kinetis E Signal Multiplexing

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

Kinetis E Signal Multiplexing

Jump to solution
1,391 Views
danielemereu
Contributor I

Hi all

I'm developing a firmware with the evaluation board FRDM-KE04Z using IAR embedded workbench and "KEXX_DRIVERS_V1.2.1" library.

I would like to set:

  • PTB4 as KBI1_P6 falling edge interrupt
  • PTC4 as FTM2_CH2 PWM signal with frequency of 1KHz and 50% duty cycle

This is my source code:

//     PTC4

SIM_RemapFTM2CH2Pin();

FTM_PWMInit(FTM2, FTM_PWMMODE_EDGEALLIGNED, FTM_PWM_HIGHTRUEPULSE);

FTM_SetFTMEnhanced(FTM2);

FTM_SetModValue(FTM2, 39999);

FTM_ClockSet(FTM2, FTM_CLOCK_SYSTEMCLOCK, FTM_CLOCK_PS_DIV1); 

NVIC_EnableIRQ(FTM2_IRQn);

FTM_SetCallback(FTM2, FTM2_Task);

FTM_SetChannelValue(FTM2, FTM_CHANNEL_CHANNEL2, 20000);

//     PTB4

KBI_ConfigType  sKBIConfig;

for (int i = 0; i < KBI_MAX_PINS_PER_PORT; i++)

{

   sKBIConfig.sPin[i].bEn = 0;

}

sKBIConfig.sBits.bMode   = KBI_MODE_EDGE_ONLY;

sKBIConfig.sPin[6].bEdge = KBI_FALLING_EDGE_LOW_LEVEL;

sKBIConfig.sBits.bIntEn  = 1;

sKBIConfig.sPin[6].bEn   = 1;

KBI_Init(KBI1, &sKBIConfig);

KBI_SetCallback(KBI1, &KBI1_Task);

The problem is that PWM signal is perfect but PTB4 interrupt not works.

PTB4 interrupt only works if I don't setup PTC4 PWM, as if there was a problem with the signal multiplexing of the PTB4 pin because I see also on PTB4 the PWM signal!

How can I setup these pins to works together but with different roles?

Anyone can help me?

Daniele

Labels (1)
0 Kudos
1 Solution
681 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Danniele Mereu,

      Did you do some modifications in your FTM_PWMInit(FTM2, FTM_PWMMODE_EDGEALLIGNED, FTM_PWM_HIGHTRUEPULSE);?

      If you are not modify it, your test result is correct. Because in the FTM_PWMInit(FTM2, FTM_PWMMODE_EDGEALLIGNED, FTM_PWM_HIGHTRUEPULSE); This function enable all the FTM2 channel, and PTB4 is also the FTM2 channel4,  from the RM document:

pastedImage_0.png

FTM2_CH3 is defaultly mapped on PTB4, then your KBI function won't working, because KBI function priority is lower than FTM.

If you want the KBI working, you should disable the FTM2_CH2.

Wish it helps you!

If you still have question, please contact me!


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
3 Replies
682 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Danniele Mereu,

      Did you do some modifications in your FTM_PWMInit(FTM2, FTM_PWMMODE_EDGEALLIGNED, FTM_PWM_HIGHTRUEPULSE);?

      If you are not modify it, your test result is correct. Because in the FTM_PWMInit(FTM2, FTM_PWMMODE_EDGEALLIGNED, FTM_PWM_HIGHTRUEPULSE); This function enable all the FTM2 channel, and PTB4 is also the FTM2 channel4,  from the RM document:

pastedImage_0.png

FTM2_CH3 is defaultly mapped on PTB4, then your KBI function won't working, because KBI function priority is lower than FTM.

If you want the KBI working, you should disable the FTM2_CH2.

Wish it helps you!

If you still have question, please contact me!


Have a great day,
Jingjing

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

0 Kudos
681 Views
danielemereu
Contributor I

Hi Jingjing

perfect, thank you for your answer.

Inside the routine FTM_PWMInit I've done this change:

if(FTM_PWM_HIGHTRUEPULSE == u8PWMEdgeSelect)

    {

        /* Configure timers PWM High True Pulses */

        for(i=0; i<channels; i++)

        {

            if( i != 4)     //     with this instruction I've excluded the channel 4 from FTM init as PWM

            {

                pFTM->CONTROLS[i].CnSC = FTM_CnSC_MSB_MASK | FTM_CnSC_ELSB_MASK; 

                pFTM->CONTROLS[i].CnV  = FTM_C0V_INIT + i*100;

            }

        }

    }

Now on PTB4 I don't see the PWM signal, finally!

0 Kudos
681 Views
mjbcswitzerland
Specialist V

Hi Daniele

The port multiplexing in the KE works based on peripherals that are enabled and their priorities.

The keyboard inputs have lowest priority and so when on PTB4 both KBI1_P6 and FTM2_CH4 are enabled, FTM2_CH4 will have priority and drive the output.

This suggests that your PWM routine is enabling the PWM output on both PTC4 (FTM2_CH2) and FTM2_CH4. You can check whether this is the case by looking at the FTM_CSC_ELSA  and  FTM_CSC_ELSB bits in FTM2_C4SC.

Regards

Mark

Kinetis: µTasker Kinetis support

KE: µTasker FRDM-KE02Z support / µTasker FRDM-KE02Z40M support / µTasker FRDM-KE06Z support

PWM: http://www.utasker.com/docs/uTasker/uTaskerHWTimers.PDF

KBI: Re: Re: GPIO pin as interrupt source KEA-64

For the complete "out-of-the-box" Kinetis experience and faster time to market

0 Kudos