RuiViana

MsgESP32

Sep 10th, 2020 (edited)
970
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Hi Guys,
  2. this is my first forum thread.
  3. If I am doing something against the forum rules, please inform me and I will correct it.
  4.  
  5. My difficulty is  ESP32 port manipulation .
  6.  
  7. I'm using a DOIT ESP32 DEVKIT V1 board with the arduino IDE.
  8.  
  9. For write a sketch I got information from the ESP32 Technical Reference Manual Version 4.2
  10.  
  11.  5.3.3 Simple GPIO Output
  12.  
  13.  The GPIO Matrix can also be used for simple GPIO output - setting a bit in the GPIO_OUT_DATA register will
  14.  write to the corresponding GPIO pad.
  15.  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).
  16.  
  17. I wrote this test sketch.
  18.  
  19. void setup ()
  20.  {
  21.  REG_WRITE (GPIO_ENABLE_REG, BIT13); // Define GPIO13 as output
  22.  REG_WRITE (GPIO_FUNC2_OUT_SEL_CFG_REG, 0x100); // Special peripheral index value (0x100)
  23.  REG_WRITE (GPIO_ENABLE_REG, BIT2); // Define GPIO2 as output
  24.  REG_WRITE (GPIO_FUNC13_OUT_SEL_CFG_REG, 0x100); // Special peripheral index value (0x100)
  25. }
  26.  
  27. void loop ()
  28. {
  29.  REG_WRITE (GPIO_OUT_W1TS_REG, BIT2); // GPIO2 HIGH (set)
  30.  REG_WRITE (GPIO_OUT_W1TS_REG, BIT13); // GPIO13 HIGH (set)
  31.  delay (50);
  32.  REG_WRITE (GPIO_OUT_W1TC_REG, BIT2); // GPIO2 LOW (clear)
  33.  REG_WRITE (GPIO_OUT_W1TS_REG, BIT13); // GPIO13 LOW (clear)
  34.  delay (50);
  35. }
  36.  
  37. In this way it works normally and the BUILT_IN LED blinks.
  38.  
  39. But if I change the setup () lines , spinning as below, doesn't work.
  40.  
  41.   REG_WRITE (GPIO_ENABLE_REG, BIT2); // Define GPIO2 as output
  42.   REG_WRITE (GPIO_FUNC2_OUT_SEL_CFG_REG, 0x100); // Special peripheral index value (0x100)
  43.   REG_WRITE (GPIO_ENABLE_REG, BIT13); // Define GPI13 as output
  44.   REG_WRITE (GPIO_FUNC13_OUT_SEL_CFG_REG, 0x100); // Special peripheral index value (0x100)
  45.  
  46. I ask where I'm going wrong.
  47. Best regards
  48. mRV
  49.  
RAW Paste Data