I'm using nRF connect SDK2.9.0. I don't create my threads. Instead, I have a GPIO interrupt and a k_timer interrupt, each doing their own job.
In my timer expiry function, I submit a work to the workqueue that do temperature sensing and PID control.
// Timer structure static struct k_timer my_timer; // thread context: temperature control and data transmission (temperature and ad5940) static void temprt_work_handler(struct k_work *work); K_WORK_DEFINE(temprt_work, temprt_work_handler); // thread context: read ad5940 data static void ECAFE_work_handler(struct k_work *work); K_WORK_DEFINE(ECAFE_work, ECAFE_work_handler); // Timer callback function // timer callback should not do too much operation, otherwise will block other functions like ADC read void timer_expiry_function(struct k_timer *timer_id) { // Do minimal, non-blocking things here, then submit work. k_work_submit(&temprt_work); } static void temprt_work_handler(struct k_work *work) { uint64_t time_stamp; int64_t delta_time; time_stamp = k_uptime_get(); log_count++; // LOG_INF("Timer callback triggered! Count = %d\n", log_count); // Add your processing here (e.g., reading the ADC) float adc_temp_reading = fetch_adc_value(); // PID operations... k_yield(); } static void ECAFE_work_handler(struct k_work *work){ DataCount = APPBUFF_SIZE; //Deal with it and provide a buffer to store data we got AppAMPISR(AppBuff, &DataCount); //Show the results to UART AMPShowResult((float*)AppBuff, DataCount); k_yield(); }
In contrast, I didn't submit my work directly in my GPIO interrupt callback handler. Instead, I set a global flag to 1 interrupt callback handler, and inspect the flag in the main loop:
while (1) { /* Check if interrupt flag which will be set when interrupt occurred. */ if(AD5940_GetMCUIntFlag()) { AD5940_ClrMCUIntFlag(); /* Clear this flag */ LOG_INF("AD5940 INT flag on\n"); k_work_submit(&ECAFE_work); } //k_sleep(K_MSEC(delay_in_ms)); k_usleep(200); }
Now, my problem is that if I enable BLE, my k_timer work is executed properly, but my ECAFE_work is never executed, although I can see the GPIO interrupt triggered and flag is set to 1. It seems that the flag inspection part in my main-loop is never executed.
In my prj.conf I didn't set anything related to thread and priority. I'm wondering what's the default priority for my work queue and for the BLE? Could you help me identify the problem? Thank you very much.