0

Trinket M0 Timers
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Trinket M0 Timers

by eboxhead on Mon Jan 28, 2019 5:17 pm

I'm looking to adjust the PWM frequency on the Trinket M0, but I'm a little lost on where to find what timers do what on this device. Looking through the SAMD21 datasheet it the port mappings don't appear to call out a timer for PA06 and PA07 (pins 3 and 4). I'm sure I'm looking in the wrong place... are there any suggestions on where else I might be able to find out what timers the Trinket M0 (and the SAMD for that matter) uses for what?

Thanks!

eboxhead
 
Posts: 18
Joined: Wed Nov 09, 2011 4:07 pm

Re: Trinket M0 Timers

by adafruit_support_mike on Tue Jan 29, 2019 4:22 am

The best (though not obvious) place to start looking for information about the configuration of a specific board is the 'variant.cpp' file in the board support package:

https://github.com/adafruit/ArduinoCore ... ariant.cpp

That includes an array of flags that describe what each pin can do. Functions like analogWrite() check the array to decide how to handle a given pin.

From a quick skim, it looks like most of the PWM pins are connected to TCC0 and TCC1.

The SAMD21 has two kinds of PWM peripherals: the Timer-Counter which can generate two signals in a few basic patterns, and the Timer-Counter-for-Control which can generate more kinds of patterns on up to 8 pins.

To change the PWM frequency you'll want to look at its Generic Clock source and the prescaler value applied by the TCC's counter.

adafruit_support_mike
 
Posts: 55974
Joined: Thu Feb 11, 2010 2:51 pm

Re: Trinket M0 Timers

by eboxhead on Wed Jan 30, 2019 1:04 pm

Awesome, thank you!

I'll give that a look in a bit.

eboxhead
 
Posts: 18
Joined: Wed Nov 09, 2011 4:07 pm

Please be positive and constructive with your questions and comments.