Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Hi Guys,
- this is my first forum thread.
- If I am doing something against the forum rules, please inform me and I will correct it.
- My difficulty is ESP32 port manipulation .
- I'm using a DOIT ESP32 DEVKIT V1 board with the arduino IDE.
- For write a sketch I got information from the ESP32 Technical Reference Manual Version 4.2
- 5.3.3 Simple GPIO Output
- The GPIO Matrix can also be used for simple GPIO output - setting a bit in the GPIO_OUT_DATA register will
- write to the corresponding GPIO pad.
- To configure a pad as simple GPIO output, the GPIO Matrix GPIO_FUNCx_OUT_SEL register is configured with a special peripheral index value (0x100).
- I wrote this test sketch.
- void setup ()
- {
- REG_WRITE (GPIO_ENABLE_REG, BIT13); // Define GPIO13 as output
- REG_WRITE (GPIO_FUNC2_OUT_SEL_CFG_REG, 0x100); // Special peripheral index value (0x100)
- REG_WRITE (GPIO_ENABLE_REG, BIT2); // Define GPIO2 as output
- REG_WRITE (GPIO_FUNC13_OUT_SEL_CFG_REG, 0x100); // Special peripheral index value (0x100)
- }
- void loop ()
- {
- REG_WRITE (GPIO_OUT_W1TS_REG, BIT2); // GPIO2 HIGH (set)
- REG_WRITE (GPIO_OUT_W1TS_REG, BIT13); // GPIO13 HIGH (set)
- delay (50);
- REG_WRITE (GPIO_OUT_W1TC_REG, BIT2); // GPIO2 LOW (clear)
- REG_WRITE (GPIO_OUT_W1TS_REG, BIT13); // GPIO13 LOW (clear)
- delay (50);
- }
- In this way it works normally and the BUILT_IN LED blinks.
- But if I change the setup () lines , spinning as below, doesn't work.
- REG_WRITE (GPIO_ENABLE_REG, BIT2); // Define GPIO2 as output
- REG_WRITE (GPIO_FUNC2_OUT_SEL_CFG_REG, 0x100); // Special peripheral index value (0x100)
- REG_WRITE (GPIO_ENABLE_REG, BIT13); // Define GPI13 as output
- REG_WRITE (GPIO_FUNC13_OUT_SEL_CFG_REG, 0x100); // Special peripheral index value (0x100)
- I ask where I'm going wrong.
- Best regards
- mRV
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement