10 years, 5 months ago.

How to synchronize two PWM pins in LPC 1768

I need to control an inverter where it has six IGBTs where they are working according to the pwm signals provided by the mbed. To avoid short circuiting the output given by the inverter, when the top IGBT of one of the legs of the inverter turns on, the bottom IGBT should be turned off. That means I need to synchronize two pwm pins where when one is turned on, the other should be turned off. How can I accomplish this? Thank you for being attending to my question.

3 Answers

10 years, 5 months ago.

By default on the LPC1768 the PWM pins run in single edge mode: they all turn on at the same time, and turn off at different times.

You got dual edge mode you can enable by manually writing registers (might also be a library on the site for it), which enables you to change when the rising edge happens and when the falling edge in the period. However that costs 2 match registers: you can then only have 3 outputs on the LPC1768.

10 years, 5 months ago.


Some time a go I wrote a program to drive MOSFETs exactly like this. Through registers you can write the PWM
and introduce pauses between the outputs, making sure no MOSFETs is on at the same time.

include the mbed library with this snippet

#include "mbed.h"

PwmOut myled(p23);
PwmOut myled2(p25);
//serial pc(usbtx, usbrx);

int main()
//lpc_pwm1->mr0 = 24000000;

// 24000 pr. ms in mr0
    LPC_PWM1->MR0 = 24*50;     // 50 usek routine / 20khz
    LPC_PWM1->MR1 = 1;          // set the pwm2 output high at this count
    LPC_PWM1->MR2 = 24*19;    // set the pwm2 output low at this count
    LPC_PWM1->MR3 = 24*21;    // set the pwm4 output high at this count
    LPC_PWM1->MR4 = 24*39;    // set the pwm4 output low at this count
    LPC_PWM1->PCR |= 0x14;
    LPC_PWM1->LER |= 0x1e;
        pc.printf("pwm registers: \r\n");
        pc.printf("pwm1->mr0 = %x\r\n", LPC_PWM1->MR0);
        pc.printf("pwm1->pcr = %x\r\n", LPC_PWM1->PCR);
        pc.printf("pwm1->ler = %x\r\n", LPC_PWM1->LER);
    while(1) {

It should work for your application too.


Thank you for your answer. My code runs the algorithm and output three duty values for the top three IGBTs of the inverter. Algorithm only gives out these three values and the bottom IGBTs should be on when the top IGBTs are off. That needs to be done through PWM pins and I can't make the algorithm to do that. For every 100 micro seconds, the duty value is changed by the code. So if I can turn on the bottom IGBT for a time of 100 microseconds less duty time for the top IGBT after the top IGBT is turned off, that would do just fine. So can you please give more information of writing PWM register to do this task. And also if you can provide basics of writing to PWM register, that would be much obliged.

posted by tharanga kumara 15 Jan 2014
7 years, 4 months ago.

how can i change the direction of single edge PWM and dual edge PWM? Single edge pwm should starts with negative edge? according to rule single edge pwm starts with high but for my application it must starts with negative. can anybody help me on this