Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > CIA SDR Race condition
2016-03-30 07:59
oziphantom

Registered: Oct 2014
Posts: 478
CIA SDR Race condition

Does the SDR on the CIA have a race condition?
If you write before it runs out, it will auto load the byte and send
If you write after it runs out, it will auto load the byte and send
If you write when it runs out, does this then stuff up?
2016-03-30 08:03
chatGPZ

Registered: Dec 2001
Posts: 11111
good question - test it :)
2016-03-30 08:43
oziphantom

Registered: Oct 2014
Posts: 478
well I think I am ;)

I have one system like so

Wait till flag is set to say byte has arrived
Toggle Clock
store byte
loop

and another on the other end

Send Byte
wait for clock to toggle
loop

This works for 59 bytes, then first one is waiting for a byte to arrive which it never does, and the 2nd one is waiting for the clock to toggle after having sent the byte.

This is all in VICE BTW.
Which makes me think that the 2nd one wrote the byte but it didn't latch, so it doesn't send.
2016-03-30 08:46
chatGPZ

Registered: Dec 2001
Posts: 11111
uh, i wouldn't trust VICE at all for this stuff - since the shift register isnt used for anything (in the c64 emu) and it cant be tested easily (on a single machine) chances are that the emulation is simply broken :)
2016-03-30 10:56
lft

Registered: Jul 2007
Posts: 369
When you say "store byte", does that also involve fetching the byte from the CIA? I'm thinking, what if the first party toggles the clock, but before fetching the byte, the second party has already had enough time to transmit a whole new byte, overwriting the first. When this second byte arrives, the flag is already set, and remains set. When the first party thinks it is reading the first byte, it is actually reading the second byte, and clearing the flag. It then waits for the flag to be set again, which never happens, because the second party is waiting for a second clock transition.
This could happen e.g. if the first party got delayed at the wrong time by an interrupt.
2016-03-30 11:30
oziphantom

Registered: Oct 2014
Posts: 478
I think you have the right idea, but for the wrong reason.

Both sides have interupts disabled but. If one steps through in VICE you get this.

What you expect to happen
A 1Mhz      vs   B 2MZ
clock            
                 clock
                 clock
clock            
                 clock
                 clock
clock            
                 clock
                 clock
                 
What actually happens 
A 1Mhz      vs   B 2MZ
clock
clock
clock
clock
clock
clock
                 clock
                 clock
                 clock
                 clock
                 clock
                 clock
                 clock
                 clock
                 clock
                 clock
                 clock
                 clock
                 clock
                 clock
                 clock
                 clock
clock
clock
clock
clock
clock
clock
clock
clock
                 clock
                 clcok
                 clock
                 clock
clock
clock

So it is entirely possible what you said happened.
2016-04-01 08:18
Martin Piper

Registered: Nov 2007
Posts: 634
This pattern is very familiar when debugging drive code.
2016-04-04 14:29
Krill

Registered: Apr 2002
Posts: 2839
Is this on C-64? Because the hardware clocking and handshaking has been broken from the start and only fixed with the C-128, hence the abysmally slow ROM loading using bitbanging and no fastloader on C-64 using hardware bitshifting.

Edit: Never mind, i guess you're not on the serial bus here but rather the user port.
2016-04-06 04:37
oziphantom

Registered: Oct 2014
Posts: 478
128 + 1571
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
Apollyon/ALD
AlexC
mutetus/Ald ^ Ons
cadaver/covertbitops
wil
Joy/Babygang
sln.pixelrat
HOL2001/Quantum
Nith/TRIÉ…D
Acidchild/Padua
Guests online: 61
Top Demos
1 Next Level  (9.8)
2 Mojo  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Comaland 100%  (9.6)
6 No Bounds  (9.6)
7 Uncensored  (9.6)
8 Wonderland XIV  (9.6)
9 Bromance  (9.6)
10 Memento Mori  (9.6)
Top onefile Demos
1 It's More Fun to Com..  (9.7)
2 Party Elk 2  (9.7)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.5)
5 Rainbow Connection  (9.5)
6 TRSAC, Gabber & Pebe..  (9.5)
7 Onscreen 5k  (9.5)
8 Wafer Demo  (9.5)
9 Dawnfall V1.1  (9.5)
10 Quadrants  (9.5)
Top Groups
1 Oxyron  (9.3)
2 Nostalgia  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Crackers
1 Mr. Z  (9.9)
2 S!R  (9.9)
3 Antitrack  (9.8)
4 Mr Zero Page  (9.8)
5 OTD  (9.8)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.057 sec.