ESP register access



  • Hi folks,

    I try to use P20 of Gpy as a digital input but the pin is constantly read as zero. There is an external pull-up and the pin is configured for input, too. The other pins around are working perfectly.

    According to the manual P20 is internally connected to GPIO33 of the ESP. And there appears to be a configuration problem regarding the RTC (realtime clock).

    I need to do something like (C-Code):

    /* gpio33 route to digital io_mux */
    REG_CLR_BIT(RTC_IO_XTAL_32K_PAD_REG, RTC_IO_X32N_MUX_SEL);

    in micropython. Is that possible?

    Via uctypes? Inline-Assembler? Any ideas?

    Or, to ask more general: is it possible to access the ESP32 configuration registers from micropython at all?



  • @Elizar P20 can be used for the XTAL, but you have to attach it. Otherwise you can use it as normal GPIO pin.
    You can access the GPIO registers via machine.mem32.
    hex(machine.mem32[0x3FF44004]) will give you the hex value of the GPIO output register. Writing to it will change the output bits.
    machine.mem32[0x3FF44008] = 0x10 will set GPIO4 (P3) to high, without affecting the other GPIO pins, if it was configure for output.

    See the esp32 reference manual for the set of GPIO registers and it's options.
    Edit: Inline-Assembler or Viper code in not supported by the Pycom dialect of MicroPython


Log in to reply
 

Pycom on Twitter