Hi.
I have an experience that I do not understand.
<main>
if(pushSwitch == true){
waitSwitch_flag = true;
waitSwitch_cnt = 0;
while(pushSwitch == true){
nrf_delay_ms(10);
if(waitSwitch_cnt >= 50) break;
}
waitSwitch_flag = false;
if(waitSwitch_cnt < 20){
printf("2s\r\n");
}
else if(waitSwitch_cnt >= 50){
printf("5s\r\n");
}
}
<timer handler>
void timer_event_handler(nrf_timer_event_t event_type, void* p_context){
switch (event_type)
{
case NRF_TIMER_EVENT_COMPARE0:
if(waitSwitch_flag == true){
waitSwitch_cnt++;
}
break;
default:
break;
}
}
- "PushSwitch" changed to true when the button was pressed using a switch interrupt.
- While pressing the button, measure the time on the timer.
- If there is no delay in the while statement, the time is not counted.
Even if the button is held down for a long time, only "2s" is output. - When I press and release the button, the pairing connection is lost.
It does not always disconnect.
It is strange that it works differently depending on whether there is a delay or not, and suddenly it does not understand that the pairing is cut off.
Do you have the same problem or do you know the cause?
Thank you.