View Single Post
Old 17 March 2020, 21:36   #8
saimo
Registered User
 
saimo's Avatar
 
Join Date: Aug 2010
Location: Italy
Posts: 832
@Toni

Quote:
Originally Posted by saimo View Post
Later I'll whip up a test proggie and post it here.
I have reimplemented ReadByte() this way:

Code:
************************************************************************************************************************
* INFO              Reads a byte.
*
* IN                a0.w                source address in [0, 1023]
*                   a2.l                CB_CIAA + RO_CIA_PRA
*                   a3.l                CB_AKIKO + RO_NVRAMSIG
*                   a4.l                CB_AKIKO + RO_NVRAMDIR
*
* OUT               d0.b                byte
*
* TRASH             d3/d4
************************************************************************************************************************

ReadByte            move.b              #NM_SCL,(a4)        ;set NVRAMDIR.SDA to input
                    bsr                 delay               ;(to be safe)
                    moveq.l             #7,d3               ;set counter

.read               clr.b               (a3)                ;pull SCL low
                    bsr                 delay
                    move.b              #NM_SCL,(a3)        ;pull SCL high
                    bsr                 delay
                    move.b              (a3),d0             ;read data
                    lsl.b               #2,d0               ;put SDA in ccr.X
                    addx.b              d4,d4               ;shift ccr.X in
                    dbra                d3,.read            ;pass to next bit

                    move.b              d4,d0               ;get result
                    lsl.b               #7,d4
                    lsr.b               #1,d4
                    move.b              d4,NVRAM_LastBit    ;store last bit
                    move.b              #NM_SCL|NM_SDA,(a4) ;set NVRAMDIR.SDA to output
                    bsr                 delay               ;(to be safe)
                    rts
As you can see, the data direction is changed only before and after reading all the bits.
On WinUAE it works in the context of both the bigger program I'm doing all this for and the test proggie.

You can find the latter attached here. It takes over the system, dumps the NVRAM to RAM:NVRAM.raw, restores the system, and quits.
I'm sending it to my tester, too, and when I have a response I'll let you know.

Last edited by saimo; 09 July 2021 at 09:56.
saimo is online now  
 
Page generated in 0.04377 seconds with 11 queries