AVR32DA28 analogWrite to PA0 doesn't work by default #350
-
I just wanted to check my understanding. I'm working through a new board design with an AVR32DA28 and wasn't getting any PWM on PA0. This code generates nothing:
If I replace the analogWrite with a digitalWrite to HIGH, I get a voltage on PA0. If I run this code, I get a PWM signal:
Is this expected? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Yes, I thought uit was clearly marked on the charts, but after my butchering of them it may not be as clear The PWM code for TCA's on a Dx or future Ex part detect the state of TCAROUTEA when called, to find out if they can PWM that pin,. Note that as described in docs it is highly recommended to not have any PWM running either on the timer, or on the pins that you are moving the timer to), In the first case, they'll stay active, (but if the pin is set input you won't know,- but a pinMode that sets it output would result in surprise PWM there. (only digitalWrite, not pinMode invokes turnOnffPWM, because that is a very expensive function call.
look at the frequency of the squarewave you get out of that. Compare it to a pin that has no PWM output at all. (I think PD7 has no PWM out?) - it should be markedly faster. Then make mypin volatile, so it can't assume the value even though it's never changed
Finally, try it with PORTMUX set to something else. Compare to PIN_PD7. This shows what happens when youstrip the pinwrites down to the bare bones.
digitalWriteFast will now be like 2-3 clock cycles (when passed a non-constant second argument, there will be a couple of extra clocks. In the first example, if you put analogWrite(PIN_PA5,127); delay(1000); after setting the PORTMUX,. the PWM would show for 1 second. In the secondexample, doing the same thing, the PWM would never stop, because fast digital IO doesn't turn off PWM. Otherwise we would have to call it digitalWriteSlow, and we already have digitalWrite(). |
Beta Was this translation helpful? Give feedback.
Yes, I thought uit was clearly marked on the charts, but after my butchering of them it may not be as clear
The PWM code for TCA's on a Dx or future Ex part detect the state of TCAROUTEA when called, to find out if they can PWM that pin,.
During initialization, we set the initial mux to somewhere else in most cases - PORTA is the last place you want your PWM pins to be on a DA/DB! What with 2 pins taken up potentially with a crystal, and 2 more as possible mux options for TCD (and they never fixed the silicon bug that breaks the other mux options for TCD) . In DD you will be able to do the same thing with the TCDs. However, we put them on the "most otherwise useless" set of pins otherwise…