📄 clock.rmh
字号:
// #1078: ;// @2c1 #1079: [LCD_write_inst4]0a4f8 // @2c1 #1079: AND(s4,F8) ;Enable=1 RS=0 Instruction, RW=0 Write, E=02c440 // @2c2 #1080: OUTPUT(s4,LCD_output_port) ;set up RS and RW >40ns before enable pulse302bb // @2c3 #1081: CALL(LCD_pulse_E)2a000 // @2c4 #1082: RETURN// #1083: ;// #1084: ;// #1085: ;Write 8-bit instruction to LCD display.// #1086: ;// #1087: ;The 8-bit instruction should be provided in register s5.// #1088: ;Instructions are written using the following sequence// #1089: ; Upper nibble// #1090: ; wait >1us// #1091: ; Lower nibble// #1092: ; wait >40us// #1093: ;// #1094: ;Registers used s0, s1, s4, s5// #1095: ;// @2c5 #1096: [LCD_write_inst8]01450 // @2c5 #1096: LOAD(s4,s5)0a4f0 // @2c6 #1097: AND(s4,F0) ;Enable=0 RS=0 Instruction, RW=0 Write, E=00c408 // @2c7 #1098: OR(s4,LCD_drive) ;Enable=1302c1 // @2c8 #1099: CALL(LCD_write_inst4) ;write upper nibble302a3 // @2c9 #1100: CALL(delay_1us) ;wait >1us01450 // @2ca #1101: LOAD(s4,s5) ;select lower nibble with20407 // @2cb #1102: SL1(s4) ;Enable=120406 // @2cc #1103: SL0(s4) ;RS=0 Instruction20406 // @2cd #1104: SL0(s4) ;RW=0 Write20406 // @2ce #1105: SL0(s4) ;E=0302c1 // @2cf #1106: CALL(LCD_write_inst4) ;write lower nibble302a7 // @2d0 #1107: CALL(delay_40us) ;wait >40us004f0 // @2d1 #1108: LOAD(s4,F0) ;Enable=0 RS=0 Instruction, RW=0 Write, E=02c440 // @2d2 #1109: OUTPUT(s4,LCD_output_port) ;Release master enable2a000 // @2d3 #1110: RETURN// #1111: ;// #1112: ;// #1113: ;// #1114: ;Write 8-bit data to LCD display.// #1115: ;// #1116: ;The 8-bit data should be provided in register s5.// #1117: ;Data bytes are written using the following sequence// #1118: ; Upper nibble// #1119: ; wait >1us// #1120: ; Lower nibble// #1121: ; wait >40us// #1122: ;// #1123: ;Registers used s0, s1, s4, s5// #1124: ;// @2d4 #1125: [LCD_write_data]01450 // @2d4 #1125: LOAD(s4,s5)0a4f0 // @2d5 #1126: AND(s4,F0) ;Enable=0 RS=0 Instruction, RW=0 Write, E=00c40c // @2d6 #1127: OR(s4,12) ;Enable=1 RS=1 Data, RW=0 Write, E=02c440 // @2d7 #1128: OUTPUT(s4,LCD_output_port) ;set up RS and RW >40ns before enable pulse302bb // @2d8 #1129: CALL(LCD_pulse_E) ;write upper nibble302a3 // @2d9 #1130: CALL(delay_1us) ;wait >1us01450 // @2da #1131: LOAD(s4,s5) ;select lower nibble with20407 // @2db #1132: SL1(s4) ;Enable=120407 // @2dc #1133: SL1(s4) ;RS=1 Data20406 // @2dd #1134: SL0(s4) ;RW=0 Write20406 // @2de #1135: SL0(s4) ;E=02c440 // @2df #1136: OUTPUT(s4,LCD_output_port) ;set up RS and RW >40ns before enable pulse302bb // @2e0 #1137: CALL(LCD_pulse_E) ;write lower nibble302a7 // @2e1 #1138: CALL(delay_40us) ;wait >40us004f0 // @2e2 #1139: LOAD(s4,F0) ;Enable=0 RS=0 Instruction, RW=0 Write, E=02c440 // @2e3 #1140: OUTPUT(s4,LCD_output_port) ;Release master enable2a000 // @2e4 #1141: RETURN// #1142: ;// #1143: ;// #1144: ;// #1145: ;// #1146: ;Read 8-bit data from LCD display.// #1147: ;// #1148: ;The 8-bit data will be read from the current LCD memory address// #1149: ;and will be returned in register s5.// #1150: ;It is advisable to set the LCD address (cursor position) before// #1151: ;using the data read for the first time otherwise the display may// #1152: ;generate invalid data on the first read.// #1153: ;// #1154: ;Data bytes are read using the following sequence// #1155: ; Upper nibble// #1156: ; wait >1us// #1157: ; Lower nibble// #1158: ; wait >40us// #1159: ;// #1160: ;Registers used s0, s1, s4, s5// #1161: ;// #1162: ;LCD_read_data8: LOAD s4, 0E ;Enable=1 RS=1 Data, RW=1 Read, E=0// #1163: ; OUTPUT s4, LCD_output_port ;set up RS and RW >40ns before enable pulse// #1164: ; XOR s4, LCD_E ;E=1// #1165: ; OUTPUT s4, LCD_output_port// #1166: ; CALL delay_1us ;wait >260ns to access data// #1167: ; INPUT s5, LCD_input_port ;read upper nibble// #1168: ; XOR s4, LCD_E ;E=0// #1169: ; OUTPUT s4, LCD_output_port// #1170: ; CALL delay_1us ;wait >1us// #1171: ; XOR s4, LCD_E ;E=1// #1172: ; OUTPUT s4, LCD_output_port// #1173: ; CALL delay_1us ;wait >260ns to access data// #1174: ; INPUT s0, LCD_input_port ;read lower nibble// #1175: ; XOR s4, LCD_E ;E=0// #1176: ; OUTPUT s4, LCD_output_port// #1177: ; AND s5, F0 ;merge upper and lower nibbles// #1178: ; SR0 s0// #1179: ; SR0 s0// #1180: ; SR0 s0// #1181: ; SR0 s0// #1182: ; OR s5, s0// #1183: ; LOAD s4, 04 ;Enable=0 RS=1 Data, RW=0 Write, E=0// #1184: ; OUTPUT s4, LCD_output_port ;Stop reading 5V device and release master enable// #1185: ; CALL delay_40us ;wait >40us// #1186: ; RETURN// #1187: ;// #1188: ;// #1189: ;Reset and initialise display to communicate using 4-bit data mode// #1190: ;Includes routine to clear the display.// #1191: ;// #1192: ;Requires the 4-bit instructions 3,3,3,2 to be sent with suitable delays// #1193: ;following by the 8-bit instructions to set up the display.// #1194: ;// #1195: ; 28 = '001' Function set, '0' 4-bit mode, '1' 2-line, '0' 5x7 dot matrix, 'xx'// #1196: ; 06 = '000001' Entry mode, '1' increment, '0' no display shift// #1197: ; 0C = '00001' Display control, '1' display on, '0' cursor off, '0' cursor blink off// #1198: ; 01 = '00000001' Display clear// #1199: ;// #1200: ;Registers used s0, s1, s2, s3, s4// #1201: ;// @2e5 #1202: [LCD_reset]302b1 // @2e5 #1202: CALL(delay_20ms) ;wait more that 15ms for display to be ready00430 // @2e6 #1203: LOAD(s4,48)302c1 // @2e7 #1204: CALL(LCD_write_inst4) ;send '3'302b1 // @2e8 #1205: CALL(delay_20ms) ;wait >4.1ms302c1 // @2e9 #1206: CALL(LCD_write_inst4) ;send '3'302ac // @2ea #1207: CALL(delay_1ms) ;wait >100us302c1 // @2eb #1208: CALL(LCD_write_inst4) ;send '3'302a7 // @2ec #1209: CALL(delay_40us) ;wait >40us00420 // @2ed #1210: LOAD(s4,32)302c1 // @2ee #1211: CALL(LCD_write_inst4) ;send '2'302a7 // @2ef #1212: CALL(delay_40us) ;wait >40us00528 // @2f0 #1213: LOAD(s5,40) ;Function set302c5 // @2f1 #1214: CALL(LCD_write_inst8)00506 // @2f2 #1215: LOAD(s5,6) ;Entry mode302c5 // @2f3 #1216: CALL(LCD_write_inst8)0050c // @2f4 #1217: LOAD(s5,12) ;Display control302c5 // @2f5 #1218: CALL(LCD_write_inst8)// @2f6 #1219: [LCD_clear]00501 // @2f6 #1219: LOAD(s5,1) ;Display clear302c5 // @2f7 #1220: CALL(LCD_write_inst8)302ac // @2f8 #1221: CALL(delay_1ms) ;wait >1.64ms for display to clear302ac // @2f9 #1222: CALL(delay_1ms)00513 // @2fa #1223: LOAD(s5,19)30313 // @2fb #1224: CALL(LCD_cursor)0053a // @2fc #1225: LOAD(s5,58) ;;;;;;;;;;;;;;;;;;;;;;; :302d4 // @2fd #1226: CALL(LCD_write_data)00516 // @2fe #1227: LOAD(s5,22)30313 // @2ff #1228: CALL(LCD_cursor)0052d // @300 #1229: LOAD(s5,45) ;;;;;;;;;;;;;;;;;;;;;; -302d4 // @301 #1230: CALL(LCD_write_data)00520 // @302 #1231: LOAD(s5,32)30313 // @303 #1232: CALL(LCD_cursor)0052d // @304 #1233: LOAD(s5,45) ;;;;;;;;;;;;;;;;;;;;;; -302d4 // @305 #1234: CALL(LCD_write_data)0052d // @306 #1235: LOAD(s5,45) ;;;;;;;;;;;;;;;;;;;;;; -302d4 // @307 #1236: CALL(LCD_write_data)0052d // @308 #1237: LOAD(s5,45) ;;;;;;;;;;;;;;;;;;;;;; -302d4 // @309 #1238: CALL(LCD_write_data)00528 // @30a #1239: LOAD(s5,40)30313 // @30b #1240: CALL(LCD_cursor)0052f // @30c #1241: LOAD(s5,47) ;;;;;;;;;;;;;;;;;;;;;; /302d4 // @30d #1242: CALL(LCD_write_data)0052b // @30e #1243: LOAD(s5,43)30313 // @30f #1244: CALL(LCD_cursor)0052f // @310 #1245: LOAD(s5,47) ;;;;;;;;;;;;;;;;;;;;;; -302d4 // @311 #1246: CALL(LCD_write_data)2a000 // @312 #1247: RETURN// #1248: ;// #1249: ;Position the cursor ready for characters to be written.// #1250: ;The display is formed of 2 lines of 16 characters and each// #1251: ;position has a corresponding address as indicated below.// #1252: ;// #1253: ; Character position// #1254: ; 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15// #1255: ;// #1256: ; Line 1 - 80 81 82 83 84 85 86 87 88 89 8A 8B 8C 8D 8E 8F// #1257: ; Line 2 - C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF// #1258: ;// #1259: ;This routine will set the cursor position using the value provided// #1260: ;in register s5. The upper nibble will define the line and the lower// #1261: ;nibble the character position on the line.// #1262: ; Example s5 = 2B will position the cursor on line 2 position 11// #1263: ;// #1264: ;Registers used s0, s1, s2, s3, s4// #1265: ;// @313 #1266: [LCD_cursor]12510 // @313 #1266: TEST(s5,16) ;test for line 135319 // @314 #1267: JUMP(Z,set_line2)0a50f // @315 #1268: AND(s5,15) ;make address in range 80 to 8F for line 10c580 // @316 #1269: OR(s5,128)302c5 // @317 #1270: CALL(LCD_write_inst8) ;instruction write to set cursor2a000 // @318 #1271: RETURN// @319 #1272: [set_line2]0a50f // @319 #1272: AND(s5,15) ;make address in range C0 to CF for line 20c5c0 // @31a #1273: OR(s5,C0)302c5 // @31b #1274: CALL(LCD_write_inst8) ;instruction write to set cursor2a000 // @31c #1275: RETURN// #1276: ;// #1277: ;This routine will shift the complete display one position to the left.// #1278: ;The cursor position and LCD memory contents will not change.// #1279: ;// #1280: ;// #1281: ;Registers used s0, s1, s2, s3, s4, s5// #1282: ;// #1283: ;LCD_shift_left: LOAD s5, 18 ;shift display left// #1284: ; CALL LCD_write_inst8// #1285: ; RETURN// #1286: ;// #1287: ;**************************************************************************************// #1288: ;Interrupt Service Routine (ISR)// #1289: ;**************************************************************************************// @31d #1290: [ISR]2e001 // @31d #1290: STORE(s0,ISR_s0) ;preserve s02e112 // @31e #1291: STORE(s1,ISR_s1)2e215 // @31f #1292: STORE(s2,ISR_s2)04101 // @320 #1293: INPUT(s1,rotary_port)00000 // @321 #1294: LOAD(s0,0)12102 // @322 #1295: TEST(s1,rotary_press)35331 // @323 #1296: JUMP(Z,no_press)06017 // @324 #1297: FETCH(s0,pressed)14000 // @325 #1298: COMPARE(s0,0)35731 // @326 #1299: JUMP(NZ,no_press)06202 // @327 #1300: FETCH(s2,LED_pattern)18201 // @328 #1301: ADD(s2,1)2e202 // @329 #1302: STORE(s2,LED_pattern)06203 // @32a #1303: FETCH(s2,mode)18201 // @32b #1304: ADD(s2,1)14207 // @32c #1305: COMPARE(s2,7)3572f // @32d #1306: JUMP(NZ,mode_save)0a200 // @32e #1307: AND(s2,0)// @32f #1308: [mode_save]2e203 // @32f #1308: STORE(s2,mode) ;;;;;0-normal;1-hour;2-min;3-sec;4-day,5-mon,6-year000ff // @330 #1309: LOAD(s0,FF)// @331 #1310: [no_press]2e017 // @331 #1310: STORE(s0,pressed)12140 // @332 #1311: TEST(s1,64) ;;;rotary INT ?353b3 // @333 #1312: JUMP(Z,T2_5m_INT) ;;NOT rotary INT,JUMP away// @334 #1313: [CLR_INT2]00040 // @334 #1313: LOAD(s0,64) ;;;;;CLR_INT12c020 // @335 #1314: OUTPUT(s0,32)06002 // @336 #1315: FETCH(s0,LED_pattern)12101 // @337 #1316: TEST(s1,rotary_left)35374 // @338 #1317: JUMP(Z,ITS_RIGHT)180ff // @339 #1318: ADD(s0,FF)2e002 // @33a #1319: STORE(s0,LED_pattern)// #1320: ;;;turn left,--06003 // @33b #1321: FETCH(s0,mode)14000 // @33c #1322: COMPARE(s0,0)353b1 // @33d #1323: JUMP(Z,CLR_INT1) ;14001 // @33e #1324: COMPARE(s0,1)35747 // @33f #1325: JUMP(NZ,MODE2N)06121 // @340 #1326: FETCH(s1,hourB)181ff // @341 #1327: ADD(s1,FF)141ff // @342 #1328: COMPARE(s1,FF) ;;;2435745 // @343 #1329: JUMP(NZ,SAVE_HHN)00117 // @344 #1330: LOAD(s1,23)// @345 #1331: [SAVE_HHN]2e121 // @345 #1331: STORE(s1,hourB)343ee // @346 #1332: JUMP(real_time_end)// @347 #1333: [MODE2N]14002 // @347 #1333: COMPARE(s0,2)35750 // @348 #1334: JUMP(NZ,MODE3N)06122 // @349 #1335: FETCH(s1,minB)181ff // @34a #1336: ADD(s1,FF)141ff // @34b #1337: COMPARE(s1,FF) ;;;3C;;603574e // @34c #1338: JUMP(NZ,SAVE_MMN)0013b // @34d #1339: LOAD(s1,59)// @34e #1340: [SAVE_MMN]2e122 // @34e #1340: STORE(s1,minB)343ee // @34f #1341: JUMP(real_time_end)// @350 #1342: [MODE3N]14003 // @350 #1342: COMPARE(s0,3)35759 // @351 #1343: JUMP(NZ,MODE4N)06123 // @352 #1344: FETCH(s1,secB)181ff // @353 #1345: ADD(s1,FF)141ff // @354 #1346: COMPARE(s1,FF) ;;;6035757 // @355 #1347: JUMP(NZ,SAVE_SSN)0013b // @356 #1348: LOAD(s1,59)// @357 #1349: [SAVE_SSN]2e123 // @357 #1349: STORE(s1,secB)343ee // @358 #1350: JUMP(real_time_end)// @359 #1351: [MODE4N]14004 // @359 #1351: COMPARE(s0,4)35762 // @35a #1352: JUMP(NZ,MODE5N)06125 // @35b #1353: FETCH(s1,monB)181ff // @35c #1354: ADD(s1,FF)14100 // @35d #1355: COMPARE(s1,0) ;;;1235760 // @35e #1356: JUMP(NZ,SAVE_MONN)0010c // @35f #1357: LOAD(s1,12)// @360 #1358: [SAVE_MONN]2e125 // @360 #1358: STORE(s1,monB)343ee // @361 #1359: JUMP(real_time_end)// @362 #1360: [MODE5N]14005 // @362 #1360: COMPARE(s0,5)3576b // @363 #1361: JUMP(NZ,MODE6N)06126 // @364 #1362: FETCH(s1,dayB)181ff // @365 #1363: ADD(s1,FF)14100 // @366 #1364: COMPARE(s1,0) ;;;1235769 // @367 #1365: JUMP(NZ,SAVE_DAYN)06127 // @368 #1366: FETCH(s1,DMAX)// @369 #1367: [SAVE_DAYN]2e126 // @369 #1367: STORE(s1,dayB)343ee // @36a #1368: JUMP(real_time_end)// @36b #1369: [MODE6N]14006 // @36b #1369: COMPARE(s0,6)35773 // @36c #1370: JUMP(NZ,MODE7N)06124 // @36d #1371: FETCH(s1,yearB)181ff // @36e #1372: ADD(s1,FF)141ff // @36f #1373: COMPARE(s1,FF) ;;;1235772 // @370 #1374: JUMP(NZ,SAVE_YEARN)00163 // @371 #1375: LOAD(s1,99)// @372 #1376: [SAVE_YEARN]2e124 // @372 #1376: STORE(s1,yearB)// @373 #1377: [MODE7N]343ee // @373 #1378: JUMP(real_time_end)// @374 #1379: [ITS_RIGHT]18001 // @374 #1379: ADD(s0,1)2e002 // @375 #1380: STORE(s0,LED_pattern)// #1381: ;;;turn right++06003 // @376 #1382: FETCH(s0,mode)14000 // @377 #1383: COMPARE(s0,0)353b1 // @378 #1384: JUMP(Z,CLR_INT1) ;14001 // @379 #1385: COMPARE(s0,1)35782 // @37a #1386: JUMP(NZ,MODE2P)06121 // @37b #1387: FETCH(s1,hourB)18101 // @37c #1388: ADD(s1,1)14118 // @37d #1389: COMPARE(s1,24) ;;;2435780 // @37e #1390: JUMP(NZ,SAVE_HHP)00100 // @37f #1391: LOAD(s1,0)// @380 #1392: [SAVE_HHP]2e121 // @380 #1392: STORE(s1,hourB)343ee // @381 #1393: JUMP(real_time_end)// @382 #1394: [MODE2P]14002 // @382 #1394: COMPARE(s0,2)3578b // @383 #1395: JUMP(NZ,MODE3P)06122 // @384 #1396: FETCH(s1,minB)18101 // @385 #1397: ADD(s1,1)1413c // @386 #1398: COMPARE(s1,60) ;;;3C;;6035789 // @387 #1399: JUMP(NZ,SAVE_MMP)00100 // @388 #1400: LOAD(s1,0)// @389 #1401: [SAVE_MMP]2e122 // @389 #1401: STORE(s1,minB)343ee // @38a #1402: JUMP(real_time_end)// @38b #1403: [MODE3P]14003 // @38b #1403: COMPARE(s0,3)35794 // @38c #1404: JUMP(NZ,MODE4P)06123 // @38d #1405: FETCH(s1,secB)18101 // @38e #1406: ADD(s1,1)1413c // @38f #1407: COMPARE(s1,60) ;;;6035792 // @390 #1408: JUMP(NZ,SAVE_SSP)00100 // @391 #1409: LOAD(s1,0)// @392 #1410: [SAVE_SSP]2e123 // @392 #1410: STORE(s1,secB)343ee // @393 #1411: JUMP(real_time_end)// @394 #1412: [MO
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -