gptimer_get_raw_count crashes

greycon
Posts: 32
Joined: Fri Nov 03, 2023 9:59 pm

gptimer_get_raw_count crashes

Postby greycon » Thu May 16, 2024 2:43 pm

Hi, I have the following task which waits for a notification from a gptimer callback. All works well. But I have added a call to gptimer_get_raw_count, and this triggers an exception. Does anyone have any idea why?

  1. static void timerTask(void *userData) {
  2.     TimerManager *timerManager = (TimerManager *)userData;
  3.     uint32_t notifiedValue;
  4.     uint64_t rawValue;
  5.  
  6.     while (1) {
  7.         showMyStack("timerTask");
  8.         ESP_LOGI(TAG,"timerTask waiting...");
  9.         // RTOS Task to sleep until timer pops.     xTaskGenericNotifyWait(uxIndexToWaitOn, ulBitsToClearOnEntry, ulBitsToClearOnExit, pulNotificationValue, xTicksToWait), bits_exit_clear, value, wait_time)
  10.         xTaskNotifyWaitIndexed( 0, 0x00, ULONG_MAX, &notifiedValue, portMAX_DELAY );
  11.             // Timer popped , notify calling task.
  12.             ESP_LOGI(TAG,"timerTask triggered...");
  13.             gptimer_get_raw_count(gptimer, &rawValue);
  14.             //ESP_LOGI(TAG, "Raw: %llu",rawValue);
  15.  
  16.             xTaskNotifyGive(timerManager->getCurrentTask()->waitingTask);
  17.             taskListManager->deleteTask(timerManager->getCurrentTask()->waitingTask);
  18.             timerManager->clearCurrentTask();
  19.             timerManager->scheduleTasks();
  20.     }
  21. }
The Exception stacktrace shows:
Backtrace: 0x4008e931:0x3ffd71a0 0x401ae52f:0x3ffd71c0 0x400ddf15:0x3ffd71e0 0x4008cdc1:0x3ffd7210
0x4008e931: timer_ll_trigger_soft_capture at /Users/concunningham/Documents/ESPIDF/esp-idf-v5.1.2/components/hal/esp32/include/hal/timer_ll.h:140
(inlined by) timer_hal_capture_and_get_counter_value at /Users/concunningham/Documents/ESPIDF/esp-idf-v5.1.2/components/hal/timer_hal.c:60
0x401ae52f: gptimer_get_raw_count at /Users/concunningham/Documents/ESPIDF/esp-idf-v5.1.2/components/driver/gptimer/gptimer.c:199
0x400ddf15: timerTask(void*) at /Users/concunningham/Documents/git-repos/PharmaSlave/PSMonitor/main/Utilities/TimerManager.cpp:75
0x4008cdc1: vPortTaskWrapper at /Users/concunningham/Documents/ESPIDF/esp-idf-v5.1.2/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:162

greycon
Posts: 32
Joined: Fri Nov 03, 2023 9:59 pm

Re: gptimer_get_raw_count crashes

Postby greycon » Thu May 16, 2024 3:14 pm

My bad - I had disabled and deleted the gptimer before I got to the gptimer_get_raw_count call. All is right with the world. :-)

Who is online

Users browsing this forum: No registered users and 249 guests