I am using an arduino Lilypad Simplesnap with atmega328p. I need a PWM on pin 5. I use the timer 0 to generate it and it works great. However, I am supposed to use pin 6 as a digital OUTPUT to enable and disable a device.
The problem is that Pins 5 and 6 are BOTH controlled by Timer 0. Therefore the PWM of pin 5 influences the behavior of pin 6.
How can I make pin 5 generate a PWM and pin 6 just be a digital OUTPUT?
I attached two picture of the behavior of pin 6 with and without PWM on pin 5.
However, I am supposed to use pin 6 as a digital OUTPUT to enable and disable a device.
Does the noise on pin six affect the enable/disable? What are you controlling with pin 6?
How can I make pin 5 generate a PWM and pin 6 just be a digital OUTPUT?
In regards to the processor, Pin 6 as an input/output is independent of pin 5. Pin six should just be a digital output. The interaction is some sort of noise and nothing fundamental to using one pin as pwm and the other as standard digital output.
Can you put a low pass filter on the pin 6 output and still control the enable/disable?
It is set as INPUT. It a good remark though because if it is set as OUTPUT the PWM is on both pins.
cattledog:
Does the noise on pin six affect the enable/disable? What are you controlling with pin 6?
In regards to the processor, Pin 6 as an input/output is independent of pin 5. Pin six should just be a digital output. The interaction is some sort of noise and nothing fundamental to using one pin as pwm and the other as standard digital output.
Can you put a low pass filter on the pin 6 output and still control the enable/disable?
Actually I can control pin 6 despite the noise. The thing is that I use 6 digital pins for 6 identical devices and only pin 6 displays this noise that is oddly similar to the PWM frequency. I tried swapping the devices and the noise remains.
It is set as INPUT. It a good remark though because if it is set as OUTPUT the PWM is on both pins.
Only if the timer set up has enabled the pwm hardware output on both pins. Perhaps the default ide behavior for the lilypad is different than other AT328 devices, but I doubt it.
Have you changed the timer setup to a different pwm frequency?