!
Call
Returned Value
6. pwm_start
Function Name
Description
Sample code
Parameter
Call
Returned Value
12.3. Custom Channels
Users can customize PWM channels. Below is a detailed instruction on how to set GPIO4
as the forth channel for PWM signal output.
1. Modify initialization parameters.
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_3_OUT_IO_MUX,PWM_3_OUT_IO_FUNC,PWM_3_OUT_IO_NUM}
{PWM_4_OUT_IO_MUX,PWM_4_OUT_IO_FUNC,PWM_4_OUT_IO_NUM},
};
pwm_init(light_param.pwm_period, light_param.pwm_duty,
PWM_CHANNEL,io_info);
2. Modify user_light.h.
#define PWM_0_OUT_IO_MUX PERIPHS_IO_MUX_MTDI_U
#define PWM_0_OUT_IO_NUM 12
#define PWM_0_OUT_IO_FUNC FUNC_GPIO12
#define PWM_1_OUT_IO_MUX PERIPHS_IO_MUX_MTDO_U
#define PWM_1_OUT_IO_NUM 15
#define PWM_1_OUT_IO_FUNC FUNC_GPIO15
#define PWM_2_OUT_IO_MUX PERIPHS_IO_MUX_MTCK_U
#define PWM_2_OUT_IO_NUM 13
Espressif
Call pwm_start() after the parameters has been set.
Duty ratio of a certain PWM channel, the value returned is (duty*45)/ (period*1000).
pwm_start
Update PWM parameters.
pwm_start (void)
None.
Call pwm_start() when PWM related parameters have been set.
Null.
75 86
!
/!
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