Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

additional check for turnOffPWM #77

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions cores/arduino/wiring_digital.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ static void turnOffPWM(uint8_t pin)

/* TCA0 */
case TIMERA0:
// check, if TCA is set to Port B (default megaavr-PWM ports)
// see variants/nona4809/variant.c line 13
if (!(PORTMUX_TCAROUTEA == PORTMUX_TCA0_PORTB_gc))
break;
/* Bit position will give output channel */
bit_pos = digitalPinToBitPosition(pin);

Expand All @@ -113,7 +117,15 @@ static void turnOffPWM(uint8_t pin)

/* TCB - only one output */
case TIMERB0:
// check, if TCB0 is set to alternate mode PF4 (Pin D6) (default megaavr-PWM)
// see variants/nona4809/variant.c line 31
if ((pin == 6) && ((PORTMUX_TCBROUTEA & PORTMUX_TCB0_bm) != PORTMUX_TCB0_bm))
break;
case TIMERB1:
// check, if TCB1 is set to alternate mode PF5 (Pin D3) (default megaavr-PWM)
// see variants/nona4809/variant.c line 36
if ((pin == 3) && ((PORTMUX_TCBROUTEA & PORTMUX_TCB1_bm) != PORTMUX_TCB1_bm))
break;
case TIMERB2:
case TIMERB3:

Expand Down