Hi,
Here is an update on the strange PWM behaviour on channel 1 (the one connected to LED1).
I wrote a simple test program that just accesses the hardware directly:
// Testing PWM channel 0 vs channel 1 behaviour, sford
#include "mbed.h"
PwmOut pwm1(p26);
PwmOut pwm2(p25);
int main() {
uint32_t t = 10000;
// set period
LPC_PWM1->MR0 = t;
LPC_PWM1->LER |= 1 << 0;
while (1) {
// set pulsewidth to 100%
LPC_PWM1->MR1 = t;
LPC_PWM1->MR2 = t;
LPC_PWM1->LER |= 0x6;
// wait for update
while (LPC_PWM1->LER);
// set pulsewidth less than 100%
LPC_PWM1->MR1 = t - 500;
LPC_PWM1->MR2 = t - 500;
LPC_PWM1->LER |= 0x6;
// wait for update
while (LPC_PWM1->LER);
}
}
As you can see, this just switches between 100% and less than 100% pulsewidth on two channels (1 and 2). Identical code for each channel. But here is the result:
Top is channel 1 (displaying the problem we see), bottom is channel 2 (what I'd expect). I'm suspicious that the problem is only on channel 1, which is "more connected" with channel 0, which is used for the period counter. Anyone see something I've overlooked here, or have an explaination?
Thanks,
Simon
I have LPC1768 only two days and I tested only LEDs because i don't hawe wires yet.
I have this problem: LED1 blink, but not by program.
My program is here:
Program is functional, but LED1 sometimes blink. I don't know why.
Please help me.