You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've added following PWM output with 50% duty cycle to the code and i got squarewave output for calibration and testing. PWM signal generating is offloaded to the hardware, so it should not interfere with logic analyzer functionality in any way:
pinMode(3, OUTPUT);
analogWrite(3, 127);
If we add some ifndefs, we can make sure, it will always run only on unused pins no mater what MCU we use.
Also it's possible to set various frequencies, so maybe we can have different freqs at different unused pins:
Ok, so that I understand this, you're saying enable PWM on unused pins all the time to allow a single source for testing?
On an Arduino Uno (ATMEGA328P & similar) you would be talking about digital pins 3/5/6 right?
The downside I see is that my understanding of the Arduino PWM is the frequency is the same but length of time the pin is HIGH (aka the pulse width) is what varies. So you could get a 490hz signal out of Pin 3 and a 980Hz signal out of pins 5 & 6. The width of the pulse is what is variable with analogWrite().
I do use the timer to drive a pin (commented out code) for testing, but it is sampled pin, no an unused pin. (so you don't need a jumper wire to debug something). I haven't looked at the timer stuff in a long time, but maybe we could enable some test signal on pin 3 in "normal" mode? Pin 5 & 6 are driven by the same timer used by the millis() and delay() functions so I would have to see if using them is better or worse.
If you want to create & test some sample code that would be useful.
The 100KHz timer I use for testing:
#if 1
/*
This sets up timer2 at 100KHz to toggle a pin. This is useful
for debugging as it gives an internally precise signal source.
This doesn't work on the Arduino Mega. Use on the Uno or older.
We're using the same clock source for the timer & our sampling.
*/
/* Set OC2A (digital pin 11) to output so we can toggle it. */
pinMode(11, OUTPUT);
/* reset timer to zero */
TCNT2 = 0;
TCCR2A = 0;
TCCR2B = 0;
OCR2A = 0;
I've added following PWM output with 50% duty cycle to the code and i got squarewave output for calibration and testing. PWM signal generating is offloaded to the hardware, so it should not interfere with logic analyzer functionality in any way:
If we add some ifndefs, we can make sure, it will always run only on unused pins no mater what MCU we use.
Also it's possible to set various frequencies, so maybe we can have different freqs at different unused pins:
The text was updated successfully, but these errors were encountered: