How can i FAST send 12 Bit Words parallel with ESP32

Tobi82m
Posts: 23
Joined: Wed Feb 16, 2022 9:10 am

How can i FAST send 12 Bit Words parallel with ESP32

Postby Tobi82m » Wed Feb 16, 2022 9:24 am

Hello,

first, sorry, my english is not the best ;-)

I have to send a 12Bit Word parallel with a ESP32. How can i do this as fast as possible?

It i send it with digitalWrite...i think its very slow. In Arduino i can use port manipulation...i read its also possible with ESP32? The register GPIO_OUT_W1TS_REG ?

What Pins should i need? How would you send the example Word -> 0b 1101 1100 0011 ? Have anyone a example for me? The Bit Word is change continuously and i need fast and continuous timing.

Thanks!

ESP_Sprite
Posts: 9730
Joined: Thu Nov 26, 2015 4:08 am

Re: How can i FAST send 12 Bit Words parallel with ESP32

Postby ESP_Sprite » Wed Feb 16, 2022 9:34 am

Look into the parallel mode of the I2S peripheral.

Tobi82m
Posts: 23
Joined: Wed Feb 16, 2022 9:10 am

Re: How can i FAST send 12 Bit Words parallel with ESP32

Postby Tobi82m » Wed Feb 16, 2022 10:09 am

Thank you. I think its the right for me. But i dont know how to make it. Im looking in the reference manual and examples but i dont know how to send the data.
I have to 12 Bit Ports, so i think i can send a 24bit word at same time. Is there a example?

ESP_Sprite
Posts: 9730
Joined: Thu Nov 26, 2015 4:08 am

Re: How can i FAST send 12 Bit Words parallel with ESP32

Postby ESP_Sprite » Thu Feb 17, 2022 3:49 am

I think you can use the 16-bit mode, that's closest to the 12 bit you need. There's some other projects out there that use the parallel i2s interface (for instance, this one), maybe you can browse through their code for inspiration.

AlfredoSC
Posts: 1
Joined: Thu Feb 17, 2022 8:41 pm

Re: How can i FAST send 12 Bit Words parallel with ESP32

Postby AlfredoSC » Thu Feb 17, 2022 8:51 pm

Esto no te funciona lo suficientemente rápido?
  1. /*
  2.  * Programa para el ESP32 que consiste en formar un puerto con varios
  3.  * GPIOs, (ya que el ESP32 no tiene configuración por puertos paralelos
  4.  * como en los Atmegas y PICs).
  5.  *
  6.  * Alfredo Segura Querétaro, México febrero de 2022
  7.  */
  8.  
  9. int D0 = 13;    // 8 bits para salida paralela,
  10. int D1 = 12;    // en cada PIN del ESP32
  11. int D2 = 14;
  12. int D3 = 27;
  13. int D4 = 26;
  14. int D5 = 25;
  15. int D6 = 33;
  16. int D7 = 32;
  17.  
  18. int variable = 0;
  19. String datochar;
  20.  
  21. int i = 0;
  22. int j = 0;
  23.  
  24. void setup() {
  25.   pinMode(D0, OUTPUT);
  26.   pinMode(D1, OUTPUT);
  27.   pinMode(D2, OUTPUT);
  28.   pinMode(D3, OUTPUT);
  29.   pinMode(D4, OUTPUT);
  30.   pinMode(D5, OUTPUT);
  31.   pinMode(D6, OUTPUT);
  32.   pinMode(D7, OUTPUT);
  33.  
  34.   digitalWrite(D0, LOW);
  35.   digitalWrite(D1, LOW);
  36.   digitalWrite(D2, LOW);
  37.   digitalWrite(D3, LOW);
  38.   digitalWrite(D4, LOW);
  39.   digitalWrite(D5, LOW);
  40.   digitalWrite(D6, LOW);
  41.   digitalWrite(D7, LOW);
  42.  
  43.   Serial.begin(115200);
  44.  
  45.  
  46. }
  47.  
  48. void loop() {
  49.   if (Serial.available()) {
  50.     datochar = Serial.read();
  51.     Serial.println(datochar);
  52.    
  53.     variable = datochar.toInt();
  54.     digitalWrite(D0, bitRead(variable,0));  
  55.     digitalWrite(D1, bitRead(variable,1));
  56.     digitalWrite(D2, bitRead(variable,2));
  57.     digitalWrite(D3, bitRead(variable,3));
  58.     digitalWrite(D4, bitRead(variable,4));
  59.     digitalWrite(D5, bitRead(variable,5));
  60.     digitalWrite(D6, bitRead(variable,6));
  61.     digitalWrite(D7, bitRead(variable,7));  
  62.     }
  63.   delay(100);    
  64. }

ESP_Sprite
Posts: 9730
Joined: Thu Nov 26, 2015 4:08 am

Re: How can i FAST send 12 Bit Words parallel with ESP32

Postby ESP_Sprite » Fri Feb 18, 2022 1:41 am

That code is super-inefficient on any processor, so I wouldn't think so.

Tobi82m
Posts: 23
Joined: Wed Feb 16, 2022 9:10 am

Re: How can i FAST send 12 Bit Words parallel with ESP32

Postby Tobi82m » Fri Feb 18, 2022 7:35 am

AlfredoSC...whats this? This is really the slowest version...

I think i try to work with the https://github.com/TobleMiner/esp_i2s_parallel
Any other Ideas?

Who is online

Users browsing this forum: Bing [Bot] and 79 guests