Direct ESP32 register access

Thread Starter

Vilius_Zalenas

Joined Jul 24, 2022
159
Hi,

I am doing my first project (learning phase for now) with ESP WROOM 32. I am using ESPIDF framework on visual studio code, but I still consider a good practise to learn direct register operations, not only blindly using built-in commands (especially for GPIO). I have been reading the datasheet for quite some time, but I can not implement what is written there: https://www.espressif.com/sites/default/files/documentation/esp32_technical_reference_manual_en.pdf
Page 52, 4.3.3 Simple GPIO Output (I tried to do this) The compiler treats register names as undeclared functions. I know that there is definitely a way to perform the direct register read or write somehow... Is it just my faulty syntax or do you have to dig deeper into the framework? I really hope that you still have the choice to use build-in functions and register manipulation as well. Thank you in advance for any help reaching the bare register directly...
My code:


C:
#include <stdio.h>
#include <stdint.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/gpio.h"

//I want to toggle GPIO pin 2

void app_main() {

    GPIO_FUNC2_OUT_SEL_CFG_REG = 0x100; //This step is provided in the datasheet
    
    while (1) {

        GPIO_OUT_DATA |= (1 << 2);
      
        vTaskDelay(1000 / portTICK_PERIOD_MS);

        GPIO_OUT_DATA &= ~(1 << 2);
        
        vTaskDelay(1000 / portTICK_PERIOD_MS);
    }
}
 

Thread Starter

Vilius_Zalenas

Joined Jul 24, 2022
159
Sorry, can't help you much. But here is another thread where you may find some more info:

You can also post your question to the ESP32 forum.
I am waiting for the first post moderator approval in esp32 forum :) However, that thread does not help me much, because they are discussing the process (I am not there yet...) The thing is that my register names are not even recognized by the compiler. All I need for now is just a few lines of code on how to actually call the register...
 
Last edited by a moderator:
Top