LPC4088 PWM Frequency

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

LPC4088 PWM Frequency

832 Views
f_fiorini
Contributor III

Hello all,
I'm currently working on a project that requires PWM to work at very high frequencies in order to switch the signal given to a relay, allowing to save some power (the hardware implementation is left intentionally vague, as it's not relevant to the question).

I've been tasked to find a way to increase the current PWM frequency, which we measured to be at 100Hz (at least that's the value provided by the oscilloscope when probing), to be in the order of kHz at the very least. 

For what's my understanding, the PWM's "frequency" is defined by the number placed in register LPC_PWM1->MR0 (is this clock ticks? Or something else?), with the prescaler used to further reduce the frequency of the updates to the TC register. 
Am I correct, or is there something I'm missing out? 

During testing, it turned out that there's no way to increase the frequency to more than 100Hz. 

This is the portion of code we use as PWM driver, which is entirely based on the LPCOpen functionalities: 

void set_dutycycle(LPC_PWM_T * reg, uint32_t value, uint8_t channel)

{

   Chip_PWM_SetMatch(reg, channel, value);

   Chip_PWM_LatchEnable(reg, channel, PWM_OUT_ENABLED);

}

void init_PWM_Pin(PCON pcon, LPC_PWM_T * reg, uint8_t channel, uint16_t frequency)

{

   LPC_SYSCTL->PCONP |= pcon;

   Chip_PWM_Init(reg);

   Chip_PWM_SetCountClockSrc(reg, PWM_CAPSRC_RISING_PCLK, 0);

   Chip_PWM_PrescaleSet(reg, ((Chip_Clock_GetPeripheralClockRate() / 1000) / frequency));

   Chip_PWM_ResetOnMatchEnable(reg, 0);

   Chip_PWM_SetMatch(reg, 0, 100);

   Chip_PWM_SetMatch(reg, channel, 0);

   Chip_PWM_LatchEnable(reg, 0, PWM_OUT_ENABLED);

   Chip_PWM_LatchEnable(reg, channel, PWM_OUT_ENABLED);

   Chip_PWM_SetControlMode(reg, channel, PWM_SINGLE_EDGE_CONTROL_MODE, PWM_OUT_ENABLED);

   Chip_PWM_Enable(reg);

}

As far as I've tried (based on what I know about the PWM driver of the LPC4088 OEM board), I've changed the Chip_PWM_SetMatch for MR0 as well as changing the prescale value, but both seem not to be giving the desired result. 

My question is: is there a way to increase such PWM frequency (10-100kHz would be optimal) and, if so, how?

Thanks in advance for the answers.

P.S: source code is not entirely available at the moment, but I can provide it to you if really needed. 

P.P.S: I've tried to look for examples on the Internet, but it seems PWM has been removed / never been included in the LPCOpen / EA Dev Kit examples. Any suggestions? 

Labels (4)
0 Kudos
1 Reply

647 Views
soledad
NXP Employee
NXP Employee

Hi, 

I've attached some PWM demos which are based on the LPC1788, however, NXP’s LPC407x_8x microcontroller family is a high performance Cortex-M4 series based on the successful LPC177x_8x Cortex-M3 family. Both families are targeted to operate atup to 120 MHz CPU frequency under worst case commercial conditions. LPC407x_8x is pin compatible with LPC177x_8x with enhancements in the core and advanced peripherals. Even the LPC407x_8x is a pin-compatible Cortex-M4 option for LPC177x_8x. Migration of a project from LPC177x_8x to LPC407x_8x is relatively simple by referring to the AN11335 which is also attached.

Have a great day,
Sol

 

-------------------------------------------------------------------------------
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