Chat freely about anything...

User avatar
By eriksl
#26885 What happens if you only use two PWMs? I have actually never used more than two PWM at the same time, maybe you ran into an SDK bug.

I do this (pseudo code), this works for at least two pwm's:

Code: Select alluint32_t pwm_io_info[gpio_pwm_size][3];
uint32_t pwm_duty_init[gpio_pwm_size];
gpio_init(); /* this may or may not matter, try it... */
for pwmchannel in all pwm's
{
    pwm_io_info[pwmchannel][0] = mux_index;
    pwm_io_info[pwmchannel][1] = mux_func;
    pwm_io_info[pwmchannel][2] = pin_index;
    pwm_duty_init[pwmchannel] = duty;
}
pwm_init(3000, pwm_duty_init, pwmchannel, pwm_io_channel);
pwm_start();
User avatar
By eriksl
#26890 Also you might want to try this:

Code: Select alluint32 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}};


change to this:

Code: Select alluint32 io_info[PWM_CHANNEL][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}};


So you're sure that the io_info array is exactly as large as the pwm_init function expects. This is just like #define usage, help the compiler help you by not trusting on "easy" default behaviour.