RGB VGA Video Driver for ATTiny85

I am currently speccing up an RGB VGA Video Driver for the ATTiny85

The resolution would only be 64*64 pixels, but writable as 32*32 pixel blocks Only 3 blocks can be used, one for red, one for green and one for blue but the block can be moved, copied, inverted etc to make patterns

Obviously all R/G/B blocks overlaid in the same place would create white, and other combinations follow suit

I am trying to make use of the limited ram available, which is 512 bytes one 32*32 pixel block would use up 128 bytes, therefore 3 blocks (RGB) would be 384 bytes

The sync would appear at PB0/OC0A, red at PB1, green at PB2, blue at PB3, and possibly an audio input at PB4

I have worked out this resolution CAN be done at 16mhz, but only by using the internal clock, so there may be errors created by temperature or just plain off-day !

I am writing this along side the 32MHz 128*96 (TVout clone) that I have adapted for RGB VGA video, which forms the precursor to a major video driver I shall be writing for the STM32 72MHz maple-style micros

Sample of ATTINY85 VGA Code Ideas...

// save the current port condition
"in r16,%[port]\n\t" // load IO from port into r16
// get values from arrays
"ld RED_REG,X+\n\t" // load byte from red array and post increment X
"ld GREEN_REG,Y+\n\t" // load byte from green array and post increment Y
"ld BLUE_REG,Z+\n\t" // load byte from blue array and post increment Z
// deal with each bit of each RGB array separately
"bst RED_REG,7\n\t" // copy bit 7 from RED_REG to T flag
"bld r16,1\n\t" // store T flag into bit 1 of r16 (PB1)
"bst GREEN_REG,7\n\t" // copy bit 7 from GREEN_REG to T flag
"bld r16,2\n\t" // store T flag into bit 2 of r16 (PB2)
"bst BLUE_REG,7\n\t" // copy bit 7 from BLUE_REG to T flag
"bld r16,3\n\t" // store T flag into bit 3 of r16 (PB3)
"out %[port],r16\n\t" // output r16 to port
// each bit is dealt with one at a time, not in a loop as it is too slow - only 13 cycles per pixel !

Bob

It looks like I can make a straight transition from TIMER1 (used on other micro's within TVout) to TIMER0 on the t85, although the resolution has dropped from 16bit down to 8bit, but that doesnt bother me as all I need to do is divide the load value by 256 and check against the timer prescaler

After doing lots of internet research I found this...

http://www.avrfreaks.net/forum/attiny-85-does-color-vga-sound-and-joystick-32mhz

This is mental considering the lack of pins and ram the ATTiny85 has !!

http://youtu.be/8Z5Gcl8Py7Y?list=UU4iEa96zMzNFfL2VIxlwwMA

Its not what I want to do as I am not into gaming, but I have had a look at some of the ideas going on there and may have to consider a few

Main change will be the upgrade to 32mhz clock gen, as I am only considering PAL at the moment this is perfect for the H & V sync timing, and this gives me 26 clock cycles to pull data from red green and blue arrays (plus some clever manipulation) and write it to the screen

What I am trying to achieve would probably make this a useless idea for anyone else to try

:)

This is going really well, I have changed the resolution to 48*48 pixels but it is done in the following way...

the screen area is split into 4 quadrants, each quadrant is 24*24 pixels I have 72 byte arrays for Red, Green and Blue which map to the top left quadrant

I have flags to determine if each of the red, green or blue arrays are switched on in any particular segment, OR mirrored vertically or horizontally

The permutations for creating amazing video effects are almost endless and the whole 48*48*8 colour pixel array takes only 216 bytes to store, less than half the 512 available on the t85

I have also created a second video mode which combines ALL the data arrays together in one continuous array so that I can create a 40*40 pixel screen in ONE selectable colour, but there wont be any mirroring or copying involved.

I am using the following connections :

MICRO   PORT  RES  SIGNAL  VGA CONN
Pin 5 - PB0   1k   VHsync  (pin13)
Pin 6 - PB1   47r  RED     (pin1)
Pin 7 - PB2   47r  GREEN   (pin2)
Pin 3 - PB4   47r  BLUE    (pin3)

this leaves pin2 for connection to the 32mhz clock generator.

I intend to free up the reset pin to use as an audio input to trigger the patterns

video to follow :)

My early video

http://youtu.be/-qz4vENZE6c

newer video to follow :)

I worked out this morning that I can select a different colour for each scan line

Therefore, if I alternate between a RED and a YELLOW line I will get generally ORANGE Similarily I can do this for other colour mixtures and create a secondary palette

Its not perfect, but its FREE !!

So far I have been using

RED YELLOW GREEN CYAN BLUE MAGENTA WHITE BLACK

but I guess I can extend it to a mixture of not only the vibrant colours like... ORANGE = RED + YELLOW

.. but also alternating with WHITE or BLACK DARK RED = RED + BLACK PINK = RED + WHITE GREY = WHITE + BLACK

I am not sure how many colours are usable, but this seems to open up quite a few more possibilities for me

latest video - please excuse the interference pattern, it improves on the close up shot

64 colour VGA on attiny85

All this looks really interesting, thanks for sharing. One question - How is the 32MHz clock used exactly? Do you overclock the ATtiny, send the signal directly to the VGA and prescale on the ATtiny... ?

Hi,

I connect a 32mhz crystal oscillator with TTL level output directly into Pin 2 of the attiny85. my boards.txt file has this entry

attiny85-32.name=ATtiny85 (32mhz MHz clock gen)
attiny85-32.bootloader.low_fuses=0xc0
attiny85-32.bootloader.high_fuses=0xdf
attiny85-32.bootloader.extended_fuses=0xff
attiny85-32.upload.maximum_size=8192
attiny85-32.build.mcu=attiny85
attiny85-32.build.f_cpu=32000000L
attiny85-32.build.core=arduino:arduino
attiny85-32.build.variant=tiny8

and thats pretty much it to get the t85 overclocked

The vSync & hSync are created from timer0, and the pixel generation made from exact clock timings

Wow, I didn’t know the ATtiny85 could be pushed so far above specs. There are probably other scenarios where this can be handy!

Its pretty much as much as it can do in one go as the VGA signalling takes up a fair bit of processing time - the 'early video' creates a 48*48*8 colour picture with very little spare time outside the interrupt for processing of 'normal' code... the second video requires some tiny no-op loops but is basically uninterruptable when drawing/rendering video pictures

I like to try and squeeze every last ounce of blood out of these little jiggers, and its great that they cost so little too

One slight correction about the colours, I am working on a algorithm to create 16 colours rather than 64 (as mentioned) - I looked at some of the colour involving more black or white and they didnt look so great so I am omitting them for the time being

My next challenge is to create indexable colour going HORIZONTALLY, which is much harder than vertically as there is so little time to change between colours as the line is being rendered AND without disturbing the timing, the last thing I want is lines to look rickety !!

Been working on colour dithering today…

so from a simple RED GREEN BLUE (logic on or off - no half voltages) I have created further mixtures

between each primary there is another colour, by ORing two primaries together you can get the other colours

Here is a list of colour I put into an array

PROGMEM uint8_t colours[12] = {_RED, _YELLOW, _YELLOW, _GREEN, _GREEN, _CYAN, _CYAN, _BLUE, _BLUE, _MAGENTA, _MAGENTA, _RED};

the “_RED” (etc) relates to a bit pattern to send to the RGB output pins

DITHERING…

If you alternate any of the above colours with the colour next to it on an adjacent video line you will get a dithered colour. This will be a colour between the first and the second, but only really viewable from a distance

Seems to work quite nicely, see pic for more details :slight_smile:

Video : 12 Colours going down the screen HERE Video : 6 Colours going across the screen HERE

Just working on a VGA driver for the ATTINY13A (1k flash, 64 bytes RAM !)

Going to stick with 40 * 40 pixels in 8 colours 8)

I shall probably manage that resolution with such little RAM by creating a ROWS/COLUMNS coincidence array for red green and blue, that will take 30 bytes in total for that resolution in 8 colours

Watch this space for a video soon :astonished:

ALSO : 32mhz clock oscillators HERE

that works out to be just over £0.18p EACH delivered !!! BARGAIN TIME :)

Hey, nice to see another Mad Hacker pushing an ATiny to do VGA!

I have made serious progress since my last attempt... 170x240 with 8 colors!!! Will post example code soon.

https://www.youtube.com/watch?v=rmx-2fTxsns&feature=youtu.be

Cheers! Radical Brad

Excellent Brad, I spot a 32MHz clock osc there !! I'm so pleased I'm not alone :)

I have some videos on youtube, but this one is my most recent, typical UNO at 16MHz with 17bit colour

https://www.youtube.com/watch?v=le3f_EGxOMI

Great stuff, the UNO display is nice!

It's amazing how far an AVR will go. 40MHz was no problem for the ATiny. I decided to push it to a safe "36MHz" now. Here is the little 512 byte ATiny doing Amiga Boing...

https://www.youtube.com/watch?v=6Y_5X8HbdK8

On the other end of the AVR scale, XMega can easily reach 68Mhz. Over 70MHz, it's a bit unstable.

If you like the opposite of "minimalist design", here is one I did all in 7400 logic pushing 400x300 VGA...

https://www.youtube.com/watch?v=HqSYwKYwtOo

Anyhow, keep up the great work, I will probably contact you again as I am starting a website just for Video / Audio micro-controller project and would like to show off your work.

Cheers! Brad

Wow, really like your bouncing ball, its incredible how far you can push.. never tried 40mhz, 32 was always my tops !!

Please contact me, I can always do a few better videos (I always seemed to rush them in one take ha ha)

Regards Bob