ESP8266 Developer Zone The Official ESP8266 Forum 2016-04-24T20:54:29+08:00 https://bbs.espressif.com:443/feed.php?f=7&t=2069 2016-04-24T20:54:29+08:00 2016-04-24T20:54:29+08:00 https://bbs.espressif.com:443/viewtopic.php?t=2069&p=6587#p6587 <![CDATA[Re: PWM FAILURE]]> 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.

Statistics: Posted by scargill — Sun Apr 24, 2016 8:54 pm


]]>
2016-04-23T00:40:58+08:00 2016-04-23T00:40:58+08:00 https://bbs.espressif.com:443/viewtopic.php?t=2069&p=6573#p6573 <![CDATA[PWM FAILURE]]>
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.

Statistics: Posted by scargill — Sat Apr 23, 2016 12:40 am


]]>