Skip to content

wiring_digital.c, function turnOffPWM(uint8_t timer) does not switch off properly  #2163

@gonzoveliki

Description

@gonzoveliki

Attention: This BUG concerns only AVR based platforms, standard variant, and not the new ARM based ones like DUE and Teensy. It is also doesn't affect Teensy 2.0 which is featuring AVR32U4 and is using different code for digital_wiring...

As I menioned and described here:
http://forum.arduino.cc/index.php?topic=252700.msg1789311
There is core bug in wiring_digital.c that has been there for a long time.
All AVR platforms using "standard" arduino core are affected,
It is obvious only with PWM mode on pin 5 on UNO,
and whichever pin is attached with TIMER0B on other boards.
Problem occurs only when a PWM is used once on that pin,
and after that can't be switched back to a solid bi-level digital.
digitalWrite, pinMode, analogWrite(5,0) or analogWrite(5,255)
are not helping either.

Solution is quite simple:
in file "wiring_digital.c"

search for
"#if defined(TIMER0B) && defined(COM0B1)"
and replace with
"#if defined(TCCR0A) && defined(COM0B1)"

That's all, regards, I am glad helping this solved.

Regards

Metadata

Metadata

Assignees

Labels

Architecture: AVRApplies only to the AVR microcontrollers (Uno, etc.)Component: CoreRelated to the code for the standard Arduino APIType: Bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions