Hi,
I am using sdk 14.2.0 ble_app_hrs_freertos example.
two threads i have created, threads are having nested loop inside.
for this case, thread is stucking inside loop.
and if i simply put delay in thread, it seems both threads are working one by one (synchronously).
lets say i am printing a statment inside thread1 aftre each 1 sec, and other statment inside thread after each 1 sec.
then both threads statments are printing after each 2 sec.(instead of each 1 sec).
here's the code snippet:
if (pdPASS != xTaskCreate(led_thread, "LED", 256, NULL, 1, &m_led_thread))
{
APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
}
if (pdPASS != xTaskCreate(vib_motor_thread, "VIB_MOTOR", 256, NULL, 1, &m_vib_motor_thread))
{
APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
}
// Activate deep sleep mode.
SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
// Start FreeRTOS scheduler.
vTaskStartScheduler();
threads:
static void led_thread(void * arg)
{
UNUSED_PARAMETER(arg);
while (1)
{
// printf("\r\nlog\r\n");
// NRF_LOG_FLUSH();
all_led_off();
printf("\r\nLED OFF \r\n");
nrf_delay_ms(1000);
all_led_on();
printf("\r\nLED ON \r\n");
nrf_delay_ms(1000);
vTaskSuspend(NULL); // Suspend myself
}
}
static void vib_motor_thread(void * arg)
{
UNUSED_PARAMETER(arg);
while(1)
{
pwm_update_duty_cycle(100);
nrf_delay_ms(1000);
pwm_update_duty_cycle(0);
nrf_delay_ms(1000);
pwm_start();
vTaskSuspend(NULL); // Suspend myself
}
}
void vApplicationIdleHook( void )
{
vTaskResume(m_led_thread);
vTaskResume(m_vib_motor_thread);
}
what might be the problem.please guide me.
Thanks,
Amarjeet