Power on/off reset needed


I need to do a power on/off reset after editing this code  to get the PWM signals on. What have I done wrong?

// PWM 0.0
// 2012-08-08 MiKi

// Keep alive function
function wakeUp()
{
     // Schedule the next state change
    imp.wakeup(2, wakeUp);
}
 
hardware.pin8.configure(PWM_OUT, 0.3, 0.5); // (PWM period, frequency , duty cycle)
hardware.pin9.configure(PWM_OUT, 0.3, 0.5); // (PWM period, frequency , duty cycle)
 
// Register with the server
imp.configure("PWM 0.0", [], []);

wakeUp();
 
// End of code.

Ok, there appears to be a problem with reconfiguring an already running PWM. I just confirmed this on my board here. When you reload, the PWM doesn’t reinitialize if it was already running.


You can workaround the problem by first configuring them to another function, eg:

hardware.pin8.configure(DIGITAL_IN); // Turn off any stale PWM
hardware.pin9.configure(DIGITAL_IN);

hardware.pin8.configure(PWM_OUT, 0.3, 0.5); // (PWM period, frequency , duty cycle)
hardware.pin9.configure(PWM_OUT, 0.3, 0.5); // (PWM period, frequency , duty cycle)
 
I’ve filed a bug report…

Thanks Hugo!