Page 7 of 8

Re: No one even mentioned the new Raspberry Pi Pico?

Posted: Fri Mar 19, 2021 1:49 pm
by feluga
I started playing with RP2040 a couple weeks ago.
I use the C SDK and decided to create my own VGA driver for it.

I tried the VGA examples from GitHub (from pico-playground project) but none works for me... The VGA Monitor doesn't lock on sync signals and reading the code makes me think it isn't standard VGA compatible. I looked into the their demo videos and it sounds like they are using old CRT VGA monitors that may support out of specs VGA signals.

Anyway, I successfully made my Pico generate VGA 640x480 60Hz correctly. So far, it produces 256x240 pixels with 256 colors (8bpp).

I decided to port Adafruit GFX to the Pico and use both cores. I don't use PIO for the VGA driver, but instead, a plain Bitbang :lol:
So I also decided to make one core deal with the VGA driver while the second core draws to the VGA RAM Video buffer.
I coded the demo based on CBM80Amiga work on the Pico, but instead of TFT, it drives the VGA --> https://www.youtube.com/watch?v=YLf2WXjunyg

Pico is Fast! I managed to draw the most complex 3D object in the demo in just 14 ms.... running Pico at 125MHz

What I had to do in order to make it work:
1- It used both Cores as said. Each core has its own NVIC, thus I could make a specific Core to handle timing IRQs.
2- I used PWM functionality to drive IRQ at certain time frame for VGA, as well as, to generate HSync signal correctly - this is a crucial point for VGA signal.
3- I bitbang the pixels on the screen with a single for(;;), which produces almost equally sized pixels - it was impressive. Pico has a Flash Cache acceleration very similar to STM32 ART, seen on STM32F4 upwards series. But I run IRQ routine from SRAM for better performance.
4- In the first test the VGA frames have a lot of jitter. I had to use a double screen frame buffer in order to draw more complex 3D objects because it takes the whole time of a VGA Frame (16.6ms). Because of it, with a single VGA frame buffer, while it was drawing the 3D objects in the buffer, it was at the same time sending the scanlines to the VGA monitor - a race visible in the screen. But even using double buffer there was jittery - thus I had to set a register in order to make Core 1 to have a higher AHB access priority. By doing it jitter is gone. Core 1 sends pixels to the VGA monitor and it was racing access to SRAM with core 0, causing the jitter. Now the image is crystal clear.
5- Core 0 draws in the not used frame buffer and its both cores work in sync using semaphores, similar to a multitasking OS.

I liked the dual core stuff!
The next step will be to make the scanline to be sent using PIO and DMA.

Re: No one even mentioned the new Raspberry Pi Pico?

Posted: Fri Mar 19, 2021 2:41 pm
by mrburnette
+1

Great effort.

Re: No one even mentioned the new Raspberry Pi Pico?

Posted: Fri Mar 19, 2021 3:17 pm
by feluga
Something I liked about Pico and its RP2040 microcontroller is that it is really flexible.
You can control almost everything, from plain CPU speed to any sort of crazy protocol for GPIOs with PIO, defining priority over buses, etc.

PIO has 8 State Machines running in parallel with the dual ARM M0+ cores. Each has its own programming space with a sort of PIO ASM.
It has many ways to make it run data transfers in parallel with the CPU, using a very flexible AHB connection matrix.
DMA can be connected to anything and PIO can raise Interrupt or even wait for Interrupts to be cleared.

It's almost like a "LEGO microcontroller" :lol: .
Very impressive for $5. Something I hadn't seen before...

Maybe some of you have seen other MCUs with a similar architecture!

Re: No one even mentioned the new Raspberry Pi Pico?

Posted: Fri Mar 19, 2021 5:51 pm
by BennehBoy
Love to see a vid of your pico doing vga/3d gfx.

Re: No one even mentioned the new Raspberry Pi Pico?

Posted: Fri Mar 19, 2021 7:49 pm
by DiTBho
For me, it looks too complex. I don't like complex things.

Re: No one even mentioned the new Raspberry Pi Pico?

Posted: Fri Mar 19, 2021 10:18 pm
by feluga
BennehBoy wrote: Fri Mar 19, 2021 5:51 pm Love to see a vid of your pico doing vga/3d gfx.
I just published the video: https://www.youtube.com/watch?v=E25eQBNbPDQ

Re: No one even mentioned the new Raspberry Pi Pico?

Posted: Sat Mar 20, 2021 2:17 pm
by BennehBoy
Nice, thanks. Maybe port Elite to it :D

Re: No one even mentioned the new Raspberry Pi Pico?

Posted: Sat Mar 20, 2021 7:29 pm
by fpiSTM
Very nice! Great work! ;)

Re: No one even mentioned the new Raspberry Pi Pico?

Posted: Sat Mar 20, 2021 7:31 pm
by feluga
BennehBoy wrote: Sat Mar 20, 2021 2:17 pm Nice, thanks. Maybe port Elite to it :D
Is this Elite you're taking about?
https://www.youtube.com/watch?v=vusGo64sDFk

Re: No one even mentioned the new Raspberry Pi Pico?

Posted: Sun Mar 21, 2021 10:18 am
by BennehBoy
Ha yeah :D But they're doing hardware emulation.