I'm developing a project that use BLE advertise and uart communication with other uC.
The uart part is based on libuarte example. To decrease the current consumption, I think we must uninit uarte before system sleep, then reinitialize it when wakeup.
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
void uc_deInit()
{
if(uartInited){
nrf_libuarte_async_uninit(&libuarte);
//when uarte inited then uninit, current consumption keep higher about 0.8ma, workarounds below
//@refers https://devzone.nordicsemi.com/f/nordic-q-a/26030/how-to-reach-nrf52840-uarte-current-supply-specification/102605#102605
//If you are using UARTE1 the base address is 0x40028000
*(volatile uint32_t *)0x40002FFC = 0;
*(volatile uint32_t *)0x40002FFC;
*(volatile uint32_t *)0x40002FFC = 1;
}
uartInited = false;
}
void uc_init()
{
ret_code_t err_code;
uc_deInit();
Everything works before first sleep, when uc_deInit() executed then uc_init(), the NRF stop receiving but transmit works, I can confirm the UC received the NRF tx packet and response, but uart_event_handler never triggered.
So, what is the correct procedure for my purpose?
Thanks.