[BC660K_GL] How to make sure module goes into deepsleep without any problem?

Hi,
I am using BC660K_GL.
I am trying to put the device into sleep mode, but it’s not happening.
I have tried with the Standalone firmware package and with the QuecOpen Package.

I want to know what is the right way to make it enter into sleep mode, and when is the right time to do so?

First case: QuecOpen.(BC660K-GL_QuecOpen_NB5_SDK_V1.0)
After all the communications are done, set up the rtc time to wake module, here is the sequence,

  1. AT+CFUN=0 (Wait for CSCON=0)
  2. AT+QSCLK=1
    (Also used Ql_SleepEnable(), Also used AT+QRELLOCK which sometimes gives an error).

Sometimes nothing happens, but sometimes I see the following output:

I tried the logs in DeepSleep Handler, and it shows this output,

[2023-01-11_19:28:20:983]<-- Deepsleep_handler: len 35,
[2023-01-11_19:28:20:983]+QNBIOTEVENT: “ENTER DEEPSLEEP”
[2023-01-11_19:28:20:983]–>

right after this following comes,

[2023-01-11_19:28:20:983]+QNBIOTEVENT: “DEEPSLEEP FAIL”

2nd case: Native Standalone (BC660KGLAAR01A04).
AT+QSCLK+1 does nothing, only OK Response, and then nothing,
Here AT+QRELLOCK never gives an ERROR but is always OK, still, the module is awake?

Only once I saw the following output,

[2023-01-12_11:03:49:783]+QNBIOTEVENT: “ENTER DEEPSLEEP”
[2023-01-12_11:03:50:080]
[2023-01-12_11:03:50:080]+QNBIOTEVENT: “EXIT DEEPSLEEP”

    • What I’m doing wrong, I also tried disabling/enabling PSM (AT+CPSMS=0/1, EDRX is disabled), but I see this error or nothing happens and the module is awake.
    • What is the right sequence of commands to enter deep sleep mode?
    • What should be the state of CFUN (or PSM enabled and disabled), CPSMS, QPSMS, CSCON, CEREG, etc. to make sure the module goes to sleep?
    • Is AT+QSCLK enough to put the module to sleep?
  1. *How to know module has entered deep sleep (will +QNBIOTEVENT: ENTER DEEPSLEEP appear always, of course this event is enabled already)

`

here is sample of output from standalone module package,

[2023-01-12_18:02:41:287]RDY
[2023-01-12_18:02:41:614]
[2023-01-12_18:02:41:614]+CFUN: 1
[2023-01-12_18:02:41:676]
[2023-01-12_18:02:41:676]+CPIN: READY

[2023-01-12_18:02:41:676]+CEREG: 2
[2023-01-12_18:02:45:558]AT+QSCLK=0

[2023-01-12_18:02:45:558]OK
[2023-01-12_18:02:46:584]
[2023-01-12_18:02:46:584]+CSCON: 1
[2023-01-12_18:02:51:972]
[2023-01-12_18:02:51:972]+IP: 10.210.68.199

[2023-01-12_18:02:51:972]+CEREG: 5
[2023-01-12_18:02:52:975]AT+CSCON?

[2023-01-12_18:02:52:975]+CSCON: 1,1

[2023-01-12_18:02:52:975]OK
[2023-01-12_18:02:56:377]AT+QDRX?

[2023-01-12_18:02:56:377]+QDRX: 2,3,4,94,7,4,2

[2023-01-12_18:02:56:377]OK
[2023-01-12_18:03:00:316]AT+CEDRXRDP

[2023-01-12_18:03:00:316]+CEDRXRDP: 5,"0011","0011","0011"

[2023-01-12_18:03:00:316]OK
[2023-01-12_18:03:02:373]
[2023-01-12_18:03:02:373]+CSCON: 0
[2023-01-12_18:03:04:594]AT+QPSMS?

[2023-01-12_18:03:04:594]+QPSMS: 1,1116000

[2023-01-12_18:03:04:594]OK
[2023-01-12_18:03:07:077]AT+CPSMS?

[2023-01-12_18:03:07:077]+CPSMS: 0,,,"01000001","00000101"

[2023-01-12_18:03:07:077]OK
[2023-01-12_18:03:26:631]AT+QSCLK=1

[2023-01-12_18:03:26:631]OK
[2023-01-12_18:03:31:664]
[2023-01-12_18:03:31:664]+QNBIOTEVENT: "ENTER DEEPSLEEP"
[2023-01-12_18:03:32:022]
[2023-01-12_18:03:32:022]+QNBIOTEVENT: "EXIT DEEPSLEEP"
[2023-01-12_18:04:02:403]
[2023-01-12_18:04:02:403]RDY
[2023-01-12_18:04:02:744]
[2023-01-12_18:04:02:744]+CFUN: 1
[2023-01-12_18:04:02:807]
[2023-01-12_18:04:02:807]+CPIN: READY

[2023-01-12_18:04:02:807]+CEREG: 2
[2023-01-12_18:04:03:385]
[2023-01-12_18:04:03:385]+CSCON: 1
[2023-01-12_18:04:07:135]
[2023-01-12_18:04:07:135]+IP: 10.210.68.199

[2023-01-12_18:04:07:135]+CEREG: 5
[2023-01-12_18:04:17:394]
[2023-01-12_18:04:17:394]+CSCON: 0
[2023-01-12_18:04:17:516]ÿ
[2023-01-12_18:04:27:566]+QNBIOTEVENT: "ENTER DEEPSLEEP"
[2023-01-12_18:04:27:940]
[2023-01-12_18:04:27:940]+QNBIOTEVENT: "EXIT DEEPSLEEP"

@herbert.pan-Q any help or suggestion would be appreciated?

Please check whether the mcu Tx pin is in a high resistance state or provide your schematic diagram

Hi, what MCU Pin? You mean the module’s main uart TX?

So I tested again, and with much effort, I could enter the module in PSM state but that is for the case of the Standalone module (Not Open SDK). However even module is in PSM state, it won’t enter deep sleep, I disabled RDX wakeup, enabled dsEvent, enabled PSM (TAU > 1h), and disabled eDRX (That also gets disabled on PSM), but don’t receive ENTER DEEPSLEEP Event?

As for the Open solution, When the module has entered PSM, the module won’t go into a deep sleep, the modem was idle, and the application has no other task, I could send a command via QCOM (through main uart handler in application), and following states are detected.

[2023-01-14_22:35:16:467]at command : AT+QSCLK?
[2023-01-14_22:35:16:467] 
[2023-01-14_22:35:16:467][ATMainResponse_Handler] 
[2023-01-14_22:35:16:467]+QSCLK: 1
[2023-01-14_22:35:16:467]OK

[2023-01-14_22:35:23:702]at command : AT+CEREG?
[2023-01-14_22:35:23:702] 
[2023-01-14_22:35:23:702][ATMainResponse_Handler] 
[2023-01-14_22:35:23:702]+CEREG: 1,5
[2023-01-14_22:35:23:702]OK

[2023-01-14_22:35:25:507]at command : AT+CSCON?
[2023-01-14_22:35:25:507] 
[2023-01-14_22:35:25:507][ATMainResponse_Handler] 
[2023-01-14_22:35:25:507]+CSCON: 1,0
[2023-01-14_22:35:25:507]OK

[2023-01-14_22:35:28:493]at command : AT+CFUN?
[2023-01-14_22:35:28:493] 
[2023-01-14_22:35:28:493][ATMainResponse_Handler] 
[2023-01-14_22:35:28:493]+CFUN: 1
[2023-01-14_22:35:28:493]OK

[2023-01-14_22:35:34:680]at command : AT+QCFG="wakeupRXD"
[2023-01-14_22:35:34:680] 
[2023-01-14_22:35:34:680][ATMainResponse_Handler] 
[2023-01-14_22:35:34:680]+QCFG: "wakeupRXD",0
[2023-01-14_22:35:34:680]OK

[2023-01-14_22:35:37:150]at command : AT+QNBIOTEVENT?
[2023-01-14_22:35:37:150] 
[2023-01-14_22:35:37:150][ATMainResponse_Handler] 
[2023-01-14_22:35:37:150]+QNBIOTEVENT: 1,1
[2023-01-14_22:35:37:150]OK

[2023-01-14_22:35:42:038]at command : AT+CEDRXRDP
[2023-01-14_22:35:42:038] 
[2023-01-14_22:35:42:038][ATMainResponse_Handler] 
[2023-01-14_22:35:42:038]+CEDRXRDP: 0
[2023-01-14_22:35:42:038]OK

[2023-01-14_22:35:44:759]at command : AT+CPSMS?
[2023-01-14_22:35:44:759] 
[2023-01-14_22:35:44:759][ATMainResponse_Handler] 
[2023-01-14_22:35:44:759]+CPSMS: 1,,,"00101100","00000011"
[2023-01-14_22:35:44:759]OK

[2023-01-14_22:35:53:270]at command : AT+CGPADDR?
[2023-01-14_22:35:53:270] 
[2023-01-14_22:35:53:270][ATMainResponse_Handler] 
[2023-01-14_22:35:53:270]+CGPADDR: 0,"10.210.68.199"
[2023-01-14_22:35:53:270]OK

[2023-01-14_22:35:58:983]at command : AT+QPLMNS?
[2023-01-14_22:35:58:983] 
[2023-01-14_22:35:58:983][ATMainResponse_Handler] 
[2023-01-14_22:35:58:983]+QPLMNS: 2
[2023-01-14_22:35:58:983]OK

[2023-01-14_22:36:05:213]at command : AT+QENG=3
[2023-01-14_22:36:05:213] 
[2023-01-14_22:36:05:213][ATMainResponse_Handler] 
[2023-01-14_22:36:05:213]+QENG: 4,"REG","PSM","SELECTED","UNKNOWN","0x232,0xf003"
[2023-01-14_22:36:05:213]OK

[2023-01-14_22:36:19:923]at command: AT+QSCLK=1
[2023-01-14_22:36:19:923] 
[2023-01-14_22:36:19:923][ATMainResponse_Handler] 
[2023-01-14_22:36:19:923]OK

The fact it’s still receiving commands means the module is not in deep sleep, though it is in a state which is suitable to go to sleep.

please comment.
Regards.

I cannot determine the possible cause from your log, please grab the debug log for analysis
https://quectel123-my.sharepoint.cn/:u:/g/personal/ae-fae_dom_quectel_com_cn/EYHT6raCxyVAq2YDKGkT9T8B_wqj3bdd15Wsuue5qTTSbQ?e=XTSevY
Quectel_GENIE操作指导与参考(CN&EN)_BC20&BC26&BC66.pdf (2.0 MB)

Did you use the transistor level shifter? if so, the unit will never enter low power mode (when VDD_EXT goes low, it causes a transition on TXD which in turn wakes the unit up). You need to remove the level shifter and use the VIO_SEL pin instead.
Simon

Hi BetaEngineer1992

Did you ever get to the bottom of why BC660K_GL was not going into deepsleep. Our module seems to go to sleep 98% of the time but not on the other 2%.

All running threads are stopped and we call the Ql_SleepEnable() and we get the following message on those instance when it works +QNBIOTEVENT: “ENTER DEEPSLEEP”

We need the module to be in deepsleep as we have to wake up the BC660 with an external micro using the PSM_EINT0 pin.

Are there known ways that one can test to see if the device has entered deepsleep?

Many thanks in advance
Ola

Hi,
Good for you, I have not been able to figure out how to put it into a deep sleep. I am using PSM mode as well, after communication, all the work is done, and the program should enter PSM and then DEEP SLEEP, but it does not, instead sometimes it gives ENTER DEEPSLEEP message but then resets somehow, maybe something is wrong with my code.

You can put something in a deep sleep handler to know when it had entered deep sleep, and the other way is to monitor power consumption. I only know about these methods.

Regards.

Is your project based on BC660K-GL_QuecOpen_NB5_SDK_V1.1 ?

BetaEngineer1992,

Sorry I did not notice that your replied. Thank you for reply. Yes I am monitoring the power to know that it has not gone into deep sleep and also additional looking out for the +QNBIOTEVENT: “ENTER DEEPSLEEP” message that comes from the registered handler for Ql_DeepSleep_Registers(handler).

When I see this message, the power consumption is consistent with low power usage.

Regards

Hi herbert.pan-Q

No I am using project based on BC660K-GL_QuecOpen_NB5_SDK_V1.0.

Do you recommend going to v1.1 do you know if there are significant difference to the API as I don’t want to have to rewrite code at this late stage of our project.

Regaads

Well, you don’t need to upgrade the SDK if your current requirements are met

hi herbert.pan-Q,

Thanks for your reply.
I would not go as far as saying my requirements are met as I am still experiencing the device not always going into DEEP SLEEP 100% of the time when expected to do so.

Hi, Ola.oni,
Have you had any success in putting the device into deep sleep?

I have not been successful. When CPSMS is 0, I don’t activate it, it does go to sleep after doing CFUN0, which sends CSCON 0 urc and then enables sleep, so it is ok.

However, I need to activate PSM, but while doing so, I enable CPSMS timers and get CEREG,4 urc response which states that timers are set, after a few seconds, it does give CSCON 0, but never gives ENTER PSM event. So after CSCON0, I put it into sleep mode, and the deep sleep handler does give an indication that the module has gone to sleep, however in just 2-3s it wakes up again (reset). This happened only for PSM mode active, for inactive PSM, sleep works.

I did try sending QNBIOTRAI 0 and 1 with CPSMS:1 command and with PING, but the result was the same.

@herbert.pan-Q any help regarding this will be appreciated.

Best Regards.

void Deepsleep_Handler(u8* buffer, u32 length)
{
    /*****************************************************************
    * Ql_Data_DirectSend is only used here
    * Warning:do not use Ql_UART_Write or APP_DEBUG here!!!
    ******************************************************************/
    Ql_Data_DirectSend(PORT_DBG_LOG,buffer,length);
}

void Enter_Deep_Sleep(void)
{
    APP_DEBUG("Enter_Deep_Sleep()\r\n");
	
    // Kill any other tasks and timers that may be running at this point. I found that if there are any
    // timers running then the device will not enter deep sleep.

    Ql_SleepDisable();  // no longer returns a value in BC660

    for(int ctr=0; ctr<5; ctr++)
    {
        osDelay(100);
    }

    s32 res = RIL_NW_SetCFUN(0);
    if (RIL_AT_SUCCESS != res)
    {
        APP_DEBUG("Enter_Deep_Sleep(): error calling RIL_NW_SetCFUN(0) [%d]. Retrying once.\r\n", res);
        res = RIL_NW_SetCFUN(0);
    }
    if (RIL_AT_SUCCESS == res)
    {
        APP_DEBUG("Enter_Deep_Sleep(): RIL_NW_SetCFUN(0) okay\r\n");
    }

    const char strCpsmsOn[] = "AT+CPSMS=1\0";
    res = Ql_RIL_SendATCmd((char*)strCpsmsOn, strlen(strCpsmsOn), NULL, NULL, 0);
    if (RIL_AT_SUCCESS != res)
    {
        APP_DEBUG("Enter_Deep_Sleep(): error calling AT+CPSMS=1 [%d]. Retrying once.\r\n", res);
        res = Ql_RIL_SendATCmd((char*)strCpsmsOn, strlen(strCpsmsOn), NULL, NULL, 0);
    }
    if (RIL_AT_SUCCESS == res)
    {
        APP_DEBUG("Enter_Deep_Sleep(): AT+CPSMS=1 okay\r\n");
    }

	osMessageQueueReset(main_queue_id);
	osDelay(100);
	Ql_SleepEnable();
}

void proc_main_task(void)
{
       // other code removed for brevity
       s32 rv = Ql_DeepSleep_Register(Deepsleep_Handler);

       while (1)
       {
            if(osOK == osMessageQueueGet(main_queue_id,(void*)&msg, NULL, osWaitForever))
            switch(msg.message)
            { 
            case ENTER_DEEP_SLEEP:
                Enter_Deep_Sleep();
                break; 
            // handle other cases
            }
      }
}

Hi Beta-Engineer,
I hope the above code can be of some help. This is the format that I have followed. 98% of the time the device would go into deep sleep. The confirmation that I used to determine when in deep sleep is that I see the following message +QNBIOTEVENT: “ENTER DEEPSLEEP on the main UART and then monitor the current consumption which drops significantly.

Once the BC660 is in deep sleep mode, we wake up the device by pulling down the PSM_EINT0 pin by an external microcontroller. If the BC660 does not go into deep sleep mode then pulling downn the PSM_EINT0 has no effect.

During testing we did find that the Ql_GetWakeUpReason() does not always return the correct reason for waking up. Most time after waking up by pulling down the PSM_EINT0 pin the function will return QL_PSM_EINT0_WAKEUP as a reason and on the odd times it would return QL_SOFT_RESET.

I was not able to to get to the button of the reason for this behaviour so I just had to find a work around due to meet slipped deadline.

I found that it is very important that before attempting to enter deep sleep that you suspend all timers and tasks that the system may be using.

Regards
Ola

You need to provide debug logs for analysis
Quectel_EPAT操作指导与参考(CN&EN)_BC260Y&BC660K&BC28F&BC95GF&BC300Y.pdf (2.1 MB)
EPAT_V1.2.86.122.zip

Hi,
thanks for sharing this info.
Sorry for the late reply. I solved the issue.
Now module can go to sleep either with CFUN0 or with PSM enabled.
The only issue is that you have to make sure the module is idle and release the connection after PSM.
Unfortunately, SDK does not have support for ENTER PSM or EXIT PSM urc, so I after implemented them, I can get the URC and then do sleep_enable and it works fine.
Sometimes, it does not go to sleep (very rarely), that’s because PSM requires network responses and sometimes it takes longer. but mostly the result of PSM is after a few seconds.

Another thing, you mentioned that Ql_GetWakeUpReason function does not always give the correct reason.
I am also experiencing this.
I have rtc set up to wake the module. Mostly it works fine, but sometimes it says QL_SOFT_RESET instead of QL_RTC_WAKE. But I thought maybe the module was experiencing reset before waking up, and not that Ql_GetWakeUpReason has any issues. So I have been trying to figure out why it’s having reset instead of waking up normally.
Maybe @herbert.pan-Q can highlight the reason if the module is getting reset or the Ql_GetWakeUpReason function has some bugs.

Best Regards.