Hi, Dialog,
I have a question about how to allow peripheral interrupt in the while loop in main_func() in ble_app_all_in_one project in DA1458x_SDK sample.
As sample code, under the normal condition if (BLE_APP_PRESENT), always GLOBAL_INT_STOP() is called.
I guess if IRQ is always disabled in the infinite loop, any normal peripheral interrupt are never detected, is it right?
年代o if you use some peripheral interrupt, I think you should delete the GLOBAL_INT_STOP().
And I feel strange that WFI() is called in the if (BLE_APP_PRESENT) clause, so why IRQ must be disabled.
Is it right or are there any other ways to allow peripheral interrupt in main loop?
I'm looking forward someone's good answers.
Best,
Device:
Hi diogenes,
The GLOBAL_INT_STOP() macro is used when the system wants to disable all the interrupt it could handle. This macro is called just before the device enters the sleep, and not when it is in sleep mode. This means that after this macro, the system will be continuing to receive interrupts, but only the handlers of the interrupts will no be triggered. The WFI() is called while the interrupts are disabled to have performed the checks necessary to decide to move to sleep mode. If there are any pending interrupts before sleep, the GLOBAL_INT_START() will be triggered and the interrupts can start being handled again by the system. So, your conclusion that if IRQ is always disabled in the infinite loop, any normal peripheral interrupt are never detected, is incorrect and it is strongly recommended to not remove the GLOBAL_INT_STOP(). Also, be aware that if the device is in sleep mode, it can be woken up only from the wake-up controller, and by any other interrupt because all the peripheral block are shut down.
Thanks, PM_Dialog