element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Arduino Forum Arduino Zero / Adafruit Feather M0 - PWM Outputs
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Verified Answer
  • Replies 7 replies
  • Answers 5 answers
  • Subscribers 391 subscribers
  • Views 1722 views
  • Users 0 members are here
  • atsamd21
  • arduino zero
  • feather m0
  • adafruit
Related

Arduino Zero / Adafruit Feather M0 - PWM Outputs

wallarug
wallarug over 6 years ago

Hi Arduino Community!

 

I am having an issue finding documentation that says what pins on the ATSAMD21G18 are PWM enabled.  The adafruit documentation says that only 7 pins have Pulse Width Modulation support while the Ardunio documentation says that all pins except 0, 1, 2 and 7 can do PWM.

 

I am looking for a third opinion on the topic from the community as you may have the knowledge / experience with this microprocessor.

 

 

Check out the Adafruit Documentation Here:

 

https://learn.adafruit.com/adafruit-feather-m0-adalogger/pinouts

 

 

This documentation states that 'most pins are pwm enabled'.  In the diagram it indicates that only 7 pins are pwm enabled. 

 

 

Could some please confirm with me which pins are pwm enabled for the board?

 

 

Thank you!!!

  • Sign in to reply
  • Cancel

Top Replies

  • fmilburn
    fmilburn over 6 years ago +7 verified
    Hi wallarug , This can be confusing. A good place to start is the datasheet which Adafruit has linked to at the top of the Downloads section of your link. Note that Adafruit is using the G variant (SAM…
  • fmilburn
    fmilburn over 6 years ago in reply to wallarug +3 suggested
    Good catch. What I stated above is factually correct but I read your question wrong / had a brain lapse and have misled you. I wish they wouldn't call PWM analogWrite. PWM is really about setting up the…
  • wallarug
    wallarug over 6 years ago in reply to fmilburn +2
    Hi Frank, Thank you for your very informative and helpful response. Just to confirm one final point... from the datasheet, the function to look for to indicate that the pin is PWM capable is ADC. From…
Parents
  • fmilburn
    0 fmilburn over 6 years ago

    Hi wallarug,

     

    This can be confusing.  A good place to start is the datasheet which Adafruit has linked to at the top of the Downloads section of your link.  Note that Adafruit is using the G variant (SAM D21G).  In the configuration summary on page 3 the datasheet states that there are 14 ADC channels.  Paging down to the pinout description on Page 15 the 14 ADC channels are shown next to their physical pins on the microcontroller along with the port / pin designation.  For example, physical pin 3 is connected to PA02.

     

    The pins can be multiplexed, i.e. assigned to different peripheral functions.  These capabilities are described in Section 10 which starts on Page 21.  Using physical pin 3 again as an example, we see it can be configured among other things as ADC AIN(0) using the Atmel nomenclature.  Note that not all of the ADC configurations are available for the G variant.

     

    So, now the capabilities are known, but it is necessary to look at what pins Adafruit (or Arduino) has brought out on their board for use and how they mapped it to the Arduino IDE.  Returning to the pinout map in your link.  Look for physical pin 3 again in the dark grey box nearest the representation of the board.  Note that it is labeled A0 on the board.  Next to the physical pin 3 box is an olive colored one that has PA02 in it - the same as in the datasheet.  We also see the other configurations from the datasheet.  In the furthest most box we see '14' and 'A0'.  The legend for the pinout tells us that these are the Arduino IDE designations.

     

    Adafruit has somewhat arbitrarily decided to bring PA02, located on physical pin 3 of the SAMD21G, and call it A0.  I count 7 pins which Adafruit has brought out and labeled as PWM on the pinout.  You can go through the same exercise with the Arduino Zero. 

     

    Frank

    • Cancel
    • Vote Up +7 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • wallarug
    0 wallarug over 6 years ago in reply to fmilburn

    Hi Frank,

     

    Thank you for your very informative and helpful response.

     

    Just to confirm one final point... from the datasheet, the function to look for to indicate that the pin is PWM capable is ADC.

     

    From the datasheet it appears that the following pins on the SAM D21G have this capability (if you had access to all pins):

     

    PhysicalI/O Pin
    3PA02
    4PA03
    7PB08
    8PB09
    9PA04
    10PA05
    11PA06
    12PA07
    13PA08
    14PA09
    15PA10
    16PA11
    47PB02
    48PB03

     

    Thank you very much for guiding me through this process. 

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • fmilburn
    0 fmilburn over 6 years ago in reply to wallarug

    Good catch.  What I stated above is factually correct but I read your question wrong / had a brain lapse and have misled you.  I wish they wouldn't call PWM analogWrite.  PWM is really about setting up the output from timers and is not analog.  It is possible of course to have PWM without any ADC capability.  Arduino uses the tilde (~) to designate PWM.  I am not really an Arduino user, have only just started using the Arduino MKR boards, and have not used the Adafruit.  Look on your board for the tilde and that is where you have PWM.  Those are the pins that they decided to map to the timers.  It is still a good idea to get familiar with the datasheet.  The timers are very flexible and powerful if used outside the Arduino IDE.

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
Reply
  • fmilburn
    0 fmilburn over 6 years ago in reply to wallarug

    Good catch.  What I stated above is factually correct but I read your question wrong / had a brain lapse and have misled you.  I wish they wouldn't call PWM analogWrite.  PWM is really about setting up the output from timers and is not analog.  It is possible of course to have PWM without any ADC capability.  Arduino uses the tilde (~) to designate PWM.  I am not really an Arduino user, have only just started using the Arduino MKR boards, and have not used the Adafruit.  Look on your board for the tilde and that is where you have PWM.  Those are the pins that they decided to map to the timers.  It is still a good idea to get familiar with the datasheet.  The timers are very flexible and powerful if used outside the Arduino IDE.

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
Children
  • genebren
    0 genebren over 6 years ago in reply to fmilburn

    Frank,

     

    On a lot of these small boards, PWM is about the only way to do analog, albeit a somewhat indirect way.  By filtering the PWM output into a low pass filter, you can convert the PWM into a pseudo DAC.  This allows you to in effect to do an analogWrite.

     

    Gene

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube