11 years, 10 months ago.

I want a phase shift between two PWM signals.

I want to generate two PWM signals, which are phase shifted by 90. For phase shifting I had used "wait" command, but it is not working.Program that i had written is shown below:

  1. include "mbed.h"

PwmOut a(p21); PwmOut b(p22);

int main() { a.period_us(10); b.period_us(10); while (1){ a.pulsewidth_us(2);

wait_us(2); b.pulsewidth_us(2);

} }

Question relating to:

2 Answers

11 years, 9 months ago.

PWM on the LPC1768 is always in phase since there is only a single PWM timer. I think with dual slope option you can get it out phase, but the mbed library does not support that by default.

Accepted Answer
11 years, 9 months ago.

The period of the wave form is 10 uSec. Thus, for 90 degree phase difference, the wave forms should be seperated in time by 2.5 uSec and not 2 as in your code.