-52-
Document Name
AI7688H
Reference Manual
Version
V 2.0
Date 2019/08/08
10.6
Controlling PWM with MRAA on AI7688H
Configure PWM pin:
To use PWM, initialize it on a certain pin such as GPIO. Note that only
GPIO#18
,
GPIO#19
,
GPIO#20
,
GPIO#21
supports PWM on AI7688H. So the
first step is to create a Pwm object by assigning the desired GPIO number.
Period
This defines the carrier frequency of the modulation. It’s controlled by
period, period_ms and period_us APIs, for example:
Duty Cycle and Pulse Width
These two parameters are related to each other and usually you only need
to set one of them. Duty cycle is controlled by write API with a value range
between 0.0 to 1.0, where 0.0 is 0% of duty cycle and 1.0 is 100% of duty
cycle. Pulse width also defines the pattern in a different unit: the "uptime"
of the signal in time units. This is defined by pulsewidth, pulsewidth_ms,
and pulsewidth_us APIs.
The following example generates a 500Hz PWM signal with 25% duty cycle
on GPIO19