usbdux firmware update from Bernd Porr:
authorFrank Mori Hess <fmhess@speakeasy.net>
Sat, 7 Feb 2004 22:20:16 +0000 (22:20 +0000)
committerFrank Mori Hess <fmhess@speakeasy.net>
Sat, 7 Feb 2004 22:20:16 +0000 (22:20 +0000)
Bugfix version of the firmware. When running ./cmd and ./ao_waveform at the same
time I got CRC errors on the USB. Reason: some registers in the FX2 need a
syncdelay. After a write to a register no other write is allowed to any other
register for a certain time. This is called "Syncdelay". Introduced syncdelays
for all EP registers. Now the CRC errors are gone.
Another bugfix: the byte for the CPUCS register was wrong (shifted one bit to
the left). This resulted in undefined processor speed. The speed was chosen just
by chance at power up (12Mhz,24Mhz,48Mhz).

etc/hotplug/usb/usbdux/usbdux_firmware.asm
etc/hotplug/usb/usbdux/usbdux_firmware.hex

index c977254493f7e86bb50a402afb0e8f280c59a371..e9aa88bd3258b5bfc475f169886ed05df6b54c80 100644 (file)
@@ -130,6 +130,9 @@ ep2isoerr_isr:
 ep4isoerr_isr: 
 ep6isoerr_isr: 
 ep8isoerr_isr:
+ep6_isr:
+ep2_isr:
+
 
        push    dps
        push    dpl
@@ -160,18 +163,26 @@ ep8isoerr_isr:
 ;;; then engages in an endless loop
 main:
        mov     DPTR,#CPUCS     ; CPU control register
-       mov     a,#000100100b   ; 48MHz clock
+       mov     a,#00010000b    ; 48Mhz
        movx    @DPTR,a         ; do it
+       lcall   syncdelay
 
        mov     dptr,#INTSETUP  ; IRQ setup register
        mov     a,#08h          ; enable autovector
        movx    @DPTR,a         ; do it
+       lcall   syncdelay
 
        lcall   initAD          ; init the ports to the converters
 
-       lcall   inieplo         ; init the isochronous data-transfer
+       lcall   initeps         ; init the isochronous data-transfer
 
 mloop2:        nop
+       nop
+       nop
+       nop
+       nop
+       nop
+       nop
 
        sjmp    mloop2          ; do nothing. The rest is done by the IRQs
 
@@ -198,14 +209,14 @@ readAD:                           ; mask the control byte
        clr     IOA.1           ; set /CS to zero
        ;; send the control byte to the AD-converter
        mov     R2,#8           ; bit-counter
-S1:     jnb     ACC.7,bitzero  ; jump if Bit7 = 0?
+bitlp: jnb     ACC.7,bitzero   ; jump if Bit7 = 0?
        setb    IOA.2           ; set the DIN bit
        sjmp    clock           ; continue with the clock
 bitzero:clr    IOA.2           ; clear the DIN bit
 clock: setb    IOA.0           ; SCLK = 1
        clr     IOA.0           ; SCLK = 0
         rl      a               ; next Bit
-        djnz    R2,S1
+        djnz    R2,bitlp
 
        ;; continue the aquisition (already started)
        clr     IOA.2           ; clear the DIN bit
@@ -334,9 +345,9 @@ convlo:     ;;
 
 
 
-;;; initilise the transfer for full speed
+;;; initilise the transfer
 ;;; It is assumed that the USB interface is in alternate setting 3
-inieplo:
+initeps:
        mov     dptr,#FIFORESET
        mov     a,#0fh          
        movx    @dptr,a         ; reset all fifos
@@ -354,8 +365,11 @@ inieplo:
        mov     dptr,#EP2BCL    ; "arm" it
        mov     a,#80h
        movx    @DPTR,a         ; can receive data
+       lcall   syncdelay       ; wait to sync
        movx    @DPTR,a         ; can receive data
+       lcall   syncdelay       ; wait to sync
        movx    @DPTR,a         ; can receive data
+       lcall   syncdelay       ; wait to sync
        
        mov     DPTR,#EP4CFG
        mov     a,#10100000b    ; valid
@@ -368,7 +382,9 @@ inieplo:
        mov     dptr,#EP4BCL    ; "arm" it
        mov     a,#80h
        movx    @DPTR,a         ; can receive data
+       lcall   syncdelay       ; wait until we can write again
        movx    @dptr,a         ; make shure its really empty
+       lcall   syncdelay       ; wait
 
        mov     DPTR,#EP6CFG    ; ISO data from here to the host
        mov     a,#11010010b    ; Valid
@@ -427,10 +443,12 @@ sof_isr:
        mov     DPTR,#EP6BCH    ; byte count H
        mov     a,#0            ; is zero
        movx    @DPTR,a
+       lcall   syncdelay       ; wait until we can write again
        
        mov     DPTR,#EP6BCL    ; byte count L
        mov     a,#10H          ; is 8x word = 16 bytes
        movx    @DPTR,a
+       lcall   syncdelay       ; wait until we can write again
        
 epfull:
        ;; do the D/A conversion
@@ -444,7 +462,9 @@ epfull:
        mov     dptr,#EP2BCL    ; "arm" it
        mov     a,#80h
        movx    @DPTR,a         ; can receive data
-       movx    @dptr,a
+       lcall   syncdelay       ; wait for the rec to sync
+       movx    @dptr,a         ; just to make sure that it's empty
+       lcall   syncdelay       ; wait for the rec to sync
 
 epempty:       
        ;; clear INT2
@@ -563,8 +583,11 @@ over_da:
        mov     dptr,#EP4BCL
        mov     a,#80h
        movx    @DPTR,a         ; arm it
+       lcall   syncdelay       ; wait
        movx    @DPTR,a         ; arm it
+       lcall   syncdelay       ; wait
        movx    @DPTR,a         ; arm it
+       lcall   syncdelay       ; wait
 
        ;; clear INT2
        mov     a,EXIF          ; FIRST clear the USB (INT2) interrupt request
@@ -660,71 +683,16 @@ ep6_arm:
        mov     DPTR,#EP6BCH    ; byte count H
        mov     a,#0            ; is zero
        movx    @DPTR,a
+       lcall   syncdelay       ; wait until the length has arrived
        
        mov     DPTR,#EP6BCL    ; byte count L
        mov     a,#10H          ; is one
        movx    @DPTR,a
+       lcall   syncdelay       ; wait until the length has been proc
        ret
        
 
-       
-;;; get all 8 channels in the high speed mode
-;;; not used just now
-ep6_isr:       
-       push    dps
-       push    dpl
-       push    dph
-       push    dpl1
-       push    dph1
-       push    acc
-       push    psw
-       push    00h             ; R0
-       push    01h             ; R1
-       push    02h             ; R2
-       push    03h             ; R3
-       push    04h             ; R4
-       push    05h             ; R5
-       push    06h             ; R6
-       push    07h             ; R7
-               
-       lcall   convlo          ; conversion
-
-       mov     DPTR,#EP6BCH    ; byte count H
-       mov     a,#0            ; is zero
-       movx    @DPTR,a
-       
-       mov     DPTR,#EP6BCL    ; byte count L
-       mov     a,#10H          ; is 8x word = 16 bytes
-       movx    @DPTR,a
-       
-       ;; clear INT2
-       mov     a,EXIF          ; FIRST clear the USB (INT2) interrupt request
-       clr     acc.4
-       mov     EXIF,a          ; Note: EXIF reg is not 8051 bit-addressable
-
-       mov     DPTR,#EPIRQ     ; 
-       mov     a,#01000000b    ; clear the ep6irq
-       movx    @DPTR,a
 
-       pop     07h
-       pop     06h
-       pop     05h
-       pop     04h             ; R4
-       pop     03h             ; R3
-       pop     02h             ; R2
-       pop     01h             ; R1
-       pop     00h             ; R0
-       pop     psw
-       pop     acc 
-       pop     dph1 
-       pop     dpl1
-       pop     dph 
-       pop     dpl 
-       pop     dps
-       reti
-
-
-       
 ;;; converts one analog/digital channel and stores it in EP8
 ;;; also gets the content of the digital ports B and D
 ep8_adc:
@@ -831,69 +799,15 @@ ep8_isr:
        reti
 
 
+;; need to delay every time the byte counters
+;; for the EPs have been changed.
 
-
-
-
-;;; high speed mode, IRQ mode. Asynchronous transmission.
-;;; not used just now
-ep2_isr:
-       push    dps
-       push    dpl
-       push    dph
-       push    dpl1
-       push    dph1
-       push    acc
-       push    psw
-       push    00h             ; R0
-       push    01h             ; R1
-       push    02h             ; R2
-       push    03h             ; R3
-       push    04h             ; R4
-       push    05h             ; R5
-       push    06h             ; R6
-       push    07h             ; R7
-               
-       mov     dptr,#0F000H    ; EP2 fifo buffer
-       lcall   dalo            ; conversion
-
-       mov     dptr,#EP2BCL    ; "arm" it
-       mov     a,#80h
-       movx    @DPTR,a         ; can receive data
-       movx    @dptr,a 
-
-       ;; clear INT2
-       mov     a,EXIF          ; FIRST clear the USB (INT2) interrupt request
-       clr     acc.4
-       mov     EXIF,a          ; Note: EXIF reg is not 8051 bit-addressable
-       
-       mov     DPTR,#EPIRQ     ; points to the usbirq
-       mov     a,#00010000b    ; clear the usbirq of ep 2
-       movx    @DPTR,a
-
-       pop     07h
-       pop     06h
-       pop     05h
-       pop     04h             ; R4
-       pop     03h             ; R3
-       pop     02h             ; R2
-       pop     01h             ; R1
-       pop     00h             ; R0
-       pop     psw
-       pop     acc 
-       pop     dph1 
-       pop     dpl1
-       pop     dph 
-       pop     dpl 
-       pop     dps
-       reti
-
-
-
-
-
-
-
+syncdelay:
+       nop
+       nop
+       nop
+       nop
+       ret
 
 
 .End
index 2c7e548818fb89751b8dfe7530e2795a5415961e..bb3da3e731070f9b717bfa659bb86fcc4a676505 100644 (file)
@@ -1,73 +1,66 @@
 :030000000201A258
 :03004300020100B7
-:1001000002017F000202D40002017F0002017F0091
+:1001000002017F000202EF0002017F0002017F0076
 :1001100002017F0002017F0002017F0002017F00D7
 :1001200002017F0002017F0002017F0002017F00C7
-:10013000020507000203450002042B000204BB0075
+:1001300002017F0002036C0002017F0002049900AB
 :1001400002017F0002017F0002017F0002017F00A7
 :1001500002017F0002017F0002017F0002017F0097
 :1001600002017F0002017F0002017F0002017F0087
 :1001700002017F0002017F0002017F0002017FC0B7
 :1001800086C082C083C084C085C0E0C0D0E591C273
 :10019000E4F591D0D0D0E0D085D084D083D082D087
-:1001A000863290E6007424F090E6687408F012013C
-:1001B000B712027C0080FD75B22775802222547C24
-:1001C0004481C2817A0830E704D2828002C282D29E
-:1001D00080C28023DAF0C2827A05D280C280DAFA45
-:1001E0007C007A047D08D280C280E58030E403EC94
-:1001F0004DFCED03FDDAEF7B007A087D80D280C2F2
-:1002000080E58030E403EB4DFBED03FDDAEFD281B6
-:1002100022759AF8759B0075AF077880E61201BECB
-:10022000EB90E67BF0ECF008E61201BEEB90E67B8B
-:10023000F0ECF008E61201BEEB90E67BF0ECF00883
-:10024000E61201BEEB90E67BF0ECF008E61201BE90
-:10025000EB90E67BF0ECF008E61201BEEB90E67B5B
-:10026000F0ECF008E61201BEEB90E67BF0ECF00853
-:10027000E61201BEEB90E67BF0ECF02290E604740F
-:100280000FF07400F090E6127492F090E61874008B
-:10029000F090E6917480F0F0F090E61374A0F09086
-:1002A000E6197400F090E6957480F0F090E614740E
-:1002B000D2F090E61574E0F090E65E74A0F090E65F
-:1002C0005F74A0F090E65C7402F075E80175A88098
-:1002D0001204AE22C086C082C083C084C085C0E044
-:1002E000C0D0C000C001C002C003C004C005C00629
-:1002F000C007E5AA5420700F12021190E69874000E
-:10030000F090E6997410F0E5AA5401700D90F00099
-:100310001203DB90E6917480F0F0E591C2E4F59170
-:1003200090E65D7402F0D007D006D005D004D0036B
-:10033000D002D001D000D0D0D0E0D085D084D083FE
-:10034000D082D08632C086C082C083C084C085C0BF
-:10035000E0C0D0C000C001C002C003C004C005C0DE
-:1003600006C00790F400E090036C237380068017AA
-:10037000801D802378807A0890F401E0F6A308DAE3
-:10038000FAE47890F6802190F4011203DB80199052
-:10039000F401E0F5B3801190F401E0F5B3A3E0F5CA
-:1003A0009074FF7890F6800090E6957480F0F0F0FD
-:1003B000E591C2E4F59190E65F7420F0D007D00695
-:1003C000D005D004D003D002D001D000D0D0D0E0EE
-:1003D000D085D084D083D082D08632E0A3F8E0FBF1
-:1003E000A3E0FCA3E0A31203ECD8F32254C04430F2
-:1003F0004CC2857A0830E704D2828002C282D28061
-:10040000C28023DAF0EB7A0830E704D2828002C29D
-:1004100082D280C28023DAF0D2852212021190E6C5
-:10042000987400F090E6997410F022C086C082C0E3
-:1004300083C084C085C0E0C0D0C000C001C002C07D
-:1004400003C004C005C006C00712021190E69874EC
-:1004500000F090E6997410F0E591C2E4F59190E611
-:100460005F7440F0D007D006D005D004D003D0028E
-:10047000D001D000D0D0D0E0D085D084D083D0823D
-:10048000D086327890E670107880E61201BE90FC3B
-:1004900000EBF0A3ECF0800990FC00E590F0A3E401
-:1004A000F090E69C7400F090E69D7410F02290E6C7
-:1004B0009C7400F090E69D7401F022C086C082C05A
-:1004C00083C084C085C0E0C0D0C000C001C002C0ED
-:1004D00003C004C005C006C007120483E591C2E44E
-:1004E000F59190E65F7480F0D007D006D005D00477
-:1004F000D003D002D001D000D0D0D0E0D085D084BD
-:10050000D083D082D08632C086C082C083C084C0EF
-:1005100085C0E0C0D0C000C001C002C003C004C09C
-:1005200005C006C00790F0001203DB90E6917480CE
-:10053000F0F0E591C2E4F59190E65F7410F0D00719
-:10054000D006D005D004D003D002D001D000D0D046
-:0D055000D0E0D085D084D083D082D0863218
+:1001A000863290E6007410F01204E590E668740858
+:1001B000F01204E51201C3120288000000000000E2
+:1001C0000080F775B22775802222547C4481C28159
+:1001D0007A0830E704D2828002C282D280C28023B1
+:1001E000DAF0C2827A05D280C280DAFA7C007A0420
+:1001F0007D08D280C280E58030E403EC4DFCED0345
+:10020000FDDAEF7B007A087D80D280C280E5803005
+:10021000E403EB4DFBED03FDDAEFD28122759AF892
+:10022000759B0075AF077880E61201CAEB90E67BFC
+:10023000F0ECF008E61201CAEB90E67BF0ECF00877
+:10024000E61201CAEB90E67BF0ECF008E61201CA78
+:10025000EB90E67BF0ECF008E61201CAEB90E67B4F
+:10026000F0ECF008E61201CAEB90E67BF0ECF00847
+:10027000E61201CAEB90E67BF0ECF008E61201CA48
+:10028000EB90E67BF0ECF02290E604740FF0740043
+:10029000F090E6127492F090E6187400F090E691F7
+:1002A0007480F01204E5F01204E5F01204E590E623
+:1002B0001374A0F090E6197400F090E6957480F045
+:1002C0001204E5F01204E590E61474D2F090E615FD
+:1002D00074E0F090E65E74A0F090E65F74A0F09099
+:1002E000E65C7402F075E80175A88012048C22C0E7
+:1002F00086C082C083C084C085C0E0C0D0C000C0BA
+:1003000001C002C003C004C005C006C007E5AA546E
+:1003100020701512021D90E6987400F01204E5900A
+:10032000E6997410F01204E5E5AA5401701390F0F8
+:100330000012040B90E6917480F01204E5F01204B0
+:10034000E5E591C2E4F59190E65D7402F0D007D046
+:1003500006D005D004D003D002D001D000D0D0D038
+:10036000E0D085D084D083D082D08632C086C0824F
+:10037000C083C084C085C0E0C0D0C000C001C0023E
+:10038000C003C004C005C006C00790F400E090039D
+:1003900093237380068017801D802378807A0890CD
+:1003A000F401E0F6A308DAFAE47890F6802190F4FC
+:1003B0000112040B801990F401E0F5B3801190F460
+:1003C00001E0F5B3A3E0F59074FF7890F68000901B
+:1003D000E6957480F01204E5F01204E5F01204E5ED
+:1003E000E591C2E4F59190E65F7420F0D007D00665
+:1003F000D005D004D003D002D001D000D0D0D0E0BE
+:10040000D085D084D083D082D08632E0A3F8E0FBC0
+:10041000A3E0FCA3E0A312041CD8F32254C0443090
+:100420004CC2857A0830E704D2828002C282D28030
+:10043000C28023DAF0EB7A0830E704D2828002C26D
+:1004400082D280C28023DAF0D2852212021D90E689
+:10045000987400F01204E590E6997410F01204E527
+:10046000227890E670107880E61201CA90FC00EBCA
+:10047000F0A3ECF0800990FC00E590F0A3E4F0908C
+:10048000E69C7400F090E69D7410F02290E69C7457
+:1004900000F090E69D7401F022C086C082C083C047
+:1004A00084C085C0E0C0D0C000C001C002C003C08D
+:1004B00004C005C006C007120461E591C2E4F591CD
+:1004C00090E65F7480F0D007D006D005D004D0034A
+:1004D000D002D001D000D0D0D0E0D085D084D0835D
+:0A04E000D082D08632000000002216
 :00000001FF