M5Stack speaker not working



  • When I call the M5.Speaker.begin or M5.Speaker.tone functions it just crashes and reboots.
    I'm coding from the Arduino IDE, and even the example Speaker sketch causes the same behaviour.
    Is my M5Stack broken? I got the thing today, and I'm certain it was making sounds when it booted up the first time.



  • Hello @nexusdk

    I've just tested the Speaker sketch on my M5Stack Fire myself and the tones work just fine - no crash.

    Posting the crash log might be helpful to figure out what going on.

    Also as a test, could you try to install UIFlow firmware and check if the speaker works then?

    Thanks
    Felix



  • Hi @felmue,

    Thanks for the response. This is the crash log:

    M5Stack initializing...OK
    E (14534) ledc: freq_hz=0 duty_resolution=13
    Guru Meditation Error: Core  1 panic'ed (IntegerDivideByZero). Exception was unhandled.
    
    Core  1 register dump:
    PC      : 0x4000d099  PS      : 0x00060830  A0      : 0x800ddc9e  A1      : 0x3ffb2720  
    A2      : 0x0f424000  A3      : 0x00000000  A4      : 0x00000000  A5      : 0x00000000  
    A6      : 0x00060820  A7      : 0x00000001  A8      : 0x00000001  A9      : 0x00000000  
    A10     : 0x00000000  A11     : 0x0f424000  A12     : 0x00060820  A13     : 0x3ffb2720  
    A14     : 0x007bdc94  A15     : 0x003fffff  SAR     : 0x00000001  EXCCAUSE: 0x00000006  
    EXCVADDR: 0x00000000  LBEG    : 0x4008b5a5  LEND    : 0x4008b5b5  LCOUNT  : 0xfffffffe  
    
    
    Backtrace:0x4000d096:0x3ffb27200x400ddc9b:0x3ffb2740 0x400d90b1:0x3ffb2780 0x400d572e:0x3ffb27c0 0x400d5755:0x3ffb27e0 0x400d29b9:0x3ffb2800 0x400dab9a:0x3ffb2820 
    
    
    
    
    ELF file SHA256: 0000000000000000
    
    Rebooting...
    ets Jul 29 2019 12:21:46
    
    rst:0xc (SW_CPU_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
    configsip: 0, SPIWP:0xee
    clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
    mode:DIO, clock div:1
    load:0x3fff0030,len:1324
    ho 0 tail 12 room 4
    load:0x40078000,len:13508
    load:0x40080400,len:3604
    entry 0x400805f0
    

    When calling M5.Speaker.begin() I also get the IntegerDivideByZero.
    I actually did not know there was a crash log like this, so thanks for that!

    Burning the UIFlow firmware and using the speaker via https://flow.m5stack.com/ does work, so it must be something I am doing wrong. I am relieved that the device itself is not broken.



  • Hello @nexusdk

    thank you for sharing. That is strange. I cannot provoke that 'divide by 0' error in my setup.

    Exactly which M5Stack device are you using? M5Stack (Base, Gray, Fire) or M5Core2?

    In Arduino IDE which board have you chosen under Tools - Board?

    Can you compile and run a basic sketch like Hello World?

    Thanks
    Felix



  • Hi @felmue,

    I believe it's the M5Stack Core. The sticker on the top reads 2AN3WM5Stack-CORE. It was purchased from here:
    https://www.tinytronics.nl/shop/en/platforms-and-systems/m5stack/m5core/m5core/m5stack-esp32-basic-development-kit

    My current sketch connects to my wifi, gets time via NTP and shows a little game of Pong on the screen. All of this works fine on the device.

    The board selected in Arduino IDE is M5Stack-Core-ESP32



  • Hello @nexusdk

    thank you for the information - that all sound correct. And since you have a sketch running, albeit w/o using the speaker; I am out of ideas at this point in time. Sorry.

    Thanks
    Felix



  • Hi,

    The same happens to me.
    I have re-installed Arduino IDE and M5Stack libraries, but no change.

    M5Stack staff please help!

    Thanks
    Ingo



  • The same phenomenon occurs in my Basic and Gray.
    Execute the sample sketch [Speaker] and press the A or B button to reset the CPU.

    It does not occur when the board definition is returned to Ver2.0.1.
    I am confident that there is a problem with the board definition Ver2.0.2.



  • hello All,
    I have the same issue, it started with this new version 2021-0907 V2.61. M5Stack changed the driver that was the first unexpected issue. Ok I managed it and then I have found that SD card reading and writing is not possible, when I load a test Sketch. The factory test which is on a new device is working fine, that means the M5Stack is ok, but the library or my installation need an update. Have done that, but no luck.
    Today I have found that I am getting a Guru Meditation error, which goes away when I disable the // M5.Speaker.tone(1200);
    speaker command.

    Sorry that I do not have a fix yet, I need to investigate more and I would be happy if someone has an idea how to solve that issue.

    best regards
    Peter

    E (53174) ledc: freq_hz=0 duty_resolution=13
    Guru Meditation Error: Core 1 panic'ed (IntegerDivideByZero). Exception was unhandled.

    Core 1 register dump:
    PC : 0x4000d099 PS : 0x00060730 A0 : 0x800e89f2 A1 : 0x3ffb26c0
    A2 : 0x0f424000 A3 : 0x00000000 A4 : 0x00000000 A5 : 0x00000000
    A6 : 0x00060720 A7 : 0x00000001 A8 : 0x00000001 A9 : 0x00000000
    A10 : 0x00000000 A11 : 0x0f424000 A12 : 0x00060720 A13 : 0x3ffb26c0
    A14 : 0x007be1a8 A15 : 0x003fffff SAR : 0x00000001 EXCCAUSE: 0x00000006
    EXCVADDR: 0x00000000 LBEG : 0x40087571 LEND : 0x40087581 LCOUNT : 0xffffffff

    Backtrace:0x4000d096:0x3ffb26c00x400e89ef:0x3ffb26e0 0x400e4119:0x3ffb2720 0x400e0d9e:0x3ffb2760 0x400e0dc5:0x3ffb2780 0x400d5c5d:0x3ffb27a0 0x400dd723:0x3ffb2800 0x400e614d:0x3ffb2820



  • @petero I have to correct myself: The issue with the speaker is appearing with old M5Stack Core 1 versions as well, after I have used the new driver "CH34XSER_MAC". Very Strange!



  • I resolved the crash problem in a hacky way.

    Within the library, edit the file Speaker.cpp

    Edit line 12 to read :
    ledcSetup(TONE_PIN_CHANNEL, 1000, 13);

    I changed the 0 in the second parameter to a 1000.
    This is a frequency setting. I don't know what it does.

    It prevents the crash, allows a beep to be played, but the beep duration is wrong.



  • Hello guys

    The issue is a divide by zero, caused by the ledcSetup(TON_PIN_CHANNEL, 0, 13); function call found by @a4x4kiwi (thanks for that).

    I found that the outcome is different depending on the Arduino version used:

    • Arduino 1.0.6 - no error, no crash
    • Arduino 2.0.1 - no error, no crash
    • Arduino 2.0.2 - crash
    • Arduino 2.0.3 - error, no crash
    E (4532) ledc: freq_hz=0 duty_resolution=13
    [  4537][E][esp32-hal-ledc.c:75] ledcSetup(): ledc setup failed!
    

    Thanks
    Felix