Init 7 seg display on esp32 gpios
Posted: Tue Jun 29, 2021 5:22 pm
How can I run a seven-segment indicator on gpio esp32 without using additional ICs at 2000 Hz and above?
I tried to use the xtensa timer, but the indication was not work at frequencies more than 1500 Hz.
Enabled: wi fi, web server, adc, ssl connection.
Chip: ESP32 Pico D4 @ 240 MHz
Timer initialization example:
Timer interrupt handler example:
I tried to use the xtensa timer, but the indication was not work at frequencies more than 1500 Hz.
Enabled: wi fi, web server, adc, ssl connection.
Chip: ESP32 Pico D4 @ 240 MHz
Timer initialization example:
Code: Select all
#define TIMER_DIVIDER (80)
#define TIMER_ALARM_VALUE 1000
timer_config_t config = {
.divider = TIMER_DIVIDER,
.counter_dir = TIMER_COUNT_UP,
.counter_en = TIMER_START,
.alarm_en = TIMER_ALARM_EN,
.auto_reload = TIMER_AUTORELOAD_EN,
};
timer_init(TIMER_GROUP_0, TIMER_0, &config);
timer_set_counter_value(TIMER_GROUP_0, TIMER_0, 0x00000000ULL);
timer_set_alarm_value(TIMER_GROUP_0, TIMER_0, TIMER_ALARM_VALUE);
timer_enable_intr(TIMER_GROUP_0, TIMER_0);
timer_isr_register(TIMER_GROUP_0, TIMER_0, timer_group0_isr,
NULL, ESP_INTR_FLAG_IRAM, NULL);
Code: Select all
void IRAM_ATTR timer_group0_isr(void *para){
portMUX_TYPE timeCriticalMutex = portMUX_INITIALIZER_UNLOCKED;
portENTER_CRITICAL(&timeCriticalMutex);
/* 7 seg digit select and port write */
timer_group_enable_alarm_in_isr(TIMER_GROUP_0, TIMER_0);
timer_group_clr_intr_status_in_isr(TIMER_GROUP_0, TIMER_0);
ets_delay_us(10);
portEXIT_CRITICAL(&timeCriticalMutex);
}