rab wrote:Did you manage to fix this? I'm getting a WDT reset everytime I call pwm_init too.
Built with various SDK versions: 1.2, 1.3 and 1.4 and it just works.
I still think something in your and TS' code is wrong. Like a pointer to an incorrect sized integer (array) etc.
eriksl wrote:rab wrote:I still think something in your and TS' code is wrong. Like a pointer to an incorrect sized integer (array) etc.
I'd be very happy for you to tell me what's wrong with this code:
#define PWM_CHANNEL 1
#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
uint32 io_info[PWM_CHANNEL][3] = {{PWM_0_OUT_IO_MUX,PWM_0_OUT_IO_FUNC,PWM_0_OUT_IO_NUM}};
uint8 pwm_duty_init[PWM_CHANNEL] = {0};
pwm_init(1000, pwm_duty_init, PWM_CHANNEL, io_info);
uint8 pwm_duty_init[PWM_CHANNEL] = {0};
by this
uint32 pwm_duty_init[PWM_CHANNEL];
Or even better: uint32_t, but for that, you need to have the open esp sdk which has the headers fixed.
The = {0} is pointless, because it will only initialise the first member. Make sure all of them get initialised properly, which can be only done in a loop, because the length of the array is dynamic (due to the #define).
Did I already mention that #defines are evil? That you should use either static const or enum's?
Did I already mention that you should enable ALL possible warnings on gcc, and if you did, gcc would have warned about an incompatible pointer at this point?