User's Manual

Table Of Contents
AI7688H User Manual
-46-
Copyright@2016 AcSiP
PWM
Use PWM module to generate a pulse width modulated signal pattern.
This is useful to control actuator peripherals such as servo motors. To use PWM, initialize it
on a certain pin such as GPIO. Note that only GPIO18, GPIO19, GPIO20, GPIO21 supports
PWM on AI7688H. To control the PWM pattern, several parameters are required, including:
Period
This defines the carrier frequency of the modulation. It’s controlled by period, period_ms
and period_us APIs.
Duty Cycle or 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 pin P26.
I2C
I2C (Inter-Integrated Circuit) is a widely used protocol among peripherals. It consists of 2
signal pins - usually named SDA and SCL. AI7688H comes with 1 set of I2C on GPIO4(P21)
and GPIO5(P20) as SCL and SDA respectively. The way I2Cs are initialized is slightly different
from GPIO modules - instead of using pins, I2Cs are initialized according to its device index.
Since there is only 1 set of I2C master device on AI7688H, you can simply pass 0 - and it is
always on pin GPIO4 and GPIO5.
I2C is capable of connecting multiple slave devices to a single I2C master. Each slave device
is identified by a 7-bit address.