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: 490
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: 11386
good question - test it :)
2016-03-30 08:43
oziphantom

Registered: Oct 2014
Posts: 490
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: 11386
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: 490
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: 722
This pattern is very familiar when debugging drive code.
2016-04-04 14:29
Krill

Registered: Apr 2002
Posts: 2980
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: 490
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
algorithm
Ben Breton/Absence o..
Freeze/Blazon
Peacemaker/CENSOR/Hi..
Guests online: 96
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.6)
5 Edge of Disgrace  (9.6)
6 What Is The Matrix 2  (9.6)
7 The Demo Coder  (9.6)
8 Uncensored  (9.6)
9 Comaland 100%  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 Layers  (9.6)
2 No Listen  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 Dawnfall V1.1  (9.5)
7 Rainbow Connection  (9.5)
8 Onscreen 5k  (9.5)
9 Morph  (9.5)
10 Libertongo  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Triad  (9.3)
5 Censor Design  (9.3)
Top Musicians
1 Rob Hubbard  (9.7)
2 Mutetus  (9.7)
3 Jeroen Tel  (9.7)
4 Linus  (9.6)
5 Stinsen  (9.6)

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