-->
Page 3 of 15

Re: pwm_init creates a platform restart

PostPosted: Sun Aug 23, 2015 11:35 am
by eriksl
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();

Re: pwm_init creates a platform restart

PostPosted: Sun Aug 23, 2015 11:38 am
by limpkin
3 pwms worked on the other project...

Anyway, I already tried with 1 and 2 pwm channels... no success.

Re: pwm_init creates a platform restart

PostPosted: Sun Aug 23, 2015 11:48 am
by eriksl
Code: Select all uint32 pwm_duty_init[PWM_CHANNEL] = {0};

Do you realise this only sets the first entry to 0?

Re: pwm_init creates a platform restart

PostPosted: Sun Aug 23, 2015 11:51 am
by eriksl
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.