Skip to content

Arduino PWM pin conflicts on SAMD21 #329

Closed
@kattni

Description

@kattni

From user feedback:

I am pretty sure there are some PWM pin conflicts on QT Py, for example, pin 4 is mapped to TCC0_CH6, and pin 10 is mapped to TCC0_CH2, but for this board variant, there's a line of code that says TCC0_CH6 = (0<<8)|(2), // Channel 6 is 2!.

I've observed this in practice. If both pins are running PWM, and you change the duty cycle of one, the other one changes with it.

pinMode(4, OUTPUT);
pinMode(10, OUTPUT);
analogWrite(10, 1);
analogWrite(4, 128);

Measure the output on pin 10, the duty cycle is 50%, when it should be nearly zero.

It's not something that can be fixed, it's nobody's fault, but it'll be nice if the tutorial page for the QT Py mentioned this.

The variant mentioned is in core Arduino, and is from the original Arduino code. It might be a hardware limitation. The question is should we document it in the SAMD21 board guides? Or is this an unusual and unlikely situation to encounter?

@dhalbert Found these links and thought they might somehow be related.
https://forum.arduino.cc/t/samd21-wo-and-cc-register-mapping/852449
arduino#170

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions