Shop OBEX P1 Docs P2 Docs Learn Events
VGA Driver and SRAM Question — Parallax Forums

VGA Driver and SRAM Question

HI Community,

I'm returning to the community after a long time away.
Now I have some free time, I would like to come back
and hopefully learn enough to hack together a project.

My project would simply be a propeller masquerading
as a desktop computer (obviously its just a look-a-like
and cant do what a PC does).

I would like to have the screen display at 640x480
and be able to address individual pixels on the display.

I appreciate that there is not enough RAM on the P8X32A to do this

So I have a few questions, and I hope someone can point
me in the right direction, a code sample would be even better.

So I want to ask the community which is the best external RAM to use?
I would like to keep the pin count low (in case I need to use 2 or 4) so I expect to use an 8-pin ic.
but which one works best or has an object in the OBEX which I could use to guide me?

I have read the SRAM application note AN012 interfacing propeller external sram
(https://www.parallax.com/downloads/an012-interfacing-propeller-external-sram-spi)

and I think I understand that bit, so I'm hoping to take away something from that and apply
it to whatever ram ic is the best/fastest ram ic recommended by the community.
Also, could I use the same source-code that is in the AN012 and apply it to 23LC1024 with little or no changes?

Finally could someone point me to a vanilla 640x480 vga scan-line driver,
which (I assume) takes the text from the Screen[WidthxHeight] BYTE array
and dumps it to the vga out connector (without specifying a color i.e monochrome ONLY)


PS
If this is wrong forum to post my question in,
then I'm sorry, and maybe a moderator can move it to the right one.

Thank You.

Comments

  • Lots of questions, sorry for not answering them in order.
    JaanDoh wrote: »
    Finally could someone point me to a vanilla 640x480 vga scan-line driver,
    which (I assume) takes the text from the Screen[WidthxHeight] BYTE array
    and dumps it to the vga out connector (without specifying a color i.e monochrome ONLY)
    The regular VGA.spin driver uses one WORD per character so that tiles outside the font ROM can be used and a color can be specified (note that the color palette also determines which character of an odd/even pair is shown). There definitely some drivers that use byte arrays but I don't use VGA enough to recall one off the top of my head. Modifying VGA.spin to use a byte array is prob. not that that hard, too.
    JaanDoh wrote: »
    Also, could I use the same source-code that is in the AN012 and apply it to 23LC1024 with little or no changes?
    Yes, the only difference between the 23LC1024 and 23K256 i can glean from the datasheets seems to be that the 23LC1024 needs a 24 bit address, instead of a 16 bit one
    JaanDoh wrote: »
    So I want to ask the community which is the best external RAM to use?
    I would like to keep the pin count low (in case I need to use 2 or 4) so I expect to use an 8-pin ic.
    but which one works best or has an object in the OBEX which I could use to guide me?

    I have read the SRAM application note AN012 interfacing propeller external sram
    (https://www.parallax.com/downloads/an012-interfacing-propeller-external-sram-spi)

    and I think I understand that bit, so I'm hoping to take away something from that and apply
    it to whatever ram ic is the best/fastest ram ic recommended by the community.
    No SPI device is fast enough to saturate a 640x480p60 video stream. Assuming one byte per pixel, that's at least 19,660,800 bytes ber second. Peak SPI speed on the Propeller is CLOCKFREQ/4 (for 80Mhz prop that's 20,000,000 BITS ber second = 2,500,000 bytes per second).
    What you can however do with the 23LC1024 is switch two of them to 4-bit SQI mode and connect their busses to the VGA DAC through a buffer (74HC125 maybe? IDK). Then you just clock them at 12.8575 MHz for 320x480 or 25.175 for 640x480 (the latter frequency is somewhat out of spec, but it'll likely work at room temperature). (note that to fit a full 640x480 frame,you'd need 4 RAMs. 640x400p70 however will work with just two) You can then update the screen memory during the blanking intervals.

  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2019-04-21 06:18
    Check out my various threads and see what I've been doing using 8bpp VGA for video/graphics as well as text etc. (The camera comes into focus about 40 secs into the video)
  • RaymanRayman Posts: 13,800
    I’ve used the ssd1963 in combination with triple dac for vga or dvi encoder for hdmi. Look for dvi graphics shield.

    But now, I think I’d use eve2 instead of ssd1963.
  • kwinnkwinn Posts: 8,697
    The best type of memory to use depends on the type of video you want. For text and sprites only you do not need any external memory, but are limited to text and simple graphics using 8x8 or 16x16 graphic blocks.

    If you want full 640x480 bit addressable graphics then you need a minimum of 307200 pixels, so 307200 bits for monochrome, bytes if you want 256 colors, so 256 color would require 8 23LC1024 chips in parallel.

    IIRC the pixel data rate for VGA is 31.5MHz, while the maximum clock rate for the 23LC1024 is only 20MHz. Perhaps two 4Mb SPI rams such as these would be simpler.
  • Thank You Wuerfel_21,
    Its okay, no apology needed for not answering my queries in order.


    Wuerfel_21 wrote: »
    The regular VGA.spin driver uses one WORD per character so that tiles outside the font ROM can be used and a color can be specified (note that the color palette also determines which character of an odd/even pair is shown). There definitely some drivers that use byte arrays but I don't use VGA enough to recall one off the top of my head. Modifying VGA.spin to use a byte array is prob. not that that hard, too.

    Oh, I wasn't aware that the selected colour affected the character too. I guess this is down to my lack of understanding the assembly code.


    Wuerfel_21 wrote: »
    Yes, the only difference between the 23LC1024 and 23K256 i can glean from the datasheets seems to be that the 23LC1024 needs a 24 bit address, instead of a 16 bit one

    Yes, I saw that bit in the datasheet for the 23LC1204, that three bytes of address are needed, so now that bit falls into place and it doesn't sound too bad.


    Wuerfel_21 wrote: »
    No SPI device is fast enough to saturate a 640x480p60 video stream. Assuming one byte per pixel, that's at least 19,660,800 bytes ber second. Peak SPI speed on the Propeller is CLOCKFREQ/4 (for 80Mhz prop that's 20,000,000 BITS ber second = 2,500,000 bytes per second).
    What you can however do with the 23LC1024 is switch two of them to 4-bit SQI mode and connect their busses to the VGA DAC through a buffer (74HC125 maybe? IDK). Then you just clock them at 12.8575 MHz for 320x480 or 25.175 for 640x480 (the latter frequency is somewhat out of spec, but it'll likely work at room temperature). (note that to fit a full 640x480 frame,you'd need 4 RAMs.

    640x400p70 however will work with just two) You can then update the screen memory during the blanking intervals.

    I'm not sure how you mean there, since my electronics is limited, but I assume the following
    4 pins for the i/o bus
    4 pins for the chip selects
    1 pin for the clock
    which leaves me 1 pin short, since I only have 8 spare.

    Lets say I STILL go for 640x480,
    but instead of having the pixel data stored with two spare bytes at the front (xxRRGGBB xxRRGGBB xxRRGGBB = 3 bytes and 3 pixels),
    I pack it and remove the spare bytes? (RRGGBBRR GGBBRRGG BBRRGGBB = 3 bytes and 4 pixels) can I fit that onto 2 RAMS?

    The more I look at it, the more it looks like I need two propeller micro-controllers to fit everything in.

  • Check out my various threads and see what I've been doing using 8bpp VGA for video/graphics as well as text etc. (The camera comes into focus about 40 secs into the video)

    That looks amazing Peter, the quality and clarity of the display is awesome,
    I was reading some of the threads where you mention Tachyon Forth last night and it made me wish I knew Forth,
    but alas I've only ever Basic and I'm struggling to understand the PASM too.
    So if your video was showcasing the power of Tachyon Forth , its beyond me I think.

    I've also read quite a few posts on the P2 project, all you guys are doing a sterling job, I cant wait till they come out officially!




  • Rayman wrote: »
    I’ve used the ssd1963 in combination with triple dac for vga or dvi encoder for hdmi. Look for dvi graphics shield.

    But now, I think I’d use eve2 instead of ssd1963.

    I saw some of the threads where you wrote about HyperRam and that was for the P2?
    I have visited your website many times, its full of useful niknaks and stuff, especially the calculators, they're ace.

    As for the vga/dvi shield its a little out of my budget right now.
    But yeah, I keep watching out in the forums, in case I find something which looks desirable and in the range of my abilities lol.





  • kwinn wrote: »
    The best type of memory to use depends on the type of video you want. For text and sprites only you do not need any external memory, but are limited to text and simple graphics using 8x8 or 16x16 graphic blocks.

    If you want full 640x480 bit addressable graphics then you need a minimum of 307200 pixels, so 307200 bits for monochrome, bytes if you want 256 colors, so 256 color would require 8 23LC1024 chips in parallel.

    IIRC the pixel data rate for VGA is 31.5MHz, while the maximum clock rate for the 23LC1024 is only 20MHz. Perhaps two 4Mb SPI rams such as these would be simpler.

    Thank You,
    Those look sooper dooper and no increase in pin count either.
    Really, Cheers for that :)
  • whickerwhicker Posts: 749
    edited 2019-04-21 19:40
    I know you specified this: "I would like to keep the pin count low (in case I need to use 2 or 4) so I expect to use an 8-pin ic."

    But I've been using Hyperram, which has an 8-bit data bus and DDR where data changes on rising and falling clock edge. and then it needs 3 more pins (clock, chip select, RWDS). for a total of 11 pins.

    It's quite a bit of overhead to set the address (6 bytes address plus latency clocks), but once it gets going it's data every clock edge which fits the video timing use case. On a P2 it can outrun 8bpp VGA by over 4 times per horizontal line. Not sure about the P1 but ideally you'd use the 6.25 MHz crystal.

    The challenge with hyperram is that it's a BGA package, so I'm using a breakout board.
    Amazingly, at this point I do have glitchless 640x480 16bpp running (on the P2) even with point to point wiring.
    (trial and error, needed a 220 ohm series resistor on CS for inexplicable reasons).

    edit: clarified P1/P2
  • RaymanRayman Posts: 13,800
    The stuff I mentioned was for P1.
    Maybe you could also use HyperRam/Flash with P1.
    Guess you could get to 20 MBPS pretty easily. Maybe more using multiple cogs.
    I suppose with 3 cogs you could get 8 bpp VGA.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2019-04-22 03:40
    JaanDoh wrote: »
    I was reading some of the threads where you mention Tachyon Forth last night and it made me wish I knew Forth,
    but alas I've only ever Basic and I'm struggling to understand the PASM too.

    Forth? Did I say Forth? I meant Stack Structured Basic. How is it different from Basic?
    Here's some Rosetta code:

    Hello World - Basic (interactive)
    print "Hello World"

    Hello World - Tachyon Stack Structured Basic (interactive)
    print" Hello World"

    Repeated Hello World in one line of Tachyon:
    10 for crlf print" Hello World" next

    Output:
    TAQOZ# 10 for crlf print" Hello World" next --- 
    Hello World
    Hello World
    Hello World
    Hello World
    Hello World
    Hello World
    Hello World
    Hello World
    Hello World
    Hello World ok
    TAQOZ#
    

    Extend the language with a new word called hello:
    pub hello   10 for crlf print" Hello World" next ;
    

    To use the new word just type hello

    Here's a "program" to calculate Ohm's law but it isn't really a program since it simple extends the language to understand these new words and how to deal with them so you can also "script" them:
    Sample usage: ( the --- here indicates end of user input and start of response )
    TAQOZ# 220 ohms 10 ma is --- 2200mV  ok
    TAQOZ# 1800 mv 10 ma is --- 180ohms  ok
    TAQOZ# 3300 1800 - mv 5 ma is --- 300ohms  ok
    TAQOZ# vdd 5 ma is --- 660ohms  ok
    TAQOZ# vdd 22 k is --- 150uA ok
    
    Just copy and paste this into the terminal to compile and run.
    ( Ohm's Law Calculator )
    
    \ define r v i variables
    long _r
    long _i
    long _v
    
    \ define result calculator
    pub is
             _r @ 0= IF _v @ 1000 * _i @ / print print" ohms " THEN ---
             _v @ 0= IF _r @ _i @ * 1000 / print print" mV " THEN ---
             _i @ 0= IF _v @ 1000 * _r @ / print print" uA" THEN ---
    	 _r 12 ERASE
             ;
    
    \ define various r v i units
    pub k			1000 *
    pub ohms		_r ! ;
    pub v			1000 *
    pub mv			_v !  ;
    pub ma			1000 *
    pub ua			_i ! ;
    
    \ define vdd as 3.3V
    pub vdd			3300 mv ;
    
    { Usage:
    TAQOZ# 220 ohms 10 ma is --- 2200mV  ok
    TAQOZ# 1800 mv 10 ma is --- 180ohms  ok
    TAQOZ# 3300 1800 - mv 5 ma is --- 300ohms  ok
    TAQOZ# vdd 5 ma is --- 660ohms  ok
    TAQOZ# vdd 22 k is --- 150uA ok
    
    and now print out all the resistors needed to get 5ma at
    voltages from 0 to vdd in 100 mv steps.
    
    0 vdd ado crlf i . space i mv 5 ma is 100 +loop
    }
    
    
    

  • whicker wrote: »
    I know you specified this: "I would like to keep the pin count low (in case I need to use 2 or 4) so I expect to use an 8-pin ic."

    But I've been using Hyperram, which has an 8-bit data bus and DDR where data changes on rising and falling clock edge. and then it needs 3 more pins (clock, chip select, RWDS). for a total of 11 pins.

    It's quite a bit of overhead to set the address (6 bytes address plus latency clocks), but once it gets going it's data every clock edge which fits the video timing use case. On a P2 it can outrun 8bpp VGA by over 4 times per horizontal line. Not sure about the P1 but ideally you'd use the 6.25 MHz crystal.

    The challenge with hyperram is that it's a BGA package, so I'm using a breakout board.
    Amazingly, at this point I do have glitchless 640x480 16bpp running (on the P2) even with point to point wiring.
    (trial and error, needed a 220 ohm series resistor on CS for inexplicable reasons).

    edit: clarified P1/P2


    Thank you, that's sounds really good too,
    Maybe later on I can investigate hyper ram when my skills get better.
  • Rayman wrote: »
    The stuff I mentioned was for P1.
    Maybe you could also use HyperRam/Flash with P1.
    Guess you could get to 20 MBPS pretty easily. Maybe more using multiple cogs.
    I suppose with 3 cogs you could get 8 bpp VGA.

    I was hoping to use 1 cog for the vga scanline driver and 1 cog for the vga console (the text grid array) and that with 64 colors only.
    I thought I had seen a vga driver in the obex with just one cog needed for it.

    I don't feel I have enough experience to work with multiple cogs as yet.
  • JaanDoh wrote: »
    I was reading some of the threads where you mention Tachyon Forth last night and it made me wish I knew Forth,
    but alas I've only ever Basic and I'm struggling to understand the PASM too.

    Forth? Did I say Forth? I meant Stack Structured Basic. How is it different from Basic?
    Here's some Rosetta code:

    No, sorry, you did not say forth.

    I meant when I was browsing this website the night before.
    I really need to punctuate my text lol.

    That structured basic looks super,
    could you point me to a link, where I could find a language ref or docs please?

    Cheers


  • Cluso99Cluso99 Posts: 18,066
    FWIW using multiple cogs is way easier than using interrupts.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2019-04-23 01:56
    JaanDoh wrote: »
    No, sorry, you did not say forth.

    I meant when I was browsing this website the night before.
    I really need to punctuate my text lol.

    That structured basic looks super,
    could you point me to a link, where I could find a language ref or docs please?

    Cheers

    That was a joke. If we have a Forth like language that was called Stack Structured Basic then automatically we think of it in terms of something that we are already familiar with. I have always said that programming is programming. The language is way to program and there are many ways, we can pick and choose rather than being tied down. Basic can be target resident and interactive. Forth is target resident and interactive, all you need is a terminal. Basic will only ever understand what its compiler can understand. Forth understands all those definitions that you make so that you end up talking to it with your "language", and if it is well thought out, then the words will flow as in the case of the Ohm's Law "program" that is written in and is Forth.

    If at 100 x and 100 y I want to draw a red panel on my VGA screen that is 200 wide and 50 high I can type from the terminal or on the screen in my graphics language.
    100 x 100 y 200 w 50 h red panel
    
    It draws a red panel but I can create an indexed loop that draws multiple panels just as easily.
    To divert text to the screen instead of the terminal console I simply use the word VGA which redirects all output there or CONVGA to do both etc. So the Hello World program remains the same, there is no special need to have special VGA print words, just redirect the output.
    Forth, or more correctly what you make it, is a lot of fun and very productive (and fast).
Sign In or Register to comment.