[comp.sys.atari.st] Read/Write to DMA port

ZUCCONI@FRMOP11.BITNET (02/14/90)

Date: 13 February 1990, 23:37:13 GMT
From: J.-M. Zucconi             (+33) 81666900       ZUCCONI  at FRMOP11
To:   info-atari16@wsmr-simtel20.army.mil
Subject: read/write to the DMA port


        I try to use the DMA port to write and read data (not in DMA mode)
typically to send commands to an external controller. The problem I meet
is that I can't read safely from the DMA port. After several checkings
I have found that I always read the last byte written on the port. Further
investigations show that if I wait 'some' time before reading the port, the
value returns to zero. The following code shows that. It should be noted
that during execution, NOTHING is connected to the DMA port!
        I write the value 0xff to the port. If the parameter 'time' is set
to 0x1fff, I read 0xff. when time is set to 0x5fff, I read 0x0 (correctly?)
and if time is set to 0x3fff, I get 0xe0 !!!

Could someone tell me what is wrong in my code and how to write/read via the
DMA port?

        Thanks
                J.-M.

------------ CUT HERE -----------------------------------------------
flock   EQU     $43E
diskctl EQU     $FF8604
fifo    EQU     $FF8606

; ...initializations take place here

        BSR     super_on        ;go in supervisor mode
        ST      flock           ;turn off floppy
        MOVE    #$1C8,fifo      ;set DMA mode register to write data

        MOVE    #$FF,diskctl    ;write data on DMA port

        MOVE    #$C8,fifo       ;set DMA mode register to read data
        BSR     pause           ; pause

        MOVE    diskctl,D0      ;read data on DMA port
        BSR     affiche_status  ;and prints value
        SF      flock           ;turn on floppy
        BSR     super_off       ;return in user mode

; end of the program...

pause   MOVE.L  #time,D1 ;delay loop. time is set between $1FFF and $5FFF
loop    SUB.L   #1,D1
        BNE     loop
        RTS

------------ CUT HERE -----------------------------------------------
-*-*-*-*-*-*-*-*-*-*-*
Jean-Marc Zucconi
ZUCCONI@FRMOP11.BITNET
*-*-*-*-*-*-*-*-*-*-*-