Description
Answers checklist.
- I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
- I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
- I have searched the issue tracker for a similar issue and not found a similar issue.
IDF version.
v5.5-master
Espressif SoC revision.
Chip is ESP32-C6 (QFN40) (revision v0.0)
Operating System used.
Windows
How did you build your project?
Eclipse IDE
If you are using Windows, please specify command line type.
None
Development Kit.
custom board
Power Supply used.
External 3.3V
What is the expected behavior?
The ulp_lp_core_get_wakeup_cause() function should return real wakeup cause, not return all set interrupt sources. Since I use both GPIO and timer wake-up, I need to distinguish which event happened.
What is the actual behavior?
calling
ulp_lp_core_update_wakeup_cause(); uint16_t LPWakeUpReason = ulp_lp_core_get_wakeup_cause();
should return real wakeup reason (as on HP core), but it is returning all posible wakeup causes which happened. It looks like there has to be a function to clear wakeup cause, so it can be set by the HW acordingly.
Steps to reproduce.
#define LED1 2 #define LED2 3 #define INPUT_PIN 7
HP core:
`
void app_main(void){
/* Initialize selected GPIO as RTC IO, enable input, disable pullup and pulldown */
rtc_gpio_init(INPUT_PIN);
rtc_gpio_set_direction(INPUT_PIN, RTC_GPIO_MODE_INPUT_ONLY);
rtc_gpio_pulldown_dis(INPUT_PIN);
rtc_gpio_pullup_en(INPUT_PIN);
ESP_ERROR_CHECK(rtc_gpio_wakeup_enable(INPUT_PIN, GPIO_INTR_ANYEDGE)); // GPIO_INTR_ANYEDGE
rtc_gpio_init(LED1);
rtc_gpio_set_direction(LED1, RTC_GPIO_MODE_OUTPUT_ONLY);
rtc_gpio_pulldown_dis(LED1);
rtc_gpio_pullup_dis(LED1);
rtc_gpio_set_level(LED1, 1);
rtc_gpio_init(LED2);
rtc_gpio_set_direction(LED2, RTC_GPIO_MODE_OUTPUT_ONLY);
rtc_gpio_pulldown_dis(LED2);
rtc_gpio_pullup_dis(LED2);
esp_sleep_wakeup_cause_t cause = esp_sleep_get_wakeup_cause();
printf("HP Reset reason: %d\r\n", (int)cause);
if (cause == ESP_SLEEP_WAKEUP_ULP) {
printf("ULP woke up the main CPU! \r\n");
printf("Logged ULP WakeUp reason: %ld\r\n", ulp_LPWakeUpReason & 0xFFFF);
printf("Pin State: %04X\r\n", (uint16_t)(ulp_PINVal & 0xFFFF));
}
else {
printf("WakeUp %d, initializing ULP! \r\n", cause);
init_ulp_program();
}
/* Go back to sleep, only the ULP will run */
printf("Entering deep sleep\r\n");
uart_wait_tx_done(UART_NUM_0, 100);
rtc_gpio_set_level(LED1, 0);
ESP_ERROR_CHECK(esp_sleep_enable_ulp_wakeup());
esp_deep_sleep_start();
}
`
LP main.c:
`
volatile uint8_t inputPinState = false;
volatile uint16_t LPWakeUpReason = 0;
volatile uint8_t PINVal = 0xFF;
int main (void)
{
ulp_lp_core_gpio_set_level(LED2, 1);
uint32_t NewPinval = ulp_lp_core_gpio_get_level(INPUT_PIN);
if(PINVal == 0 && NewPinval){
PINVal = 0xFF;
inputPinState = true;
}
else if(PINVal && NewPinval == 0){
PINVal = 0;
inputPinState = false;
}
ulp_lp_core_update_wakeup_cause();
LPWakeUpReason = ulp_lp_core_get_wakeup_cause();
ulp_lp_core_gpio_clear_intr_status();
ulp_lp_core_gpio_set_level(LED2, 0);
ulp_lp_core_wakeup_main_processor();
return 0;
}
`
Debug Logs.
`HP Reset reason: 6
ULP woke up the main CPU!
Logged ULP WakeUp reason: 16
Pin State: 0000
Entering deep sleep
HP Reset reason: 6
ULP woke up the main CPU!
Logged ULP WakeUp reason: 16
Pin State: 0000
Entering deep sleep
...
HP Reset reason: 6
ULP woke up the main CPU!
Logged ULP WakeUp reason: 20
Pin State: 00FF
Entering deep sleep
HP Reset reason: 6
ULP woke up the main CPU!
Logged ULP WakeUp reason: 20
Pin State: 00FF
Entering deep sleep
...
HP Reset reason: 6
ULP woke up the main CPU!
Logged ULP WakeUp reason: 20
Pin State: 0000
Entering deep sleep`
Diagnostic report archive.
No response
More Information.
No response