[resolved] waitvid minimum timing
kuroneko
Posts: 3,623
To put it bluntly, it wasn't what I expected. Then again, what is? I tried to get a handle on this in the past but somehow didn't. Anyway, lets start with some prerequisites.
The video PLL is set to run at 20MHz, frame and pixel clocks are left at default values (4K/256). Which means at 80MHz a frame should last 16K cycles. I sample cnt in three places, at the start of the frame (after the last waitvid), immediately before waitvid for the current frame and also immediately after that one. Lets call them one, two and three in that order. Which means (three - one) gives us the cycle count for the frame (in clock cycles) and (three - two - 4) gives us the time spent in waitvid. One last thing, in order to not spent all the time waiting in waitvid I fill the gap with a defined waitcnt to consume all those unsused cycles.
And here are the results:
So, like it or not, the minimum cycle time for a waitvid is 4. You'll notice that the measured timing for +1 too late is also 4 (it's not a typo). In this case the frame length is not 16K cycles but 16K+1 cycles. What remains to be investigated is how that affects the next frame, i.e. whether it can be off by one as well.
Make sure you check out other oddities listed here.
The video PLL is set to run at 20MHz, frame and pixel clocks are left at default values (4K/256). Which means at 80MHz a frame should last 16K cycles. I sample cnt in three places, at the start of the frame (after the last waitvid), immediately before waitvid for the current frame and also immediately after that one. Lets call them one, two and three in that order. Which means (three - one) gives us the cycle count for the frame (in clock cycles) and (three - two - 4) gives us the time spent in waitvid. One last thing, in order to not spent all the time waiting in waitvid I fill the gap with a defined waitcnt to consume all those unsused cycles.
waitvid zero, zero '----------------------------------------------- _one_ mov eins, cnt ' start of frame N mov cnt, cnt ' add cnt, delay ' waitcnt cnt, #0 ' delay 14 + (delay - 9) _two_ mov zwei, cnt ' end of frame N (sort of) waitvid zero, zero '----------------------------------------------- _three_ mov drei, cnt ' start of frame N+1
And here are the results:
' frame length = mov + (14 + (delay - 9)) + mov + waitvid ' delay = frame length - mov - 14 + 9 - 4 - waitvid ' delay = 4K*4 - 4 - 14 + 9 - 4 - 4+ ' delay = 16371 - 4+ expected waitvid measured ' cycle count cycle count collect(16365) ' -2 too early 6 6 collect(16366) ' -1 too early 5 5 collect(16367) ' +0 perfect match 4 4 collect(16368) ' +1 too late 16K + 4 - 1 4 collect(16369) ' +2 too late 16K + 4 - 2 16K + 4 - 2
So, like it or not, the minimum cycle time for a waitvid is 4. You'll notice that the measured timing for +1 too late is also 4 (it's not a typo). In this case the frame length is not 16K cycles but 16K+1 cycles. What remains to be investigated is how that affects the next frame, i.e. whether it can be off by one as well.
Make sure you check out other oddities listed here.
Comments
This means that with careful coding even higher resolutions may be possible than I expected, based on the 5+ cycle rating of waitvid
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.mikronauts.com E-mail: mikronauts _at_ gmail _dot_ com 5.0" VGA LCD in stock!
Morpheus dual Prop SBC w/ 512KB kit $119.95, Mem+2MB memory/IO kit $89.95, both kits $189.95 SerPlug $9.95
Propteus and Proteus for Propeller prototyping 6.250MHz custom Crystals run Propellers at 100MHz
Las - Large model assembler Largos - upcoming nano operating system
Having thought about this, the extra cycle for the frame length is probably only visible in PASM land (as it has to be sync'd to the system clock). The video h/w may well show exact frame timing.
Post Edited (kuroneko) : 8/4/2010 4:52:21 AM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Composite NTSC sprite driver: Forum
NTSC & PAL driver templates: ObEx Forum
OnePinTVText driver: ObEx Forum