analogWriteFrequency bug

Donziboy2

Well-known member
I seem to have found a small bug in analogWriteFrequency. While working on my eGocart project I managed to do this.
Code:
analogWriteFrequency(22, PWMfrequency);
analogWriteFrequency(23, PWMfrequency);

It looks harmless but boy did it kill my afternoon.
I was trying to set pin 25 High with a switch and a few other variables and it would sometimes go on and off quickly and other times do nothing. After banging my head on my Keyboard for a few hours trying to figure out why my If statement was broken I started disabling huge chunks of code. 900lines later...... I commented out the above code and pin 25 started working......:mad:

It seems that if you write to the same timer twice it borks something, even though pin25 is on a different timer and was not being used for PWM it was pulsing the pin one time instead of holding it High.

Well I have just enough time left in the day to get drunk and go to bed so later everyone.
 
Can you please post a complete program which demonstrates the problem?

There may indeed be a bug in analogWriteFrequency or analogWrite itself. If so, I would really like to investigate and fix it. But I need you to post an actual program that demonstrates the problem.
 
I will see what I can do, I need to take a break, just spend a few hours troubleshooting pin33......

I will try to make a small example that has what is needed to reproduce but right now I need Excedrin and Crown.

The good news is I have a working Precharge and Bypass for my eGocart, and the faults work to :) Was hoping to run the test motor today but probably be further into the week.
 
Cant seem to reproduce it with a basic test program.

I will play around with an older version of the code before I removed the second analogWriteFrequency.
 
I hope you'll manage to trim it down to something you can post here, which reproduces the problem.

If there really is a bug in either of those Teensyduino functions, I certainly want to fix it. But I can't even start without knowing how to reproduce the problem.
 
I have been unable to reproduce it :/

I even went back to an older version and tried playing with it and could not get it to reproduce.
Maybe I should have had the Crown before I started yesterday instead of after.....
 
Back
Top