LPC546xx audio PWM

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

LPC546xx audio PWM

1,401 Views
cybaluke
Contributor III

Hi,

I'm starting a work on a LPC54608, I need to generate a PWM square wave (about @500kHz) with the duty cycle modulated by an audio signal (20Hz-20kHz) sampled @48kHz from I2S input.

The first step of my work should be to synth and generate a digital sine wave from 20Hz to 20kHz (internal generated @48kHz Fs) and to modulate with this signal the duty cycle of the 500kHz square wave carrier.

Am I right if I will try to use the SCT_Timer block to generate a 500kHz carrier and I will try to modulate the value of the duty cycle from my audio signal (for example  using SCTIMER_UpdatePwmDutycycle function)?

From my point of view the first problem is how to sync and transfer the audio samples (@Fs=48kHz)  in my audio buffer to the update function of the value of SCT_timer duty cycle ...

Any ideas or suggestions about this?

Is there any example to starting from?

thanks

Labels (2)
0 Kudos
Reply
4 Replies

1,364 Views
PabloAvalos
NXP TechSupport
NXP TechSupport

Hi @cybaluke 

 

I would like to apologize for the delay. We are overloaded on the request these days. I really appreciate your patience.

 

Regarding your questions, the first one, to understand better, what do you refer with "modulate the value of the duty cycle from my audio signal", because it comes to my mind that you are trying to generate a FM modulation, but I do not know if my understanding is right, by any chance do not you have a drawing or graphic where I can see what you are trying to do?

And regarding your other question, there is not an example where you can start, but one suggestion you can take in mind, is to use the peripheral tool on MCUXpresso Config Tool, where you can see an interface like this and you can configure your SCTimer as you wish and play with the different options.

PabloAvalos_0-1649295856954.png

PabloAvalos_1-1649295879492.png

 

Hope this information was helpful, please let me know if you have more questions.

 

Thanks a lot.
Best Regards.
Pablo Avalos.

0 Kudos
Reply

1,350 Views
cybaluke
Contributor III

Hi Pablo, thanks for your answer and your support.

Maybe I was not so clear in the first part of my question...

Just to clarify: what I'm trying to do with this works is to change the duty cycle of a sqare wave of frequency about 500kHz (the carrier) in a sinusoidal way, the sine signal that control the variation of the duty cycle (the mudulating) has a fixed amplitude and frequency that can be selected in the range 20Hz-20kHz. I think this is an example of PWM modulation.

The micro generates the sinusoidal signal Vsin(t)=Vmax*sin(2piNt/Fs) used to control the duty cycle, each sample (@48kHz Fsample rate) has the amplitude value in the range [-Vmax, +Vmax], for example when Vsin=0 the duty cycle will be 50%, when Vsin=+Vmax duty cycle will be 99% and when Vsin=-Vmax the duty cycle will be 1% (just to avoid the 0% and 100% d.c. problems)

At the moment I can use the AudioPll and the I2S peripheral's IRQ to generate the sine signal samples with a wavetable synthesys @48kHz; I generate the carrier @480kHz with the SCT_Timer with a 50% duty cycle; I can change the value of the carrier's duty cycle (SCTIMER_UpdatePwmDutycycle) at each generated sine sample and I can get the right syncronization using a PINT IRQ drived by a pin port externally connected to the 48kHz LRCK signal of the I2S Flexcomm port pinout.
This works well using modulating sine signals from 1Hz to 10kHz, for higher frequencies I have some problems: it seems that the micro loses some sync pint IRQ and duty cycle updates, maybe this solution is too slow.

What do you think about?
Do you have any idea about a faster way to sync the 48kHz generation of the sine samples with the SCT_Timer duty cycle updating wihout using the external driven PINT IRQ?
If there are any other ideas I will be grateful to hear them...

Thanks!

0 Kudos
Reply

1,299 Views
PabloAvalos
NXP TechSupport
NXP TechSupport

Hi @cybaluke 

 

Thank you so much for all your patience.

 

Regarding your question, I have a couple of suggestions that might be helpful, one of them is to use some analog comparators like it is suggested on this thread from our community: https://community.nxp.com/t5/LPC-Microcontrollers/Interested-in-capturing-sinusoidal-or-ramp-signals...

My other suggestion is to try to use DMA to get the trigger and update the duty cycle, because DMA does not use time for processing and can be faster.

 

Hope the information might be helpful for you, please let me know if you have more questions.

 

Thank you so much.
Best Regards.
Pablo Avalos.

0 Kudos
Reply

1,256 Views
cybaluke
Contributor III

thanks for the suggested link...

About your DMA idea to update the duty cycle.... I can't figure how to sync the update of the SCTimer duty cycle with the I2S LRCK event... can you give me more informations about this?

0 Kudos
Reply