Kinetis PWM Frequency Changes on Zero Crossing

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

Kinetis PWM Frequency Changes on Zero Crossing

595 Views
gsinde
Contributor III

I am currently using a PWM output on my MK22FN512 to tone a speaker based upon a measured signal from an antenna. I update the speaker about every 500 msec to 1000 msec and only use 100 Hz to 3000 Hz mapped to signal power (using a log function but that doesn't matter). 

On frequency changes, I get a little click and I am sure it is my software "FORCE" update of the PWM registers. I am not a motor control guy but there must be a way to change the frequency just as the sine wave crosses zero for no disruptions. It is not critical for me but would be a nice bug fix before I release the product.

I will dive in to the datasheet but I thought I would reach out to the community.

Current Code:

ftm_chnl_pwm_signal_param_t Speaker_Params;

void SpeakerFreq(unsigned int freq, unsigned int duty)
{
Speaker_Params.level = kFTM_LowTrue;
Speaker_Params.dutyCyclePercent = (duty & 0x3F);

FTM_SetupPwm(FTM0, &Speaker_Params, 1, kFTM_CenterAlignedPwm, freq, SOUND_CLOCK_SOURCE);

if (speaker_on == false)
   {

   // Only set level when turning on the speaker
   FTM_UpdateChnlEdgeLevelSelect(FTM0, Speaker_Params.chnlNumber, Speaker_Params.level);
   }

// Software trigger to update registers
FTM_SetSoftwareTrigger(FTM0, true);

speaker_on = true;
}

Thanks

0 Kudos
2 Replies

489 Views
gsinde
Contributor III

This is a good idea (if I need to rev my hardware) but unless my final testing shows an issue, the board is ready for production. I would have thought there must be a way in software to arm a PWM frequency change and have it load at an optimal time (which I guessed was zero crossing). I will keep looking at motor control examples just in case. Thx

0 Kudos

489 Views
FelipeGarcia
NXP Employee
NXP Employee

Hello Gary,

 

Have you tried to use a common cross zero point detect circuit. The final output is a trigger signal you can connect to your MCU.

pastedImage_2.png

Hope it helps!

Best regards,

Felipe

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

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos