具体内容看附件吧,我把写的程序打包放在一起了。
感兴趣的朋友可以做进一步扩展。
单片机源程序如下:
- ORG 0000H
- AJMP MAIN
- ORG 0100H
- MAIN:
- SETB P3.6 ;RW,1读,0写
- SETB P3.5 ;RS,1数据寄存器,0命令/状态寄存器
- MOV 2AH,#16 ;位首地址
- LCALL TIM1
- JMP MAIN
-
- //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- TIM1: MOV R5,#-1 ;位右移次数
- MOV R7,#10
- LOOP0: INC R5
- MOV 2EH,R5
- LOOP1: MOV R3,#0
- MOV R4,#16 ;位扫描初始化
- LOOP2: LCALL WEI
- LCALL EXC1H
- LCALL HC595
- LCALL EXC1L
- LCALL HC595
- CLR P3.5
- NOP
- NOP
- SETB P3.5
-
- INC R3
- DJNZ R4,LOOP2 ;扫描16位
-
- MOV R5,2EH
- DJNZ R7,LOOP1 ;延时显示
-
- MOV R7,#10
- CJNE R5,#8,LOOP0 ;右移8位
- //////////////////////////////////////////////////////////////
- TIM2: MOV R5,#-1
- MOV R7,#10
- LOOP3: INC R5
- MOV 2DH,R5
- LOOP4: MOV R3,#0
- MOV R4,#16
- LOOP5: LCALL WEI
- LCALL EXC2H
- LCALL HC595
- LCALL EXC2L
- LCALL HC595
- CLR P3.5
- NOP
- NOP
- SETB P3.5
-
- INC R3
- DJNZ R4,LOOP5 ;扫描16位
-
- MOV R5,2DH
- DJNZ R7,LOOP4 ;延时显示
-
- MOV R7,#10
- CJNE R5,#8,LOOP3 ;再右移八位,共16位
-
- MOV A,2AH
- ADD A,#16
- MOV 2AH,A
- CJNE A,#80,TIM1
- RET
- //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- WEI: MOV DPTR,#WEI2
- CLR A
- ADD A,R3
- MOVC A,@A+DPTR
- CPL A
- LCALL HC595
- MOV DPTR,#WEI1
- CLR A
- ADD A,R3
- MOVC A,@A+DPTR
- CPL A
- LCALL HC595
- RET
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ;得到偏移后段码高八位
- EXC1H: MOV 22H,R5 ;保存右移次数
-
- MOV DPTR,#TAB2
- MOV A,2AH
- CLR C
- SUBB A,#16
- ADD A,R3
- MOVC A,@A+DPTR
- MOV 20H,A
-
- MOV DPTR,#TAB1
- MOV A,2AH
- ADD A,R3
- MOVC A,@A+DPTR
- MOV 21H,A
- MOV A,22H
- JZ Z1
- LCALL ROTATE1
- JMP Z2
- Z1: MOV A,20H
- Z2: RET
- EXC2H: MOV 22H,R5 ;保存右移次数
-
- MOV DPTR,#TAB1
- MOV A,2AH
- ADD A,R3
- MOVC A,@A+DPTR
- MOV 20H,A
-
- MOV DPTR,#TAB2
- MOV A,2AH
- ADD A,R3
- MOVC A,@A+DPTR
- MOV 21H,A
-
- MOV A,22H
- JZ Z3
- LCALL ROTATE1
- JMP Z4
- Z3: MOV A,20H
- Z4: RET
- ROTATE1:CLR C
- MOV A,21H
- RRC A
- MOV 21H,A ;保存每次右循环后的数据
- MOV A,20H
- RRC A
- MOV 20H,A
- DJNZ R5,ROTATE1
- MOV R5,22H ;还原右移次数
- RET
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ;得到偏移后段码低八位
- EXC1L: MOV 22H,R5 ;保存右移次数
-
- MOV DPTR,#TAB1
- MOV A,2AH
- CLR C
- SUBB A,#16
- ADD A,R3
- MOVC A,@A+DPTR
- MOV 23H,A
-
- MOV DPTR,#TAB2
- MOV A,2AH
- CLR C
- SUBB A,#16
- ADD A,R3
- MOVC A,@A+DPTR
- MOV 24H,A
-
- MOV A,22H
- JZ Z5
- LCALL ROTATE2
- JMP Z6
- Z5: MOV A,23H
- Z6: RET
- EXC2L: MOV 22H,R5 ;保存右移次数
-
- MOV DPTR,#TAB2
- MOV A,2AH
- ADD A,R3
- CLR C
- SUBB A,#16
- MOVC A,@A+DPTR
- MOV 23H,A
-
- MOV DPTR,#TAB1
- MOV A,2AH
- ADD A,R3
- MOVC A,@A+DPTR
- MOV 24H,A
-
- MOV A,22H
- JZ Z7
- LCALL ROTATE2
- JMP Z8
- Z7: MOV A,23H
- Z8: RET
- ROTATE2:CLR C
- MOV A,24H
- RRC A
- MOV 24H,A
- MOV A,23H
- RRC A
- MOV 23H,A
- DJNZ R5,ROTATE2
- MOV R5,22H
- RET
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ;HC595数据传输
- HC595: MOV R2,#8
- SHFT: MOV C,Acc.7
- MOV P3.4,C
- RL A
- CLR P3.6
- NOP
- NOP
- SETB P3.6
- DJNZ R2,SHFT
- DELAY: MOV 2FH,#0AFH
- DELAY1: DJNZ 2FH,DELAY1
- RET
- WEI1: DB 01H,02H,04H,08H,10H,20H,40H,80H,00H,00H,00H,00H,00H,00H,00H,00H
- WEI2: DB 00H,00H,00H,00H,00H,00H,00H,00H,01H,02H,04H,08H,10H,20H,40H,80H
- TAB1: ;低八位
- DB 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
- DB 0x00,0x80,0x60,0xF8,0x07,0x40,0x20,0x18,0x0F,0x08,0xC8,0x08,0x08,0x28,0x18,0x00
- DB 0x10,0x10,0xF0,0x1F,0x10,0xF0,0x00,0x80,0x82,0x82,0xE2,0x92,0x8A,0x86,0x80,0x00
- DB 0x00,0xFC,0x04,0x04,0xFC,0x00,0xC2,0xBA,0x82,0x82,0x82,0xFE,0x82,0x82,0x80,0x00
- DB 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
- TAB2: ;高八位
- DB 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
- DB 0x01,0x00,0x00,0xFF,0x00,0x10,0x0C,0x03,0x40,0x80,0x7F,0x00,0x01,0x06,0x18,0x00 ;你
- DB 0x40,0x22,0x15,0x08,0x16,0x61,0x00,0x00,0x40,0x80,0x7F,0x00,0x00,0x00,0x00,0x00 ;好
- DB 0x00,0x0F,0x04,0x04,0x0F,0x20,0x10,0x08,0x04,0x42,0x81,0x7F,0x00,0x00,0x00,0x00 ;呀
- DB 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
- END
复制代码
所有资料51hei提供下载:
16×16点阵仿真.zip
(270.97 KB, 下载次数: 44)
|