Closed AdityaNG closed 8 months ago
When analogWrite() is called from different libraries, the mapping between channels and pins would not be correct. Take the example
analogWrite()
Lets say that in the main file, we set pin 13 to 100% duty cycle.
// main.ino void loop() { ... analogWrite(13, 255); }
In the above, pin 13 would get mapped to channel 0, but lets say we import another library that happens to use analogWrite()
// other_library.cpp void init() { ... analogWrite(14, 125); }
Since analog_write_channel_t _analog_write_channels[16] is not declared as a globally accessible extern variable, pin 14 will also get mapped to channel 0.
analog_write_channel_t _analog_write_channels[16]
extern
This is fixed by making _analog_write_channels an extern variable.
_analog_write_channels
When
analogWrite()
is called from different libraries, the mapping between channels and pins would not be correct. Take the exampleLets say that in the main file, we set pin 13 to 100% duty cycle.
In the above, pin 13 would get mapped to channel 0, but lets say we import another library that happens to use
analogWrite()
Since
analog_write_channel_t _analog_write_channels[16]
is not declared as a globally accessibleextern
variable, pin 14 will also get mapped to channel 0.This is fixed by making
_analog_write_channels
anextern
variable.