[posted] VGA out for Teensy 4.0/4.1

Hi Jean Marc ,
I have check your VGA driver but i have to admit ,the way it's done, it's too complex for me :D
I have then test on STM32 for try to shift the screen to right , i don't have reproduce the same as we have on the teensy but it come from the H back porch + H Sync + H Front porch , when i set them to wrong value the picture move too :eek:
If it's possible , can you try this on your timing ?

This timing made me a perfect 640 x 480 screen with no shifting , now for the 640 x 400 the horizontal timing stay the same , only the vertical one change because they are less line to show.


According to your drawing,
back_porch = 800-756= 44
and front_porch = 660-640 = 20

So in the lib do:

#define frontporch_pix 20 //16
#define backporch_pix 44 //48

Does it resolve your problem?


The shift you have in Turrican is not because of the VGA driver but is a bug in the emulator.
You have the issue with other games as Toki.
I have it too.
Hello Jean Marc :)

I'm back home and tested what you say , it change nothing for the drift to right.
It's not just on emulator but generic , it do also the same with the demo program.

I don't remember what we do in the pas to recenter the picture .....

sorry for the late reply.
Not sure what is wrong with your monitor.
I had updated the code the last w-e with the reduced values of the back porch.
I tested on the 3 monitors I have here. They have an auto adjust option so I never have this shifting issue.

I also added a mechanism to allow pixel shift between upper and lower nibble of the 2 DMA copy (in copyline mode only)
That allows to compensate the delay between 2 DMA channels but I noticed that the delay is not constant so it does not really help to resolve the sharpness.

In meanwhile I have now MIDI support for the Atari ST emulator published.
I loved the Amiga but I had first an AtariST after my Vic20 and C64.
Even if less powerful, it had at least MIDI interface which made it popular for musicians...;-)

Hi Jean Marc :)
I found another screen for VGA testing , now it's OK , the auto correction work and the left part of screen is finally filled :)
On Amiga workbench , the bottom pixels are off screen , i don't remember the workbench resolution , i will have to test with other soft and games for see if it's the same.
The FR keyboard mapping is not able to put 'm', ',' and some other chars , i think it will be better to test it with US KB , but i don't have one , so we see if all key's are working before modding the KB code.
Congrats for this work , it's like i have my Amiga again :)
But , it will be too easy of they are no ... bugs ;) ... after some minutes , the screen come black and nothing respond , first i have think it was because PSRAM was not active in platform_config , but when it's set it appear to change nothing for the black screen after some min , i compile for smallest code or it don't fit the teensy :)

I get this problem of the black screen from time to time (with all emulator and especially doom)
When I have it, I close teensyduino SDK fully and reopen it with the project.
Recompile and re-flash and it is gone! I don't know what it is...It is like the VGA interrupt stops fully because the CPU is starved for seconds?
May be location where code ends up is the problem?
It is now running the workbench since 1/2 hour and it is stable for me. It is really sporadic but I also have it.

There are definitively bugs ;-(
The missing lines at bottom is true. If you select NTSC resolution it is not there.
I also have many games that fails from floppies but works great with whdload from HDD.

For the keyboard the m works with Belgian French keyboard.
Do you select the layout of the keyboard from Teensyduino/tools?
; is not working also for me.
for the missing lines you can play with the option
gfx_correct_aspect in uae.cpp.

Setting to 1 will fit the image to the 240 available lines but as a result will remove some lines at fixed position to insure the scaling=> not sure it is what you would like.
you can also let run the emu at full VGA res
in teensyuae41.ino use tft.begin(VGA_MODE_640x480);
and in uae.cpp
#define WIN_H TFT_HEIGHT*2

It will skip lines also but use the full res available.
Hi :)
I have made your change , it's strange like this ... he he
I check on wiki for the original Amiga res , it is :
Users could customize four display colours and choose from two resolutions: 640×200 or 640×400 (interlaced) on NTSC, or 640×256 or 640×512 on PAL systems. In later revisions, the TV or monitor overscan could be adjusted
Games use less to get more colors , it's difficult to create a resolution that will accept all , and change resolution on the fly it's allot of work too ....
But for know all available Amiga resolution it's not a bad idea to start deluxe paint IV and take a look at display mode options , if i remember , every display information was present.
Emulators on PC don't have this problem , they just put the Amiga screen into a windows that fit the desired resolution , what is not so easy with a MCU like the teensy :)
This is awesome. I want to adopt vga_t4 to my port of msx emulator (basically a ported blueMSX with a few real chips.)
Many msx people also obsessed with 15khz videos instead of vga's 31khz. I will try to make it work with 15khz but before I start, do you think it's realative easy to do, or will it take substantial amounts of work?
It should be doable, if you have the timings we can give try ! Changing the qtimer for the line timing and the pixel clock for the rest.
Is it possible to adapt this project to just read in the digital RGB from the Amiga and output it as VGA with no other processing? I'm seeing a lot of these Amiga projects that take the RGB in and run RGB2HDMI on the Pi to get an HDMI output. It seems like if you can run the whole Amiga on a Teensy 4.0 or 4.1 and output VGA, you should be able to use it for basically a flicker fixer in a real amiga. It would be smaller than the Pi0 implementation.

12 bits in and 12bits out would be needed , probably ending up in using a Teensy4.1. Not sure if price would be that interesting compare to current RAPI zero solution with HDMI out.
Thanks. I will look at your code and see if I can figure anything out. I'm better at the hardware side and was thinking that the form factor would be better even with a Teensy 4.1 than what is currently being used. In an Amiga 500, it looks like one really needs to jump through a bunch of hoops to get the RPI and HDMI cable in there with an accelerator.
Nice module, if the project is open source, may be you don't need any MCU at all to drive it as it actually has the 12 bits digital input for the Amiga.

I was not very enthusiastic the past month since I fail adding an spi interface to the VGA library gaming interface, may be time to have a look at 12 bit VGA out again?
Hi Jean Marc :)
Yea , 12bit VGA can be fun to try , but the thing with FlexIO without the right pins coming out will be tricky ;)
I get one of the PMOD Digital Video Interface , as you probably have see , they are not allot VGA connector left around on our screens , it can be easier to use something like this little interface , on the photo i see a CK pin , probably the pixel clock , i thing you can just made only perfect timing with this approach .... will see when i get it at home.

Hi Frank ,
this schematic is my R2R DAC for get better colors.
The original pin description is on Jean Marc Github for the VGA library here :
And the pin-out don't have change :)


PS : it's easy to add more bits , here it's for 8bit , i originally designed the R2R DAC for 16bits.

Thank you!
He mentiones 12 Bit on Github. Are the resistor values for 12 Bit the same for the R2R?
Which pins does 12Bit use? ( I'll add some jumpers to my PCB, and then build both versions.. )

I2S: Have you tried to place the I2S DMA-Buffers in DTCM, not OCRAM?
Hi Frank,

The 12bits mode was never tested and probably will not work.
Only the 8bits mode works (same resistor values as for the uVGA project on T3.6 that you know very well!)

Happy to have an expert on board!

You will see the issues I had when using 2 DMAs at the same time to control the FlexIO...
May be you will find a better way to drive it?

Also any use of the Audio library (any extra DMA/IRQ in fact) will disturb the display, that is why I had integrated the an I2S interrupt base audio playback in the VGA library.

I would say that "it works" but 640x480 is really on the edge...
You can also try the lib in the context on the amiga emulator (in MCUME), you will see what I mean...

Good luck!
:) I intend to order in china, so it will be cheap anyway. I'll publish the eagle files and gerbers..
How many do you need? I can send you some when they are tested.

I think I provide only the PT8211 and VGA, and put all the other pins on a big pinheader. Then this is universally usable.