Generating VGA signal by PIC24 with no hardware - Page 1
Forum section: electronics / projects

author: voja
author_rank: Contributor
timestamp: January 05, 2015, 09:05:02 pm
content: I made a few projects which employed pure software to generate VGA signals. At this moment it is used in some public displays and in casinos, and for MCU shape recognition projects (in development and service adjusting process). Both text and (limited resolution) graphic modes are possible, even sprite support.For demonstration purpose and DIY workshop, the single chip retro game console is described athttp://www.voja.rs/PROJECTS/GAME_HTM/1_intro.htmThe project is open and convenient for workshops.

author: amyk
author_rank: Super Contributor
timestamp: January 05, 2015, 09:48:29 pm
content: Much more interesting thanhttp://www.linusakesson.net/scene/craft/, although you're using a much more powerful MCU too.

author: fcb
author_rank: Super Contributor
timestamp: January 05, 2015, 10:03:15 pm
content: Bravo - nice project!!I shall order one of those PIC's as soon as you publish the Gerbers.

author: c4757p
author_rank: Super Contributor
timestamp: January 05, 2015, 10:39:07 pm
content: Nice!I noticed this:QuoteIf you really want USB, look harder - Microchip have a few PICs that indeed do have USB in the DIP package, IIRC.

author: voja
author_rank: Contributor
timestamp: January 05, 2015, 11:00:09 pm
content: Quote from: c4757p on January 05, 2015, 10:39:07 pmYes, but not 24/33E with 48K RAM in DIP. There are only four types which meet those requirements and none of them has USB.

author: BloodyCactus
author_rank: Frequent Contributor
timestamp: January 06, 2015, 02:53:23 am
content: What about PIC32MX270F256B, 64kb sram, 50mhz, usb, dip28 ?

author: voja
author_rank: Contributor
timestamp: January 06, 2015, 08:48:05 am
content: Quote from: BloodyCactus on January 06, 2015, 02:53:23 amI am limited to 24/33E, as I am not familiar with MIPS32 assembler. The significant part of kernel is time-critical, and the MIPS32 documentation gives the poor explanation about execution times, especially for superpipeline and superscalar modes, which are important for keeping track with VGA dot clock. Or I couldn't find it - I'll be grateful for any pointer.

author: Howardlong
author_rank: Super Contributor
timestamp: January 06, 2015, 10:43:08 am
content: Quote from: voja on January 06, 2015, 08:48:05 am+1 for PIC32 I'm afraid!Could you use DMA to do this? That would give you some control over this. No need to fiddle about in assembler either. Idle the processor if necessary in lieu of DMA. By the way, the low pin count PIC32s (PIC32MX1xx/2xx) have no cache so are much more deterministic, similar to the PIC24F in that respect. Most instructions are single cycle (note FCY=FOSC on the PIC32) and a very few (that would result in a stall), most predominantly successful branches, take 2. The PIC32MX2xx have USB. For DIP28 packages, use PIC32MX2x0FxxxB, but note that you won't get much in the PIC32MX210 or 220 as the USB stack takes up a lot of flash, especially if you want a bootloader too. Anyway, for your RAM DIP and USB requirement, I agree it's the PIC32MX270F256B.The PIC24FJ64GB202 and PIC24FJ128GB202 offer USB in DIP28 and include DMA, but lack the RAM you want.Care would need to be taken to respond in a timely manner to USB requests. Not sure if the USB access is just required for setup, or for more continuous online operation.Personally speaking, although I do stuff for all PICs, from PIC10F thru the PIC32MZ, I find myself using the PIC32MX series most these days.Nice project by the way!

author: rob77
author_rank: Super Contributor
timestamp: January 06, 2015, 11:16:25 am
content: excellent work ! very nice project

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: January 06, 2015, 12:03:38 pm
content: PIC32 may be a better choice as the DMA may allow you to offload most of the heaviest data transfer stuff, so you wouldn't need to get into assembler

author: voja
author_rank: Contributor
timestamp: January 06, 2015, 12:11:04 pm
content: Quote from: Howardlong on January 06, 2015, 10:43:08 amI am not sure about two problems. First of all, how would DMA handle the conditional logic of sprites (sprite/background switch), and the another one is would it be possible to synchronize PIC32 DMA pixel stream with horizontal sync in one T cycle precision?I am the hardware guy and all of my programs are based on pure assembler. In fact, I really enjoy freedom which assembler programming offers.

author: c4757p
author_rank: Super Contributor
timestamp: January 06, 2015, 12:20:18 pm
content: Not to keep pushing (clearly you've done a good job here, and as it's likely all for fun, do as you please...), just throwing this out there - MIPS assembly isreallyeasy, if you want to go poking around at that level. There's a reason it's used so often as a base for academic instruction.

author: Howardlong
author_rank: Super Contributor
timestamp: January 06, 2015, 12:29:01 pm
content: If you're doing sprites as real time overlays, then DMA would be very hard to setup.The way I saw it working was as a memory mapped graphics display, and draw the game objects in the "conventional" software loop.You'd use timers and the ouptut compares to achieve sync and DMA events, however it would probably be necessary to idle the CPU outside of frame blanking to prevent DMA bus contention and therefore jitter due to indeterministic stalling. That way you can achieve single TCY precision.I certainly admire your skill, it's one at's sadly lacking in these days of code bloat and both commoditisation and pigeon-holing of skills. I am not sure how old you are, but if I was hiring and an interviewee came in with that and explained how it worked, I'd struggle not to give you a job.Although I frequently look at the code generated by compilers when looking at timing and how to optimise code, it's rare these days I actually write any. Ask me the same question twenty odd years ago I'd give a very different view!!

author: dannyf
author_rank: Super Contributor
timestamp: January 06, 2015, 12:31:47 pm
content: QuoteWith DMA, you can implement a display buffer in the memory and the DMA will dump it to the pins automatically. As changes from frame to frame is actually quite small, it will relieve the mcu a lot.

author: fcb
author_rank: Super Contributor
timestamp: January 06, 2015, 12:48:02 pm
content: I'd stick with what you have and have the option to add a FT230X or similar to the board.

author: voja
author_rank: Contributor
timestamp: January 06, 2015, 01:10:34 pm
content: Quote from: Howardlong on January 06, 2015, 12:29:01 pmI'm doing so, and I don't see the other way to move so many objects in real time by MCUQuoteI use T1/OC1 for horizontal syncQuote:-))Old enough to say that I built my first computer almost 40 years ago! I also created my first computer animation in 1979, you can see it onhttps://www.youtube.com/watch?v=6HnW1XnXFoA&feature=youtu.be

author: rob77
author_rank: Super Contributor
timestamp: January 06, 2015, 02:05:41 pm
content: Quote from: voja on January 06, 2015, 01:10:34 pm90 x 2114 SRAM chips back in 1979 ? that must have been worth of an arm and a leg back then !

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: January 06, 2015, 02:32:41 pm
content: Quote from: voja on January 06, 2015, 01:10:34 pmFor (a few) sprites you may be able to do something clever with multiple DMA channels, but I suspect memory contention would make the timings a little erratic.

author: voja
author_rank: Contributor
timestamp: January 06, 2015, 03:03:10 pm
content: Quote from: rob77 on January 06, 2015, 02:05:41 pm... and a kidney. I had some long distance order from USA, my bank (in former Yugoslavia) was too slow and my order arrived when the item was already sold out. So I had to select some other item from the catalogue, and I ordered 100 pcs 2114's at a discount price of about $250, IIRC. That's why I've got the idea to build my graphic working station. I adjusted the resolution to the amount of RAM that I have.

author: Howardlong
author_rank: Super Contributor
timestamp: January 06, 2015, 04:33:49 pm
content: Quote from: voja on January 06, 2015, 01:10:34 pmSweet! i guess that explains it, we are from similar stock. My first computer was built in 1977, hand wired, with eight 2102 1kx1 RAM. 2114? Sheer luxury!(Edit: here's what remains of my first computerhttp://www.g6lvb.com/when_i_was_a_young_chap.htm)I'd have loved it if you'd have said "I'm 14" or something, oh well!

author: Stonent
author_rank: Super Contributor
timestamp: January 06, 2015, 05:25:09 pm
content: I like this project. I've been wondering about something similar for a bit.

author: voja
author_rank: Contributor
timestamp: January 06, 2015, 09:06:04 pm
content: Quote from: Howardlong on January 06, 2015, 04:33:49 pmBuilt computer when you were 12? Wow!I like to remember that time, when computers were not just fashion accessories.

author: Stonent
author_rank: Super Contributor
timestamp: January 07, 2015, 03:50:25 pm
content: QuoteClicking on "Here" doesn't do anything.

author: voja
author_rank: Contributor
timestamp: January 07, 2015, 05:29:51 pm
content: Quote from: Stonent on January 07, 2015, 03:50:25 pmcorrectedthanks

author: miguelvp
author_rank: Super Contributor
timestamp: January 08, 2015, 05:23:07 am
content: I'm too busy at the moment but since I have an r2r VGA connector (4 bits per color) and even a full 24 bit up to 330 MHz Video DAC, I might try it on a PSoC 5 that has DMA and digital blocks, I might even try on the PSoC 4 (no DMA but has digital blocks)But work is a bear so not yet, but I'm replying so I can find the thread when I get to itPretty cool btw.Edit:330MHz DAC hooked to DE0-Nano running at 1600x1200@60Hz with 162.0MHz pixel clock (of course I can't expect the PSoC at 48MHz to do thisbut It should be able to do 640x480@60HzIt does output a very clean signal:The R2R at 640x480 only using 3 bits per color might be more in par:which you can see disconnected two pictures up. But going from the FPGA to an MCU is going to be tricky but I really hope the programmable digital blocks will help the Cortex-M0 (PSoC4) or the Cortex-M3 (PSoC5) along, at least with the horizontal and vertical sync, but I might need an external oscillator to get a good clock, will try with the built in one first anyways.

author: Dave Turner
author_rank: Frequent Contributor
timestamp: January 08, 2015, 04:40:43 pm
content: I recall 8 1kx1 static memory chips cost £100 in 1976. My first microprocessor based computer utilised 16 of them - 8 for the 64x16 VDU and 8 for the memory. 12x12 inch home etched prototyping board, single sided vero pins 1 per chip pin and all hardwired.