PWM
4G LTE Module PWM Channel Mapping
Note
PWM Channel 1 on RDA8910 and RDA8955 based modules has limited configurable period and duty cycle.
PWM Channel |
EC600U |
EC200U |
N58 |
N716 |
L610 |
EG915U |
|---|---|---|---|---|---|---|
PWM CH 0 |
Pin 70 |
Pin 135 |
Pin 39 |
Pin 38 |
Pin 135 |
Pin 20 |
PWM CH 1 |
Pin 54 |
Pin 5 |
– |
Pin 67 |
Pin 5 |
Pin 21 |
GSM/NB-IoT Module PWM Channel Mapping
RDA8955 based modules
PWM Channel |
M590 Pin |
MC65 Pin |
A9 Pin |
|---|---|---|---|
PWM CH 0 |
Pin 58 |
Pin 25 |
Pin 50 |
PWM CH 1 |
Pin 59 |
Pin 24 |
Pin 49 |
MT2503/MT6261/MT2625 based modules
PWM Channel |
M56 Pin |
MC60 Pin
|
M66 Pin |
BC20 Pin |
SIM868 Pin |
|---|---|---|---|---|---|
PWM CH 0 |
Pin 12 |
Pin 47 |
Pin 16 |
Pin 47 |
Pin 6 |
PWM CH 1 |
Pin 27 |
Pin 28 |
– |
Pin 3 |
Pin 57 |
PWM CH 2 |
– |
– |
– |
Pin 36 |
– |
PWM CH 4 |
– |
– |
– |
Pin 61 |
– |
Example Usage
#include <hw/pwm.h>
/* Init PWM */
pwm_init(PWM_CH0);
/* configure PWM @ 1Khz 50% duty */
pwm_config(PWM_CH0, 1000, 50);
/* start pwm */
pwm_start(PWM_CH0);
/* stop PWM */
pwm_stop(PWM_CH0);
/* free PWM */
pwm_free(PWM_CH0);
Application Example
API Reference
Header File
Source: include/hw/pwm.h
#include <hw/pwm.h>
Functions
-
int pwm_init(int ch)
Initialize PWM channel and setup pin-muxing. This function must be called before calling any other PWM function.
- Parameters:
ch – PWM Channel pwmch_e
- Returns:
0 on success, negative value on error
-
int pwm_config(int ch, unsigned int freq, unsigned int cycle)
Configure PWM channel parameters
- Parameters:
ch – PWM Channel to configure pwmch_e
freq – PWM Frequency to set
cycle – PWM Duty cycle
- Returns:
0 on success, negative value on error
-
int pwm_start(int ch)
Start PWM output
- Parameters:
ch – PWM Channel to start pwmch_e
- Returns:
0 on success, negative value on error
-
int pwm_stop(int ch)
Stop PWM output
- Parameters:
ch – PWM Channel to stop pwmch_e
- Returns:
0 on success, negative value on error
-
int pwm_free(int ch)
Release PWM channel and IO function changed to GPIO
- Parameters:
ch – PWM Channel to free pwmch_e
- Returns:
0 on success, negative value on error
Note
Please refer header file for actual number of channels available for respective board.
Header File
Source: include/plat/def_pwm.h
#include <plat/def_pwm.h>
Enumerations
-
enum pwm1_prd_e
PWM Channel 1 - Fixed Period in milliseconds
Note
Only for Platform with RDA8910 SoC
Values:
-
enumerator PWM1_PRD_125MS
-
enumerator PWM1_PRD_250MS
-
enumerator PWM1_PRD_500MS
-
enumerator PWM1_PRD_1000MS
-
enumerator PWM1_PRD_1500MS
-
enumerator PWM1_PRD_2000MS
-
enumerator PWM1_PRD_2500MS
-
enumerator PWM1_PRD_3000MS
-
enumerator PWM1_PRD_125MS
-
enum pwm1_duty_e
PWM Channel 1 - Fixed On-time/Duty cycle in milliseconds
Note
Only for Platform with RDA8910 or RDA8955 SoC
Values:
-
enumerator PWM1_DUTY_UNDEFINE
-
enumerator PWM1_DUTY_15_6MS
-
enumerator PWM1_DUTY_31_2MS
-
enumerator PWM1_DUTY_46_9MS
-
enumerator PWM1_DUTY_62_5MS
-
enumerator PWM1_DUTY_78_1MS
-
enumerator PWM1_DUTY_93_7MS
-
enumerator PWM1_DUTY_110MS
-
enumerator PWM1_DUTY_125MS
-
enumerator PWM1_DUTY_141MS
-
enumerator PWM1_DUTY_156MS
-
enumerator PWM1_DUTY_172MS
-
enumerator PWM1_DUTY_187MS
-
enumerator PWM1_DUTY_203MS
-
enumerator PWM1_DUTY_219MS
-
enumerator PWM1_DUTY_234MS
-
enumerator PWM1_DUTY_UNDEFINE
