Possible to sync video PLLs in multiple cogs for VGA driver? (Yes!, well 2 at
Rayman
Posts: 14,802
So, I want run 3 VGA drivers at the same time in order to·do some strange things...· (for instance, 6-bit color by having one cog for each of red,blue,green).· I can syncronize them with waitcnt, but the PLL aren't synced...· Anybody know how to do this?· Or, if it is possible?
This appears to be done in the 1024x768 driver:
I've been trying a few things like this:
But, haven't figured out how to get it right yet...
Post Edited (Rayman) : 2/12/2008 9:06:22 PM GMT
This appears to be done in the 1024x768 driver:
' Synchronize all cogs' video circuits so that waitvid's will be pixel-locked movi frqa,#(pr / 5) << 2 'set pixel rate (VCO runs at 2x) mov vscl,#1 'set video shifter to reload on every pixel waitcnt cnt,d8_d4 'wait for sync count, add ~3ms - cogs locked! movi ctra,#%00001_110 'enable PLLs now - NCOs locked! waitcnt cnt,#0 'wait ~3ms for PLLs to stabilize - PLLs locked! mov vscl,#100 'subsequent WAITVIDs will now be pixel-locked!
I've been trying a few things like this:
' Entry 'First, sync with other vga cogs !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ' WaitSync mov t1,par 'calculate sync cnt address sub t1,#4 rdlong cnt2sync, t1 'get sync cnt movi frqa,#afrq'136'(65 / 5) << 2 'set pixel rate (VCO runs at 2x) mov vscl,#1 'set video shifter to reload on every pixel waitcnt cnt2sync,d8_d4 'sync movi ctra,#%00001_101 'enable PLLs now - NCOs locked! waitcnt cnt2sync,#0 'wait ~3ms for PLLs to stabilize - PLLs locked! mov vscl,h1'#100 'subsequent WAITVIDs will now be pixel-locked!
But, haven't figured out how to get it right yet...
Post Edited (Rayman) : 2/12/2008 9:06:22 PM GMT
Comments
This code starts 2 syncronized XGA drivers.· Possible uses of strikethrough and underlined text are show.
I'd really like to get this working for the VGA driver though...
Rayman: What about doing a synchronized WAITCNT where all cogs wait for the same cnt value before starting? It's completely a guess
Good luck!
Cheers,
--fletch
First, an initial common-value WAITCNT must be executed on all involved cogs. This will sync instruction execution, which can subsequently be used to sync the CTRA's and their PLL's. The instruction sequence following this WAITCNT must be the same on all COGs to ensure synchronization.
Then, CTRA and FRQA must be configured for PLL function mode %00001·(it is assumed that all PHSA's·were zeroed from reset) and VCFG and VSCL must be configured to reload on every pixel (VSCL=1). This will sync all CTRA's and start the video shifters (which will rev up along with the PLL's).
Another ~ms will be required to allow the PLL's and the PLL-driven video shifters to synchronize, as well. This can be done with a simple common delay or WAITCNT. Note that the video shifters will be reloading on every pixel clock (which is every PLL clock, since VSCL=1).
Then, VSCL must be set to a value of, say, 100, to allow the various code branches to occur before all cogs settle into their initial WAITVID's, which will be synchronized.
Here is the complete VGA 1280x1024 Tile Driver:
http://obex.parallax.com/objects/176/
Note that the subtle key to getting the video shifters synchronized was to have them reload on EVERY pixel, keeping them all in a common state. Since the CTRA's were synced, and additional time was allowed for the PLL's to sync, and the video shifters were reloading on every single PLL cycle, AND code execution was synced across all cogs, that final MOV VSCL,#100 set the next WAITVID time marker 100 pixels into the future, allowing all cogs to get into their unique WAITVID's so that they could each play their differentiated roles in the video production. Thereafter, each cog must do WAITVID's to elapse all necessary time chunks to stay in sync with the other cog's. Or, in other words, WAITCNT is no longer the sync mechanism, but WAITVID is.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chip Gracey
Parallax, Inc.
Post Edited (Chip Gracey (Parallax)) : 2/11/2008 8:54:00 PM GMT
I don't get it!·· I would think this either doesn't wait or waits 34 seconds...· What gives?
Anybody know about how "waitcnt cnt,d8_d4" works? Maybe I'll look in "Tricks&Traps"...
Searched everywhere (even deSilva's Assembly Tutorial!) and still don't see how "waitcnt cnt" is supposed to work...
Post Edited (Rayman) : 2/11/2008 10:31:56 PM GMT
marty
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Lunch cures all problems! have you had lunch?
http://forums.parallax.com/showthread.php?p=613987
I think it's too late for me today to get a grip on this though...
To flame the board a bit...· Here's a little Photoshop test of what a 6-bit image might look like:
Here's what I have so far:
Note:· I'm using the long before the regular parameters to pass the cnt to sync to.· I'm printing blue lines with one driver and red lines with the other and hoping to make magenta...· It seems that now the driver PLL are in sync, but offset by 40 ns or so...· So, I'm closer, but not there yet...
Be sure to uncomment out this line:
Post Edited (Rayman) : 2/12/2008 7:12:17 PM GMT
Just commented out the last step in the sync routine:
And now it works!· (red+blue=magenta)
PS:· This is also a trick for red-blue 3D in 2-bit color...
Here's the working files:
I'll be adding something similar to the VGA Line Driver in the VGA learning kit soon.
Still trying to get a basic graphics object working first though, which will also make it simpler to test this!
Glad you figured it out
Cheers,
--fletch
I think I can so proof of concept with XGA drivers anyway, so I think I'll punt on sync'd VGA for now...
I would also recommend using a real CRT, and not an LCD for your driver development, since it will be much more 'analog' and won't suffer from pixel jitter when your timing in't matching up to an LCD's absolute pixel grid. By the time development is over, your driver should work perfectly on most LCDs (some have better PLLs than others, and it seems to have nothing to do with price).
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chip Gracey
Parallax, Inc.