!
Uint32 period;
Uint32 freq;
uint32 duty[PWM_CHANNEL_NUM_MAX];
};
void pwm_init(uint32 period, uint32 *duty,uint32
pwm_channel_num,uint32 (*pin_info_list)[3]);
void pwm_start(void);
void pwm_set_duty(uint32 duty, uint8 channel);
uint32 pwm_get_duty(uint8 channel);
void pwm_set_freq(uint32 period);
uint32 pwm_get_freq(void);
12.2.2. Interface Specifications
1. pwm_init
Function Name
Definition
Sample code
Description
Parameters
Call
Returned Value
2. pwm_set_period
Function Name
Definition
Espressif
pwm_init
PWM initialization.
pwm_init (uint32 freq, uint32 *duty, uint32
pwm_channel_num,uint32 (*pin_info_list)[3]);
PWM GPIO, initializing parameters and timer.
• uint32 freq: PWM period.
• uint32 *duty: duty ratio of each PWM channel.
• uint32 pwm_channel_num: the number of PWM channels.
• uint32 (*pin_info_list)[3]: This parameter, which is made up of a n x 3 array pointer,
defines the GPIO hardware parameter of each PWM channel. Registers of GPIO, pin
multiplexing of IO, and the serial number of each GPIO are defined in the array. Take the
initialization of a 3-channel PWM for example:
uint32 io_info[][3] =
{{PWM_0_OUT_IO_MUX,PWM_0_OUT_IO_FUNC,PWM_0_OUT_IO_NUM},
{PWM_1_OUT_IO_MUX,PWM_1_OUT_IO_FUNC,PWM_1_OUT_IO_NUM},
{PWM_2_OUT_IO_MUX,PWM_2_OUT_IO_FUNC,PWM_2_OUT_IO_NUM}};
pwm_init(light_param.pwm_period,light_param.pwm_duty,
3,io_info);
Call the function when the system is been initialized. Currently the function can be called
only once.
Null
pwm_set_period
Set PWM period.
73 86
!
/!
//PWM period
//PWM frequency
//PWM duty ratio
12. PWM Interface
2016.05
Need help?
Do you have a question about the ESP8266 and is the answer not in the manual?
Questions and answers