Hello
I used sdk v17.0 and nRF52DK.
I wrote a code that can turn on/off various functions using buttons and apps. And I don't think there's a problem up to here.
And by creating a new timer, I am going to create a function that shuts down power if there is no input on the MCU for a certain period of time.
This is a simple timer whose count increases every second. However, adding this timer will cause the board to stop if the button or app repeatedly executes one function several times.
(No errors were output from debugging.)
This is the app_timer I added.
static void SleepMode_timer_handler(void * p_context) //1sec
{
//printf("%d\n", sleep_count);
//sleep_count++;
if(!cleaning_state && !UVC_state) //if no running cleaning and uvc led
{
sleep_count++;
}
else //if running cleaning or uvc led
{
sleep_count = 0; //No count
}
if(sleep_count > 60) //if idle state during 1min, power off
{
printf("Power Off..\n");
do_play_buzzer();
/* power off code */
}
}
static void timers_init(void)
{
ret_code_t err_code;
// Initialize timer module.
err_code = app_timer_init();
APP_ERROR_CHECK(err_code);
//Create Sleep Mode timers/
err_code = app_timer_create(&m_SleepMode_timer_id,
APP_TIMER_MODE_REPEATED,
SleepMode_timer_handler);
APP_ERROR_CHECK(err_code);
}
static void SleepMode_timers_start()
{
ret_code_t err_code;
printf("SleepMode_timers_start \n");
err_code = app_timer_start(m_SleepMode_timer_id, APP_TIMER_TICKS(1000), NULL);
APP_ERROR_CHECK(err_code);
}
int main()
{
.
.
.
SleepMode_timers_start(); //timer start
}
6371.nRF5_SDK_17.0.0_9d13099.zip
I attached my entire code file because I couldn't find the cause of the problem.
Thank you in advance for your help.