Changeset 53d1ddc in avrstuff
- Timestamp:
- Oct 29, 2010, 6:24:23 PM (14 years ago)
- Branches:
- main
- Children:
- 741c0b9
- Parents:
- 1dc9759
- Location:
- CPC stuff/cpc_serial_2313/code
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
CPC stuff/cpc_serial_2313/code/main.asm
r1dc9759 r53d1ddc 2 2 ; Copyright 2010, Adrien Destugues <pulkomandy@pulkomandy.ath.cx> 3 3 ; Distributed under the terms of the MIT Licence 4 .INCLUDE "2313def.inc" 4 5 5 6 ; Firmware for µSerial expansion board 6 7 8 .EQU ALL_OUT = 255 9 .EQU ALL_IN = 0 10 11 .EQU DATADIR = DDRB 12 .EQU DATAOUT = PORTB 13 .EQU DATAIN = PINB 14 15 .EQU CTRLIN = PIND 16 .EQU A0 = PIND4 17 18 .EQU curregbak = SRAM_START 19 20 .CSEG 7 21 ; Vectors 8 22 ; reset 23 RJMP init 9 24 ; int0 10 25 RJMP cpc_write … … 24 39 25 40 ; --- READ INTERRUPT --- 26 cpc_read 41 cpc_read: 27 42 ; That means we only have 5 cycles left to output the value on the BUS! 28 43 ; We have no time to do anything, so we assume that X is already pointing at … … 38 53 ; We assume X (R26:R27) points to the current reg 39 54 ; So we can load it and react fast enough to the interrupt 40 LDI R 0,ALL_OUT ; 1 ; peut être économisé si on sacrifie un reg55 LDI R16,ALL_OUT ; 1 ; peut être économisé si on sacrifie un reg 41 56 OUT DATADIR,R0 ; 1 42 LD R27, (X); 2 cycles ; peut être économisé si un reg. contient57 LD R27,X ; 2 cycles ; peut être économisé si un reg. contient 43 58 ; déjà la valeur à envoyer 44 59 ; (mais qui l'update ?) 45 OUT DATA , R27 ; 1 cycle60 OUT DATAOUT, R27 ; 1 cycle 46 61 47 62 ; Here data is sent, the CPC read operation is handled. … … 53 68 54 69 ; Restore R27 55 LD R27,curregbak56 LD R27, (X)70 LDI R27,curregbak 71 LD R27,X 57 72 58 73 ; release the bus 59 LDI R 0,ALL_IN60 OUT DATADIR, R 074 LDI R16,ALL_IN 75 OUT DATADIR, R16 61 76 62 77 ; Restore R27 to selected reg. (we erased it to do the OUT) 63 78 RETI 64 79 80 65 81 ; --- WRITE INTERRUPT --- 66 cpc_write 82 cpc_write: 67 83 ; The timing is a bit less constraining here. 68 84 PUSH R0 69 IN R0,DATA 85 IN R0,DATAIN 70 86 ; we also need to know A0 state... 71 SBIS CTRL ,A087 SBIS CTRLIN,A0 72 88 ; This was actually a reg select operation! 73 89 ; Jump to the proper code … … 79 95 RJMP intEnd 80 96 81 regSel 82 LD R27,curregbak83 ST (X),R097 regSel: 98 LDI R27,curregbak 99 ST X,R0 84 100 MOV R27,R0 85 101 102 intEnd: 86 103 POP R0 87 104 RETI … … 92 109 ; At a bare minimum : 93 110 ; * Set up the INT0 and INT1 so the CPC can do the rest of the setup itself 111 init: 112 RJMP init
Note:
See TracChangeset
for help on using the changeset viewer.