I want to have signal on PB7 when PB11 is pressed, I think can be done by attachInterrupt / detachInterrupt in timer or pin PA7.
This is what I was trying, not working.
Code: Select all
HardwareTimer pwmtimer3(3);
void setup() {
pinMode(PA7, PWM);// CH2
pinMode(PB11, INPUT_PULLDOWN);
pwmtimer3.pause();
pwmtimer3.setPrescaleFactor(180);
pwmtimer3.setOverflow(100 - 1);
pwmtimer3.setCompare(TIMER_CH2, 50);
//pwmtimer3.attachCompare1Interrupt(timer3);
pwmtimer3.refresh();
pwmtimer3.resume();
}
void loop() {
if (digitalRead(PB11) == HIGH)
{
attachInterrupt(digitalPinToInterrupt(PA7));
}
else {
detachInterrupt(digitalPinToInterrupt(PA7)) ;
}
}