Sofware interrupt
Posted: Fri Jun 23, 2023 2:30 pm
Hello, I am new to ESP32-C3 and try to find example using ESP-IDF to generate software interrupt in ESP32-C3 but I cant find anywhere. So I am trying to make a very simple example problem: Print "Hello" to screen using software interrupt (generated every second).
However, my code is not work. Can you guy help me to debug this? Thank you in advance
Here is my code
[Codebox]#include <stdio.h>
#include "include/soc/soc.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_types.h"
#include "esp_intr_alloc.h"
#include "soc/periph_defs.h"
// Timer interval in microseconds
#define TIMER_INTERVAL 1000000
void IRAM_ATTR cbs(void* arg)
{
printf("Hello");
REG_CLR_BIT(SYSTEM_CPU_INTR_FROM_CPU_0_REG, 0);
}
void app_main()
{
// Allocate sofware interrupt for counting min
intr_handle_t handle;
esp_intr_disable(handle);
esp_intr_alloc(ETS_FROM_CPU_INTR0_SOURCE, ESP_INTR_FLAG_LEVEL1, sw_min_cb, &digital_clock, &handle);
esp_intr_enable(handle);
// Keep the task alive
while (1) {
REG_SET_BIT(SYSTEM_CPU_INTR_FROM_CPU_0_REG, 0);
vTaskDelay(pdMS_TO_TICKS(1000));
}
}
[/Codebox]
However, my code is not work. Can you guy help me to debug this? Thank you in advance
Here is my code
[Codebox]#include <stdio.h>
#include "include/soc/soc.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_types.h"
#include "esp_intr_alloc.h"
#include "soc/periph_defs.h"
// Timer interval in microseconds
#define TIMER_INTERVAL 1000000
void IRAM_ATTR cbs(void* arg)
{
printf("Hello");
REG_CLR_BIT(SYSTEM_CPU_INTR_FROM_CPU_0_REG, 0);
}
void app_main()
{
// Allocate sofware interrupt for counting min
intr_handle_t handle;
esp_intr_disable(handle);
esp_intr_alloc(ETS_FROM_CPU_INTR0_SOURCE, ESP_INTR_FLAG_LEVEL1, sw_min_cb, &digital_clock, &handle);
esp_intr_enable(handle);
// Keep the task alive
while (1) {
REG_SET_BIT(SYSTEM_CPU_INTR_FROM_CPU_0_REG, 0);
vTaskDelay(pdMS_TO_TICKS(1000));
}
}
[/Codebox]