PWM FAILURE

scargill
Posts: 70
Joined: Sun Nov 02, 2014 8:09 pm

PWM FAILURE

Postby scargill » Sat Apr 23, 2016 12:40 am

I am using the latest SDK - programming the ESP8266 (ESP12) in C.

I have had PWM running for some time but not tested it for a few months. Now that I come to test, it is crashing.

I thought I'd look at the SDK manual (1.5.2) and I noted that the manual states... for PWM_INIT - that the duty is a uint8 *duty

That cannot be right as the duty cycles are 32 bits. I tried changing my array to 8 bits regardless and that caused the processor to crash immediately on power up.

Here is my code.

#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_3_OUT_IO_MUX PERIPHS_IO_MUX_GPIO4_U
#define PWM_3_OUT_IO_NUM 4
#define PWM_3_OUT_IO_FUNC FUNC_GPIO4

#define PWM_4_OUT_IO_MUX PERIPHS_IO_MUX_GPIO5_U
#define PWM_4_OUT_IO_NUM 5
#define PWM_4_OUT_IO_FUNC FUNC_GPIO5

#define PWM_CHANNEL 5

uint32 duty[] = {0, 0, 0};
uint32 freq = 1000;
static uint8 donepwm = 0;

uint32 io_info[][3] = {
{PWM_1_OUT_IO_MUX, PWM_1_OUT_IO_FUNC, PWM_1_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}
};


and when I start the PWM (long after power up) - I use this... once only...

pwm_init(freq, duty, 3, io_info);

Within seconds of using this I get a watchdog timer timeout and the processor reboots...

This used to work.

So am I right in saying that even the latest manual is WRONG (because the PWM routines later on have 32 bits for duty - so 8 bits cannot be right in init, surely??) and assuming it IS 32 bits - why would running this crash the processor. It didn't used to.

scargill
Posts: 70
Joined: Sun Nov 02, 2014 8:09 pm

Re: PWM FAILURE

Postby scargill » Sun Apr 24, 2016 8:54 pm

This has now been solved. see http://tech.scargill.net/pwm-woes/

It would appear that the manual definition of pwm_init IS wrong - and also there is a potential alignment problem in the SDK - see comments here.

http://www.esp8266.com/viewtopic.php?f= ... 060#p46060

Espressif need to fix this - if there is a potential alignment issue for this - there may be others.

Who is online

Users browsing this forum: No registered users and 15 guests