Chat freely about anything...

User avatar
By drewle
#71923 Hi anybody,
I'm trying to use PWM with me ESP8266-12E.
I use the following code:
Code: Select all#include "osapi.h"
#include "uart.h"
#include "pwm.h"
#include "user_interface.h"
#include "espmissingincludes.h"

#define PWM_CHANNELS 1
ICACHE_FLASH_ATTR void my_init_done_cb()
{
   os_printf("done!!\n");
}

ICACHE_FLASH_ATTR void user_init()
{
   // Initialize UART
   uart_init(74880,74880);

   struct rst_info *rtc_info = system_get_rst_info();
   os_printf("reset reason: %x\n", rtc_info->reason);

   uint32_t period = 5000; // * 200ns ^= 1 kHz
   uint32 pwm_duty_init[PWM_CHANNELS] = {0, /*10240, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF*/};

   // PWM setup
   uint32 io_info[PWM_CHANNELS][3] = {
      // MUX, FUNC, PIN
      {PERIPHS_IO_MUX_MTDI_U,  FUNC_GPIO12, 12},
   };
   // initial duty: all off
   pwm_init(period, pwm_duty_init, PWM_CHANNELS, io_info);
   pwm_start();


   // Set callback when initialization is done
   system_init_done_cb(my_init_done_cb);
}


And I'm getting the following output:
Code: Select all
 ets Jan  8 2013,rst cause:2, boot mode:(3,7)

load 0x40100000, len 29224, room 16
tail 8
chksum 0xee
load 0x3ffe8000, len 900, room 0
tail 4
chksum 0x1b
load 0x3ffe8390, len 384, room 4
tail 12
chksum 0x0e
csum 0x0e
rf cal sector: 1019
rf[112reset reason: 6
mode : sta(ee:ff:bb:00:66:ee)
add if0
done!!
"@⸮rjrA(!⸮SKu⸮КvX%(⸮+⸮y⸮eh)"8⸮t⸮⸮⸮*NH⸮P⸮T⸮1⸮!u|⸮⸮Q 5⸮*M/=⸮n⸮*e"⸮⸮I⸮A,⸮'⸮⸮(E,R⸮*1)⸮vA,1⸮y*E⸮ n⸮*U"Hh⸮nA,RZMmr,R⸮*5⸮⸮⸮vA-⸮5y*E⸮ n⸮*M⸮ )i⸮~⸮9bN⸮⸮(1fN⸮rf cal sector: 1019
rf[112reset reason: 0
mode : sta(ee:ff:bb:00:66:ee)
add if0
done!!
⸮@⸮rjrA(⸮⸮SKu⸮КvX⸮(⸮+⸮y⸮eh)"8⸮tmݪNH⸮P⸮T⸮⸮⸮!e|⸮⸮Q   ⸮y*M/-⸮n⸮*e⸮HhI⸮A,⸮'!⸮⸮E,R⸮*⸮)⸮vA,1⸮y*Eh n⸮*E"⸮⸮InA,RZ
er⸮,R⸮*⸮⸮⸮vA-⸮5⸮*U⸮ n⸮*M⸮ )⸮⸮~⸮9bN⸮⸮(⸮vN⸮rf cal sector: 1019
rf[112reset reason: 0
mode : sta(ee:ff:bb:00:66:ee)
add if0
done!!


After the "done!!" the output should be over but with a delay of approximately 1s there are the strange signs and part of the normal output.
It seams there is a reset. Maybe it's the watchdog. But why?
What am I doing wrong?
If I remove the "pwm_init" the resets are gone.

By the way:
I' working with the SDK "esp_iot_sdk_v2.0.0"

Thanks
Drewle