VIA timer underflow troubles
Moderator: Moderators
- pixel
- Vic 20 Scientist
- Posts: 1330
- Joined: Fri Feb 28, 2014 3:56 am
- Website: http://hugbox.org/
- Location: Berlin, Germany
- Occupation: Pan–galactic shaman
VIA timer underflow troubles
I've almost hacked video into that "Ohne Dich" audio player. But I can't get the frames in sync because the high byte of the VIA timer used to measure the pulse lengths doesn't seem to underflow. No negative value to have had. At least in VICE. Is it me once again having a period of brain dysfunction, an incompatibility of VICE or just the end of another crazy dream?
"Video" would be 16x16 pixels with 16 grades of luminance at rougly ten frames per second. A little bit better than in the early days of mechanical television.
"Video" would be 16x16 pixels with 16 grades of luminance at rougly ten frames per second. A little bit better than in the early days of mechanical television.
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose
https://github.com/SvenMichaelKlose
Re: VIA timer underflow troubles
"A little bit better than in the early days of mechanical television" Hillarious
BR
Thomas Lövskog
Thomas Lövskog
Re: VIA timer underflow troubles
VIA is still very buggy in VICE, i wouldnt trust it - at least use a snapshot from vice.pokefinder.org, which has most of the really bad problems fixed.
I'm just a Software Guy who has no Idea how the Hardware works. Don't listen to me.
- pixel
- Vic 20 Scientist
- Posts: 1330
- Joined: Fri Feb 28, 2014 3:56 am
- Website: http://hugbox.org/
- Location: Berlin, Germany
- Occupation: Pan–galactic shaman
Re: VIA timer underflow troubles
Will try that. Thanks! (But I'll have to build it myself on Linux.) Got a real VIC next to me for ages – now that SD2IEC device came in – and no bloody TV set I dragged through the streets of Berlin wants to tune in properly. As if the universe doesn't want me to work an a real machine. m(groepaz wrote:VIA is still very buggy in VICE, i wouldnt trust it - at least use a snapshot from vice.pokefinder.org, which has most of the really bad problems fixed.
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose
https://github.com/SvenMichaelKlose
- pixel
- Vic 20 Scientist
- Posts: 1330
- Joined: Fri Feb 28, 2014 3:56 am
- Website: http://hugbox.org/
- Location: Berlin, Germany
- Occupation: Pan–galactic shaman
Re: VIA timer underflow troubles
Logie Baird even tried to record video with a gramophone. Check out this: http://www.tvdawn.com/earliest-tv/phono ... s-1927-28/TLovskog wrote:"A little bit better than in the early days of mechanical television" Hillarious
My tapes sound very much like these records.
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose
https://github.com/SvenMichaelKlose
- Mike
- Herr VC
- Posts: 4816
- Joined: Wed Dec 01, 2004 1:57 pm
- Location: Munich, Germany
- Occupation: electrical engineer
Re: VIA timer underflow troubles
Should depend on the operation mode of what timer you use.pixel wrote:[...]the high byte of the VIA timer used to measure the pulse lengths doesn't seem to underflow. No negative value to have had. At least in VICE.
Timer 1 underflows in one-shot mode. In free-running (a.k.a. 'continuous') mode however, after $0000 it only decrements once more down to $FFFF and in the next cycle then starts again from the latch value. Timer 2 underflows in both interval timer mode and pulse counting mode.
- pixel
- Vic 20 Scientist
- Posts: 1330
- Joined: Fri Feb 28, 2014 3:56 am
- Website: http://hugbox.org/
- Location: Berlin, Germany
- Occupation: Pan–galactic shaman
Re: VIA timer underflow troubles
Thanks! I used timer 1 in one-shot mode. I wonder why this information is missing in the documentation. I'm so glad that I don't have to find that out myself anymore.Mike wrote:Timer 1 underflows in one-shot mode. In free-running (a.k.a. 'continuous') mode however, after $0000 it only decrements once more down to $FFFF and in the next cycle then starts again from the latch value. Timer 2 underflows in both interval timer mode and pulse counting mode.
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose
https://github.com/SvenMichaelKlose
- Mike
- Herr VC
- Posts: 4816
- Joined: Wed Dec 01, 2004 1:57 pm
- Location: Munich, Germany
- Occupation: electrical engineer
Re: VIA timer underflow troubles
Are you sure you didn't mean free-running/continuous mode? That one would actually be symptomatic for the problem you described, i.e. showing $FF in the timer high byte for a single cycle only (for T1 latch values < $FF00 anyway), which would most likely be missed by a polling LDA.pixel wrote:Thanks! I used timer 1 in one-shot mode.
The KERNAL puts T1 in VIA #2 into free-running/continuous mode per default for the keyboard scan/jiffy-clock IRQ.
I checked against the VIC-20 Programmer's Reference Guide, and you're right that the PRG doesn't mention T1 is not reloaded from the latches in one-shot mode (one could argue though, that this is the main difference between those two operating modes...)I wonder why this information is missing in the documentation. I'm so glad that I don't have to find that out myself anymore.
In my earlier post I was referring to the VIA 6522 data sheet, which can be found on 6502.org (link). There, the different timer operating modes are clearly laid out.
Last edited by Mike on Fri May 08, 2015 4:47 pm, edited 2 times in total.
- pixel
- Vic 20 Scientist
- Posts: 1330
- Joined: Fri Feb 28, 2014 3:56 am
- Website: http://hugbox.org/
- Location: Berlin, Germany
- Occupation: Pan–galactic shaman
Re: VIA timer underflow troubles
Pretty sure. I tried both modes with the same result: no negative high byte at all. But hang on! Am just compiling the freshest VICE and will try again soon.Mike wrote:Are you sure you didn't mean free-running/continuous mode? That one would actually be symptomatic for the problem you described, i.e. showing $FF in the timer high byte for a single cycle only (for T1 latch values < $FF00 anyway), which would most likely be missed by a polling LDA.
The KERNAL puts T1 in VIA #2 into free-running/continuous mode per default for the keyboard scan/jiffy-clock IRQ.
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose
https://github.com/SvenMichaelKlose
- pixel
- Vic 20 Scientist
- Posts: 1330
- Joined: Fri Feb 28, 2014 3:56 am
- Website: http://hugbox.org/
- Location: Berlin, Germany
- Occupation: Pan–galactic shaman
Re: VIA timer underflow troubles
The newest version of VICE is sooo much better on Linux. Don't miss out on it. The build instructions are pretty straightforward but DO NOT compile it with clang. Use the gcc compiler instead or everything will break.
But there still is no negative high byte to have had. The VIA emulation code looks very incomplete and probably doesn't care about the issues Mike mentioned.
Perhaps that won't be required. The video information is messing up the real-time alignment, so there have to be some initial statistics as well to get the playback going.
But there still is no negative high byte to have had. The VIA emulation code looks very incomplete and probably doesn't care about the issues Mike mentioned.
Perhaps that won't be required. The video information is messing up the real-time alignment, so there have to be some initial statistics as well to get the playback going.
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose
https://github.com/SvenMichaelKlose
Re: VIA timer underflow troubles
It's pretty cool you're designing a Vic-20 video/audio format.
Learning all the time...
Re: VIA timer underflow troubles
detailed bug report and/or test programs might help with fixing itBut there still is no negative high byte to have had. The VIA emulation code looks very incomplete and probably doesn't care about the issues Mike mentioned.
I'm just a Software Guy who has no Idea how the Hardware works. Don't listen to me.
- pixel
- Vic 20 Scientist
- Posts: 1330
- Joined: Fri Feb 28, 2014 3:56 am
- Website: http://hugbox.org/
- Location: Berlin, Germany
- Occupation: Pan–galactic shaman
Re: VIA timer underflow troubles
Will come up with something should the real machine ever get attached to everything it needs.groepaz wrote:detailed bug report and/or test programs might help with fixing it
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose
https://github.com/SvenMichaelKlose
- pixel
- Vic 20 Scientist
- Posts: 1330
- Joined: Fri Feb 28, 2014 3:56 am
- Website: http://hugbox.org/
- Location: Berlin, Germany
- Occupation: Pan–galactic shaman
Re: VIA timer underflow troubles
Oops! Missed your post. Sorry. Got my negative high byte now, but the low byte is always 3 in the newest VICE. Will look into that some time in the future…Mike wrote:In my earlier post I was referring to the VIA 6522 data sheet, which can be found on 6502.org (link). There, the different timer operating modes are clearly laid out.
A man without talent or ambition is most easily pleased. Others set his path and he is content.
https://github.com/SvenMichaelKlose
https://github.com/SvenMichaelKlose
- Mike
- Herr VC
- Posts: 4816
- Joined: Wed Dec 01, 2004 1:57 pm
- Location: Munich, Germany
- Occupation: electrical engineer
Re: VIA timer underflow troubles
If anything, I'd have to apologize. I made an edit to that post while you posted a reply to it.pixel wrote:Oops! Missed your post. Sorry.
If you read T1 count low at the start of an ISR that explicitly handles T1 interrupts *and* the foreground program has a deterministic timing (like a simple JMP *), that arrangement is likely to 'lock' onto a single interrupt latency cycle. As then always the same number of cycles has passed between the VIA causing the interrupt, and the ISR reading T1 low, you'll always read the same value.Got my negative high byte now, but the low byte is always 3 in the newest VICE. Will look into that some time in the future …