eriksl wrote:Replace thisCode: Select alluint8 pwm_duty_init[PWM_CHANNEL] = {0};
by thisCode: Select alluint32 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 sdk manual states that the pwm_duty parameter is an array of uint8s, but now you mention it the header file does say uint32. Has anyone pointed that out to Espressif to correct the documentation? Either way I have actually tried with uint32s (as I saw it that way in other sample code) and unfortunately the result was exactly the same. I'm not sure why you think using uint32_t would be any better.
eriksl wrote: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).
That is incorrect. {0} will initialise all values in the array to 0.
eriksl wrote:Did I already mention that #defines are evil? That you should use either static const or enum's?
That's your preference, but there is nothing at all wrong with #defines in general or how they were used in the little code I posted. In all likely hood the compiler will produce the exact same code after optimisation, worse case scenario putting them in variables will just waste stack space.
eriksl wrote: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?
It should have anyway by default, without a cast to tell it the difference was deliberate. It was originally uint32s and one of the last things I tried was to switch to uint8s, as per the manual, I may have coped and pasted a version that didn't actually compile anyway, oops.