I'm using an Arduino Micro (Leonardo was added in the title just to help for searching, as 'Micro' is a little generic) as a simple AtoD converter to drive the dimming pin on some LED drivers that only accept pwm. The code portion is working fine, so I don't see a need to post it up. What I am having issues with is the pwm output of the ATmega32U4 itself. I'm using the analogWrite() function like you normally would, and the output is far from consistent.
At 0% duty cycle, the LEDs flicker constantly, even with a 10K pull down resistor on the line. You can see some artifacts on the scope plot below. It's a little tricky capturing everything, as the events happen quite fast, and the trigger can't capture them as I would like. You can see that random pulses pop up in the waveform (about 50us in duration). The pwm signal is measured right from the board, with no additional circuitry connected after that point, so there are no external influences, save for the pull down resistor (removing it makes no difference to the output).
Even at higher duty cycles, these random pulses still show up. They aren't as obvious, but you can see flickering in the LED output. Now, the same kind of issue shows up at 100% duty cycle, but they appear as gaps in the output, again, creating flicker. You can just see the ghost of two of the pulses in the image below.
To see if this was an issue with the software, I connected an Uno in place of the Micro to see what would happen. With the Uno (exact same code), the output is rock solid, and running through the range of duty cycles produced smooth output. I did notice that at 0% and 100% duty cycle, the output was pulled low or high respectively, with no pulsing like I saw on the Micro. Obviously, I could change the code for the Micro to act more like a digital output once the duty cycle hit 0% or 100%, but that still doesn't get rid of the random pulsing.
This is the first time using a board with the ATmega32U4. All of my other projects have used the ATmega328, so I'm wondering if this is a specific issue to the ATmega32U4, or if there is a specific fault with this particular board. The IDE I'm using is v1.0.4
Thanks in advance for the help. Hopefully someone can help me out here.