Hi
When I turn on disabled lines in loop PWM is disappears, how to fix that ?
volatile int i = 0; //initializing a integer for incrementing and decrementing duty ratio.
void Tim2_ISR(void)
{
Timer2.setCompare(TIMER_CH4, i);
}
HardwareTimer pwmtimer2(2);
void setup() {
pinMode(PB3, INPUT_PULLDOWN);// sets the pin0 as output
pinMode(PB5, INPUT_PULLDOWN);// sets the pin1 as output
pinMode(PA3, PWM);
pwmtimer2.pause();
pwmtimer2.setPrescaleFactor(100); // Timer input clock Prescaler = 1 (= 72MHz input ?)
pwmtimer2.setOverflow(256); // PWM Period width for 7,2kHz ?
pwmtimer2.setCompare(TIMER_CH4, 128); // PWM High Pulse width is 50% duty (1:1)
pwmtimer2.refresh();
//Timer2.attachInterrupt(0, Tim2_ISR);
pwmtimer2.resume();
}
void loop()
{
/*
/////////////////////////////////////////
analogWrite(PA3, i); // analogWrite values from 0 to 255
if (digitalRead(PB3) == HIGH)
{
if (i < 255)
{
i++;//if pin PB3 is pressed and the duty ratio value is less than 255
delay(30);
}
}
if (digitalRead(PB5) == HIGH)
{
if (i > 0)
{
i--;// if pin PB5 is pressed and the duty ratio value is greater than 0
delay(30);
}
}
///////////////////////////////////
*/
}
The problem is - why pulses on PA3 are disappeared when disabled lines are activated, there is nothing going on inside the loop until button is pressed = empty loop.