Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
154 lines (154 sloc) 9.76 KB
0000- 2 .TF lcd2_1852.hex,HEX
0000- 3 *
0000- 4 * SC1602 LCD Display program 1 for COSMAC CDP1852
0000- 5 * SB-Assembler
0000- 6 *
0000- 7 .CR 1802 ;To load the 1802 cross overlay
0000- 8 .OR $0000
0000- 9 *
0000- 10 * CDP1852 SC1602LCD
0000- 11 * DATA_RDY ----> E(6)
0000- 12 * DO0 ---------> DB4(11)
0000- 13 * DO1 ---------> DB5(12)
0000- 14 * DO2 ---------> DB6(13)
0000- 15 * DO3 ---------> DB7(14)
0000- 16 * DO7 ---------> RS(4)
0000- 17 * GND--> R/W(5)
0000- 18 * GND--> GND(2)
0000- 19 * +5V--> VDD(1)
0000- 20 *
0000-F8 2D 21 ( 2) START LDI #MAIN ;R3 = MAIN
0002-A3 22 ( 2) PLO 3 ;D -> R(3).0
0003-F8 45 23 ( 2) LDI #WAIT1 ;R7 = WAIT
0005-A7 24 ( 2) PLO 7 ;D -> R(7).0
0006-F8 4D 25 ( 2) LDI #SEND1 ;R8 = SEND
0008-A8 26 ( 2) PLO 8 ;D -> R(8).0
0009-F8 13 27 ( 2) LDI #INTDAT ;INTDAT -> D
000B-A4 28 ( 2) PLO 4 ;D -> R(4).0
000C-F8 00 29 ( 2) LDI #0 ;0 -> D
000E-B3 30 ( 2) PHI 3 ;D -> R(3).1
000F-B7 31 ( 2) PHI 7 ;D -> R(7).1
0010-B8 32 ( 2) PHI 8 ;D -> R(8).1
0011-B4 33 ( 2) PHI 4 ;D -> R(4).1
0012-D3 34 ( 2) SEP 3 ; Jump MAIN
0013- 35 *
0013- 36 *---------------------------
0013- 37 * LCD Initialize Data(4bit mode, RS=0)
0013- 38 *---------------------------
0013-03 39 INTDAT .DB $03 ;Function set (Interface is 8bits long.)
0014- 40 * ;wait 4.1ms
0014-03 41 .DB $03 ;Function set (Interface is 8bits long.)
0015- 42 * ;wait 100us
0015-03 43 .DB $03 ;Function set (Interface is 8bits long.)
0016- 44 * ;wait 40us
0016-02 45 .DB $02 ;Function set (Set interface to be 4 bits long.)
0017- 46 * ;wait 40us
0017-02 47 .DB $02 ;Function set (2Line mode)
0018-08 48 .DB $08 ;
0019- 49 * ;wait 40us
0019-00 50 .DB $00 ;Display OFF, Cursor OFF, Blink OFF
001A-08 51 .DB $08 ;
001B- 52 * ;wait 40us
001B-00 53 .DB $00 ;Clear Display
001C-01 54 .DB $01 ;
001D- 55 * ;wait 1.64ms
001D-00 56 .DB $00 ;Entry Mode Set(Cursor right, shift off)
001E-06 57 .DB $06 ;
001F- 58 * ;wait 40us
001F-00 59 .DB $00 ;Display ON, Cursor OFF, Blink OFF
0020-0C 60 .DB $0C ;
0021- 61 * ;wait 40us
0021- 62 *---------------------------
0021- 63 * LCD Display data(4bit mode, bit7=RS=1)
0021- 64 *---------------------------
0021-84 65 .DB $84 ;"C" $43
0022-83 66 .DB $83 ;
0023- 67 * ;wait 40us
0023-84 68 .DB $84 ;"O" $4F
0024-8F 69 .DB $8F ;
0025- 70 * ;wait 40us
0025-85 71 .DB $85 ;"S" $53
0026-83 72 .DB $83 ;
0027- 73 * ;wait 40us
0027-84 74 .DB $84 ;"M" $4D
0028-8D 75 .DB $8D ;
0029- 76 * ;wait 40us
0029-84 77 .DB $84 ;"A" $41
002A-81 78 .DB $81 ;
002B- 79 * ;wait 40us
002B-84 80 .DB $84 ;"C" $43
002C-83 81 .DB $83 ;
002D- 82 * ;wait 40us
002D- 83 *----------------------
002D- 84 * Main routine
002D- 85 *----------------------
002D-E4 86 ( 2) MAIN SEX 4 ;4 -> X
002E- 87 *
002E- 88 * LCD Initrize
002E- 89 *
002E- 90 * Function set (Interface is 8bits long.)
002E- 91 *
002E-65 92 ( 2) OUT 5 ;M(R(X))->BUS, R(X)++
002F- 93 *
002F- 94 * Wait 4.1ms
002F- 95 *
002F-F8 AA 96 ( 2) LDI #170 ;Load immediate value 170 into 0
0031-D7 97 ( 2) SEP 7 ;Call WaitSub
0032- 98 *
0032- 99 * Function set (Interface is 8bits long.)
0032- 100 *
0032-65 101 ( 2) OUT 5 ;M(R(X))->BUS, R(X)++
0033- 102 *
0033- 103 * Wait 100us
0033- 104 *
0033-F8 04 105 ( 2) LDI #4 ;Load immediate value 4 into 0
0035-D7 106 ( 2) SEP 7 ;Call WaitSub
0036- 107 *
0036- 108 * Send Initrize command (8byte)
0036- 109 *
0036-F8 08 110 ( 2) LDI #8 ;Send 8 byte
0038-D8 111 ( 2) SEP 8 ;Call SEND
0039- 112 *
0039- 113 * Wait 1.64ms
0039- 114 *
0039-F8 40 115 ( 2) LDI #64 ;Load immediate value 64 into 0
003B-D7 116 ( 2) SEP 7
003C- 117 *
003C- 118 * Send Enrty Mode Set/Set Address
003C- 119 *
003C-F8 04 120 ( 2) LDI #4 ;Send 4 byte
003E-D8 121 ( 2) SEP 8 ;Call SEND
003F- 122 *
003F- 123 * Write data to RAM (bit7=RS=1)
003F- 124 *
003F-F8 0C 125 ( 2) LDI #12 ;Send 12 byte
0041-D8 126 ( 2) SEP 8 ;Call SEND
0042- 127 *
0042-30 42 128 ( 2) STOP BR STOP ;HALT
0044- 129 *
0044- 130 * WAIT SUB ROUTINE
0044- 131 *
0044-D3 132 ( 2) EXIT1 SEP 3
0045-A5 133 ( 2) WAIT1 PLO 5 ;Put D in R5,0
0046-25 134 ( 2) LOOP2 DEC 5 ;Decrement R5 by 1 over 8 bits
0047-85 135 ( 2) GLO 5 ;Get R5.0 to test
0048-3A 46 136 ( 2) BNZ LOOP2 ;If R5.0 != 0, branch to LOOP
004A-30 44 137 ( 2) BR EXIT1
004C- 138 *
004C- 139 * SEND n byte SUB ROUTINE
004C- 140 *
004C-D3 141 ( 2) EXIT2 SEP 3
004D-A5 142 ( 2) SEND1 PLO 5 ;Put D in R(5).0
004E-65 143 ( 2) LOOP6 OUT 5 ;M(R(X)) -> BUS; R(X)++
004F-C4 144 ( 2) NOP ;WAIT
0050-C4 145 ( 2) NOP ;WAIT
0051-C4 146 ( 2) NOP ;WAIT
0052-C4 147 ( 2) NOP ;WAIT
0053-C4 148 ( 2) NOP ;WAIT
0054-C4 149 ( 2) NOP ;WAIT
0055-25 150 ( 2) DEC 5 ;Decrement R5
0056-85 151 ( 2) GLO 5 ;Get R5.0 to test
0057-3A 4E 152 ( 2) BNZ LOOP6 ;If R(5).0 != 0, branch to LOOP
0059-30 4C 153 ( 2) BR EXIT2
005B- 154
005B- 155 .EN
You can’t perform that action at this time.