0x08

Base Register Address

This module provides support for Pulse Width Modulation (PWM) output.

Nomenclature

The seesaw PWM Function Registers are defined using a generic nomenclature as follows:

  • PWM Number - Specifies a specific PWM output (pin).
  • PWM Value - Specifies the PWM duty cycle.
  • PWM Frequency - Specifies the PWM frequency.

See the Port Specific Details section below for further information.

Function Register Summary

Register Address

Register Name

Register Size

Access

0x01

PWM_VAL

3 bytes

W

0x02

PWM_FREQ

3 bytes

W

Function Register Description

0x01 - PWM_VAL

Byte 0

Byte 1

Byte 2

PWM Number

PWM Value MSB

PWM Value LSB

Sets the PWM Value for a specified PWM Number. The first byte written is the PWM Number. The next two bytes are the 16 bit PWM Value, most significant byte (MSB) followed by least significant byte (LSB).

0x02 - PWM_FREQ

Byte 0

Byte 1

Byte 2

PWM Number

PWM Frequency MSB

PWM Frequency LSB

Sets the PWM Frequency for a specified PWM Number. The first byte written is the PWM Number. The next two bytes are the 16 bit PWM Frequency, most significant byte (MSB) followed by least significant byte (LSB).

Port Specific Details

SAMD

PWM outputs are available on pins PA04, PA05, PA06, and PA07. The PWM Number for each is shown in the table below.

PWM Number

Output Pin

0

PA04

1

PA05

2

PA06

3

PA07

The full 16 bit PWM Value is used. This value should be an unsigned integer ranging from 0 for full off to 65535 for full on.

The PWM Frequency is a 16 bit unsigned integer value which specifies the frequency in hertz (Hz).

ATtiny

The PWM Number is the Arduino GPIO pin number.

Currently, only the MSB of the 16 bit PWM Value is used. This is due to the 8 bit limit of analogWrite() used internally. However, a full 16 bit value should be sent from 0 for full off to 65535 for full on.

The PWM Frequency is a 16 bit unsigned integer value which specifies the frequency in hertz (Hz). (NOTE: uses tone() internally)

This guide was first published on Oct 20, 2021. It was last updated on May 23, 2024.

This page (PWM) was last updated on Mar 08, 2024.

Text editor powered by tinymce.