Timeline for Fast PWM working with int main(void) but not with void setup()
Current License: CC BY-SA 4.0
6 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| May 3, 2018 at 18:53 | comment | added | Mr. C |
After changing DDRB to _BV(PB1) | _BV(PB2) to the corresponding pins in MEga DDRB to _BV(PB5) | _BV(PB6) it works perfectly, i didnt notice that. Thank you so much @Edgar Bonet, after your explanation about the core's init function it is more clear for me now why it was not working with void setup().
|
|
| May 3, 2018 at 18:49 | vote | accept | Mr. C | ||
| May 3, 2018 at 18:44 | comment | added | Edgar Bonet |
@Mr.C: I tested it (and it works) on an Uno. I had to change DDRB to _BV(PB1) | _BV(PB2) in order to fit the Uno's pinout. Note that on the previous version of my answer I mistakenly left the DDRB setting appropriate for the Uno.
|
|
| May 3, 2018 at 18:41 | history | edited | Edgar Bonet | CC BY-SA 4.0 |
+ background info, fixed port pins
|
| May 3, 2018 at 18:31 | comment | added | Mr. C | Thank you for pointing out that the order in which the timer is set up could affect in some way, i had no idea. With your code it still does not work for me, did you have a chance to test it? | |
| May 3, 2018 at 17:16 | history | answered | Edgar Bonet | CC BY-SA 4.0 |