grafalex82 / hellozigbee

Hello NXP JN5169 Zigbee
63 stars 13 forks source link

Reset during sleep #4

Closed mdepa91 closed 1 year ago

mdepa91 commented 1 year ago

I ran the code (just added a custom endpoint) and while sleeping it resets. If the sleep time is 1 minute, then rarely, if 10 minutes, then very often. Time between sleep and reset is random, can be 30s or 8min

reset during wakeup(with timestamp and delta): image

correct wakeup: image

do you know what it could be? tested on E75 and on custom PCB, changed power source, with or without UART. I've read documentation and other examples - found nothing.

I can paste the code, but it's almost same as on main branch

PS pullup resistor 10kOhm to RST didn't fix issue

OleksandrMasliuchenkoGL commented 1 year ago

Hmmm, interesting. Thank you for reporting that. To be honest, I did no try running the code on super long sleep intervals. I do not remember any limitations on the sleep duration, but need to refresh my knowledge from the documentation. I'll try checking this out during the weekend.

I have nothing specific to recommend in this case. Just a few ideas:

mdepa91 commented 1 year ago

Thanks for response, I'll run from battery, also I'll check 'Supply Voltage Monitor', about dumping PowerStatus - check screenshot and Device power statuses, it print active flags, and it isn't watchdog, BTW here is function:

void printPowerStatus() {
    DBG_vPrintf(TRUE, "> Device power statuses:");
    uint16 powerStatus = u16AHI_PowerStatus();  // //https://www.nxp.com/docs/en/user-guide/JN-UG-3087.pdf page 159
    if ((powerStatus >> 0) & 1) {
        DBG_vPrintf(TRUE, "\n\t* Device has completed a sleep-wake cycle");
    }
    if ((powerStatus >> 1) & 1) {
        DBG_vPrintf(TRUE, "\n\t* RAM contents were retained during sleep");
    }
    if ((powerStatus >> 2) & 1) {
        DBG_vPrintf(TRUE, "\n\t* Analogue power domain is switched on");
    }
    if ((powerStatus >> 3) & 1) {
        DBG_vPrintf(TRUE, "\n\t* Protocol logic is operational");
    }
    if ((powerStatus >> 7) & 1) {
        DBG_vPrintf(TRUE, "\n\t* Watchdog caused last device restart");
    }
    if ((powerStatus >> 10) & 1) {
        DBG_vPrintf(TRUE, "\n\t* 32kHz clock is ready");
    }
    if ((powerStatus >> 11) & 1) {
        DBG_vPrintf(TRUE, "\n\t* Device has just come out of Deep Sleep mode");
    }
    DBG_vPrintf(TRUE, "\r\n");
}

Thanks in advice, I spend almost weekend to read docs/learn/debug/compare to other examples so I'm running out of ideas :roll_eyes:

mdepa91 commented 1 year ago

Tested with power from battery(CR2032), also disabled(and log) BrownOut reset. Tested overnight and still resets, maybe a little less often

mdepa91 commented 1 year ago

I tested with example code from NXP - still the same. But I found out it was a connection to CP2102 UART adapter. I don't know why, I only connected GND RX TX, even just connecting GND still caused the problem. Maybe wires are too long and thin(about 50cm)

Another weird thing that gave me a hint if I touch GND with my hand - it causes a reset, even with a CR2032 battery in holder on PCB.

OleksandrMasliuchenkoGL commented 1 year ago

Glad you identified the issue. I tested on my side overnight with 30min sleep intervals, and did not spot any issues.

Thank you for the interest in my project.

mdepa91 commented 1 year ago

Thank you for your interest. It's not my first uC(I just came from TexasInstruments CC265X after issues with power consumption - confirmed this time :smile:) but this behavior surprises me.

I wasn't sure why you rewrote so much, but after working with the official examples - now I know. Thank you very much