Want to know about Arduino 33 IoT's timers and related functions and PWM pins.

Hello,

I'm new in Arduino 33 IoT, and want to know about its timers and related functions and PWM pins.

In the case of Uno,
-Timer 0 for delay, millis, PWM(5, 6 pins)
-Timer 1 for servo, PWM(9, 10 pins)
-Timer 2 for tone, PWM(3, 11 pins)

What about the case of 33 IoT?
I couldn't find any documents about the case of 33 IoT.

you can see in analogWrite implementation how this table is used for PWM

here I have other use of the timer using the arduino pin mapping

I appreciate your reply.

I checked the link but I couldn't understand the codes

For example, D2 seems related with "TC5/0" and "TCC0/4" in the table, but I have no idea what they are
and whether they both effect analogWrite for D2 pin.

And it seems like the link does not show the mappings between the timers and the Arduino functions
that use timers internally such as delay, millis, analogWrite, tone, etc.

Would it be possible to provide some list of 33 IoT timer usages like the Uno example below?
[This example is for Uno]
-Timer 0 for delay, millis, PWM(5, 6 pins)
-Timer 1 for servo, PWM(9, 10 pins)
-Timer 2 for tone, PWM(3, 11 pins)

The above shows that if I change frequency of Timer 1, I cannot use servo function.
It also shows that if I use tone function, I cannot use PWM from 3 and 11 pins.
I would like to know such things for 33 IoT.

Thanks!

the table for 33 IoT is here

the SAMD has mux for pins. the datasheet shows mapping of pins to peripherals.
the table in variant.cpp has all this options in the A, B, C, D, E, F columns and has a * at the mapping selected by Arduino for the implementation of the core functions like the analogWrite, analogRead, Serial, Serial1, attachInterrupt

this mapping is then put in an array of pin mapping structs. the index in this array is the pin number as labeled on the PCB (or some are internal).

so if you call analogWrite on 6, the function uses the mapping on index 6 to get the SAMD pin number PA04, the mux 'column' E selected by Arduino for analogWrite on this pin and the timer TTC0 and the channel 0 associated with mux 'column' E for PA04 .

Thank you for the quick deep answers!

So if I understood correctly, TCC0 is in charge of PWM out for D5,D6,D9,and D10 pins if analogWrite is called on those pins?

But still have no clue about what timers do the "delay", "tone", "servo (library)" functions use.

in Tone.cpp
#define TONE_TC TC5
#define TONE_TC_CHANNEL 0

delay.c
delay() use micros() which uses the SysTick counter, not an interrupt

ServoTimers.h
#define TC_FOR_TIMER1 TC4
#define CHANNEL_FOR_TIMER1 0
#define TC_FOR_TIMER2 TC4
#define CHANNEL_FOR_TIMER2 1

I really appreciate your kind crystal clear answers.

It was my first time to post a question and I get more confidence using Arduino because of you people who are willing to help others like me.

Thank you!

By the way, where can I find all the implementations of the functions such as
delay, servo, and tone?

I searched servo and found the following link

But couldn't find other functions (tone, delay) from Arduino Libraries · GitHub

And can I assume the codes for SAMD as for the 33 IoT?

Thank you.

alexprotocol:
By the way, where can I find all the implementations of the functions such as
delay, servo, and tone?

I searched servo and found the following link
Servo/src/samd/ServoTimers.h at master · arduino-libraries/Servo · GitHub

But couldn't find other functions (tone, delay) from Arduino Libraries · GitHub

And can I assume the codes for SAMD as for the 33 IoT?

Thank you.

all this source files are on your computer and in verbose mode you can see in IDE console the command lines which compile them.

delay and tone are in core.

on github the samd core is here