I have a simple program turning bit 7 of PORTD off and on. However, when I look at the output on an oscilloscope, a 5uS pause is obvious and messing up how the signal should look. I noticed when I disable interrupts, this 5uS pause goes away....however I need to use interrupts for my project.
Anyone have any idea what causes this and how I can mitigate it?
You're bound to get glitches (they're not random, BTW) when the timer overflow interrupt occurs.
Why not use the timers to generate your waveform, and reserve the processor for slower stuff?
AWOL:
You're bound to get glitches (they're not random, BTW) when the timer overflow interrupt occurs.
Why not use the timers to generate your waveform, and reserve the processor for slower stuff?
I would love to do as you've described, however you're implying using interrupts and this 5uS 'pause' exists anytime interrupts are enabled and it messes up my signal.
Can you explain or point me in the direction of what is causing this...I've run out of ideas for tracking it down? You mentioned a timer overflow, I wasn't using a timer in my code, perhaps you're talking about one Arduino uses...do you know where that is in the Arduino C files so I could modify it to get rid of this?
Not sure that that is what anyone was suggesting - for a time critical application most of us would just set up the hardware timers to do their thing in the background. They are entirely hardware based and not effected by whatever the software is doing elsewhere on the micro controller - until you want to effect them that is.
Look up the hardware timers in the datasheet, its not the easiest reading, but there are various waveform generation modes built in to do exactly what you want without software or interrupts getting in the way.
DuaneB:
Not sure that that is what anyone was suggesting - for a time critical application most of us would just set up the hardware timers to do their thing in the background. They are entirely hardware based and not effected by whatever the software is doing elsewhere on the micro controller - until you want to effect them that is.
Look up the hardware timers in the datasheet, its not the easiest reading, but there are various waveform generation modes built in to do exactly what you want without software or interrupts getting in the way.
I didn't look into it completely but the Timer0 that arduino uses to generate the millis() was the problem and since my app is time sensitive I couldn't have it pausing my real program or interrupts (timer0 is a higher priority I guess?) every 1.024mS with a 5uS freeze.
Either way about it, disabling that Timer0's interrupt means the only interrupts that run are my own which is exactly what I happened to need.