analogWriteResolution with promicro boards

I would like to use analogWrite with the Sparkfun Micro Pros with a higher PWM precision.

I see from the promicro data sheets that they seem to support 10 bit (on pins 5 and 6) and 16 bit resolution (on pins 9 and 10) (*unless I’m mis-reading these pdf’s?)…

https://cdn.sparkfun.com/assets/f/d/8/0 … 6MHzv2.pdf

https://cdn.sparkfun.com/assets/learn_t … oUSB-C.pdf

However, with the latest Boards Manager versions (*I am using version 1.1.13) – the analogWriteResolution does not appear to be settable.

You’ll get a compile error message: ‘analogWriteResolution’ was not declared in this scope

Looking at the board files in Library/Arduino15/packages/SparkFun/hardware/avr/1.1.13/variants/promicro

  • I don’t see that you are setting the analog resolution anywhere for the promicro series

= Unlike the Adafruit Feather M0, where I see in its Boards Manager configuration

#define ADC_RESOLUTION 12

(and you can set analogWriteResolution with their boards)

Is there a configuration file change,

  • or a newer beta boards manager version,

= that I can use to unlock the 10 bit (on pins 5 and 6) and 16 bit resolution (on pins 9 and 10) of the promicro series of boards?

My ideal would be to match the analogRead 10 bit precision with an analogWrite with the same 10 bit resolution.

It’s painful mapping an analog 10 bit input to a lower 8 bit resolution!

Thank you for you any insights you can offer.

Hello,

It seems that those blocks labeled “8-Bit, 10-Bit, or 16-Bit” are in the same color for PWM, not ADC. I don’t believe they are used for this purpose.

In addition, the Adafruit board is based on a SAMD21 ARM Cortex-M0. There could be functions that the ARM chip can do that our AVR chip can not.

My apologies if my reference to ADC and analog input made my question confusing.

I am trying to unlock the 10 bit PWM analogWrite potential that appears in the ProMicro data sheets.

I am happy with the ProMicro 10 bit resolution - AVR by default reads analog 10 bit.

I want to set

analogWriteResolution(10); // Set PWM output resolution to 10 bits

but SparkFun AVR Boards v1.1.13 doesn’t appear to allow analogWriteResolution to be set

at least in its default configuration

is there any way to enable analogWriteResolution(10) within this v1.1.13 configuration, or using some other method?

I might be wrong about this, but it appears that [analogWriteResolution() is only implemented in the IDE for the Zero, Due & MKR family of Arduino boards and won’t work on a 32U4 based board like the ProMicro.](https://www.arduino.cc/reference/en/language/functions/zero-due-mkr-family/analogwriteresolution/)[/u]

My apologies.

Have you tried setting using registers? https://www.arduinoslovakia.eu/blog/201 … no?lang=en

There could be an issue using the analogWriteResoulution() but the registers might be a way around it.