Other Parts Discussed in Thread: LP-EM-CC2340R5, CC2340R5
Hi all,
I want to put CC2340 on sleep mode and wake up the device through GPIO.
Can I get any example code and documentation?
Regards,
Aslam
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi all,
I want to put CC2340 on sleep mode and wake up the device through GPIO.
Can I get any example code and documentation?
Regards,
Aslam
Hello Mohamed,
Please refer to these two documents linked here:
GPIO Interrupt toggles an LED depending on a button toggle.
GPIO Shutdown moves the device into shutdown from a button toggle.
Within the SDK there is two example programs (gpioshutdown, gpiointerrupt) show how this is done. Based on this, you can adjust the code to toggle shutdown based on button inputs and individual GPIO inputs. I will provide direct links to these example programs below.
GPIO Interrupt Example Program
Let me know if you have any more questions!
Thanks,
Isaac
Hi Issac,
Thanks for the suggestion.
This method is working fine but I have an issue.
This method is not working for the project which having the OTA support. The device is going to shut down, but it is not waking up. I think it stuck in the bootloader.
Do you have any solution for this issue?
Is there any other sleep mode available that I could manually instruct the device to sleep mode and manually wake up the device? (like shutdown mode)
Regards,
Aslam
Hello Mohamed,
By OTA do you mean Over the Air Download, or a BLE example project? Could you give me some more information on the use and the SDK version?
In the meantime, I will link another API below that is used for putting the device into sleep. Let me know if this fixes your problem, or if you have any more questions/concerns.
Thanks,
Isaac
Hello Issac,
Yes, the problem is in Over the Air Download project.
I am testing in LP-EM-CC2340R5 (Same issue happened in my custom board also)
I am using SDK simplelink_lowpower_f3_sdk_7_40_00_64.
For the basic_ble_LP_EM_CC2340R5_freertos_ticlang project, shutdown and wakeup is happening properly.
But for the OAD project (basic_ble_oad_offchip_LP_EM_CC2340R5_freertos_ticlang), Shutdown is happening but wake up through GPIO is not happening. I think, it is stuck in the bootloader. I am using mcuboot_offchip_LP_EM_CC2340R5_nortos_ticlang.hex from the SDK as the bootloader.
Can you please check this scenario in your end and provide us solution for this issue?
I have checked in the power analyzer with my custom board, when pressing the wakeup button during shutdown condition, current is shifting from 300 uA to 2.6 mA meaning wake up is happening but my application is not running at all. I am suspecting after the wake up, it somehow stuck in bootloader.
And regarding power sleep API, can you provide any example? Is wake up through GPIO available in Power sleep?
(Power shutdown method is most likely will meet our sleep current requirement. Please provide us solution for the above issue)
Regards,
Aslam
Hello Aslam,
I am currently working on replicating your issue on my end. I will be able to get back to you on Tuesday next week.
In the meantime, could you provide me with the program you are using?
I apologize for the inconvenience.
Thanks,
Isaac
Hi Issac,
I think I found out the issue.
We have to call the PowerLPF3_releaseLatches() function in the bootloader. Please see the below code snippets that I have added in mcuboot project.
/* * ======== mainThread ======== */ int main(void) { fih_int bootStatus; struct boot_rsp bootRsp; PowerLPF3_ResetReason resetReason = PowerLPF3_getResetReason(); //If we are waking up from shutdown, we do something extra. if (resetReason == PowerLPF3_RESET_SHUTDOWN_IO) { //Application code must always disable the IO latches when coming out of shutdown PowerLPF3_releaseLatches(); } #ifndef EXCLUDE_GPIOS powerUpGpio(); lightRedLed(); #endif //EXCLUDE_GPIOS
This function should be called after waking up from shutdown to avoid any glitches. Since during the wake-up bootloader only run first in OAD project, we have to call the PowerLPF3_releaseLatches() function.
But I have a one issue. During the wake up If we call the PowerLPF3_releaseLatches() function in the bootloader, my application will not know whether it is waking up from shutdown or Power on RESET.
So, I am planning to write some magic ID in external flash before going to shut down, so my application also will know it is waking up from shutdown or Power on RESET.
So, I want to how much space basic_ble_oad_offchip project is using from the 1MB external flash.
From which sector, we can write the user information in the external flash.
Is there any way to restrict the space used by the basic_ble_oad_offchip project in the 1MB external flash?
Regards,
Aslam
Hello Aslam,
within the basic_ble_oad_offchip project, features that you are not using can be removed (i.e. Buttons, LEDS). This can help reduce the amount of flash used.
For more information about the off-chip flash please look at the link provided below:
This section of the documentation discusses the memory layout of the off-chip flash.
Additionally, the .map file within the release file in the basic_ble_offchip project will help visualize the flash usage from the application.
Let me know if this helped you and if you have any more questions!
Thanks,
Isaac