16bit pwm on arduino micro?

Hi, I was seeing some datasheets and pinouts and I remarked that the ATmega32U4 has up to 7 pwm pins (actually 8?) and also that they seem to have different resolutions from 8 to 16 bits.

So the here are the questions:

  1. are the 8 pwm pins usable from the arduino core/IDE? Or just 7?
  2. from the arduino IDE how can one access to the different pwm resolutions? I found for other cards analogwriteresolution () function but the micro doesn't appear on the references.
  3. not that I have a plan to use it right now, but for plain curiosity, since some of the pwm capable pins seem to have ADC as well, would it be possible to toogle between PWM and analogread?

Thx!

  1. All the pins on the chip which are brought out to Arduino pins are useable. Check the pin mapping on the Arduino product page.

For example, the Tx and Rx LEDs are individually-addressable pins on the Micro but they aren't useful to most projects because you can't easily attach a wire to them.

  1. What happened when you tried it?

  2. If you have circuitry attached to the pin which is expecting a PWM output then the pin isn't useful as an analog input. If you have some kind of external switch then perhaps this would make sense. The Arduino doesn't care if you toggle 1000 times per second.

  1. Arduino website states 7 pwm.... on several pinouts (pighixxx) there are 8....

  2. I haven't... I don't even have this board yet. I'm thinking about getting it because I need more PWM pins about 7~8, I would like to keep it simple and not to get an external pwm driver and a micro is still cheaper than a mega

The max PWM resolution for a particular pin depends on whether the HardwareTimer that controls the pin is an 8-bit or a 16-bit timer. The 16-bit timers can also be used as 8-bit timers and I think the standard Arduino initialization sets them all as 8-bit.

If you study the Atmega 32U4 datasheet you will get all the details. I don’t think all the 32U4 pins are accessible on a Micro.

…R