HIgh speed GPIO

thomasx
Posts: 8
Joined: Sun Mar 17, 2024 10:07 pm

HIgh speed GPIO

Postby thomasx » Sun Mar 31, 2024 11:34 pm

Hi

I have noticed that there are some different libraries and software out there that makes the ESP32 output VGA.

One lib offers 640x480 resolution at 60Hz framerate. So this means a pixel rate of more than 18MHz, or about 50 nS per pixel.

While the ESP32 is also doing other stuff.

So I made a simple program that just toggled a GPIO on/off.

Basicly like this

Code: Select all

while(1) {
	  digitalWrite(Outpin,LOW);
	  digitalWrite(Outpin,HIGH);
}
But it's nowhere near the speeds needed to output a VGA signal.

So, I would like to start off by learning the basics on how to output signals with such high speed as a VGA signal.

Can someone please point me in the direction where I can find information/tutorials to start learning about this?

Just toggling a pin at 18MHz, or faster, and to understand what goes into making that happen, would be a good start.

Thanks!

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

Re: HIgh speed GPIO

Postby ESP_Sprite » Mon Apr 01, 2024 1:45 am

You could open those libraries to see what they do, most of them are open-source... but I imagine they all will be using some kind of DMA-enabled parallel output functionality. On the ESP32, that would be the LCD mode of the I2S peripheral, on the ESP32S3 it will be the LCD/camera module, etc.

mikemoy
Posts: 627
Joined: Fri Jan 12, 2018 9:10 pm

Re: HIgh speed GPIO

Postby mikemoy » Wed Apr 03, 2024 10:14 am

Look into

GPIO.out_w1ts
GPIO.out_w1tc
GPIO.out1_w1tc.val
GPIO.out1_w1ts.val

You can control IO a LOT faster.

liaifat85
Posts: 200
Joined: Wed Dec 06, 2023 2:46 pm

Re: HIgh speed GPIO

Postby liaifat85 » Wed Apr 03, 2024 3:56 pm

By configuring a timer to interrupt at regular intervals, you can toggle GPIOs with high precision.

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

Re: HIgh speed GPIO

Postby ESP_Sprite » Thu Apr 04, 2024 2:42 am

liaifat85 wrote:
Wed Apr 03, 2024 3:56 pm
By configuring a timer to interrupt at regular intervals, you can toggle GPIOs with high precision.
That very much depends on what you call 'high precision'. Interrupt latency is a thing, and GPIO writes can get 'stuck' between other transactions on the bus. It's best to look at what peripherals can do for you without CPU interaction if you want high precision.

mtraven
Posts: 28
Joined: Thu Jul 07, 2022 3:34 am

Re: HIgh speed GPIO

Postby mtraven » Thu Apr 11, 2024 7:20 pm

I run "fabGL" on a couple esp32 projects, driving a 15" display @ 640*480. Color's must be limited to a pallet of 16, but it will work. LVGL is another good graphics library, though I've not tested it with a VGA display.

I'm a little unclear as to what you're trying to do? Make your own graphics library? No offense, but if you're still writing code in an arduino framework, as it sounds like you are, you're not ready to write your own graphics library.

If you're just playing around, wanting to find a fast way to write pins you could switch to a native IDF project & eliminate the middle man that is the arduino framework.

Or, the simpler option, have a look at a library like fastDigitalRead. There are a bunch of "fast io" libraries available for arduino. As I recall, some where VERY effective. Usually they give up some naming convenience / flexibility. If you are on a path to try to make your own graphics library, I suggest your start with your own fast GPIO library. That will get you familiar with direct register manipulation.


oh and FYI, VGA use analog signals, so digitialWrite() really has no place there anyways. On that note, you need to choose your pins such that they are connect to PWM capable pins.

MicroController
Posts: 1760
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: HIgh speed GPIO

Postby MicroController » Fri Apr 12, 2024 9:52 am

mtraven wrote:
Thu Apr 11, 2024 7:20 pm
VGA use analog signals, so digitialWrite() really has no place there anyways. On that note, you need to choose your pins such that they are connect to PWM capable pins.
PWM is likely not an option for VGA signals. Instead, people tend to use a couple of resistors to build a simplistic DAC, enabling the use of e.g. 2 digital pins to generate one analog signal of 4 different voltage levels.

Who is online

Users browsing this forum: pheigenbaum and 60 guests