既有动态显示又有静态显示,没有电原理图,但是很简单,行扫描,上下滚动,单片机型号STC15F2K60S2(打开文件后就可以看到)
单片机源程序如下:
- /* 静态
- DL BIT P1.0;串行输入列信号(数据信号)(低有效)并行输出
- DH BIT P1.1;串行输入行信号(行扫描信号)(高有效)并行输出
- STR BIT P1.2;RCLK 三态输出锁存器的时钟输入
- CLK BIT P1.3;SRCLK 移位寄存器的时钟输入
- FOE BIT P1.4;/OE 输出允许控制
- ROWH EQU 40H;字模信号,高位在前
- ROWL EQU 41H;
- SELH EQU 42H;行扫描信号
- SELL EQU 43H;
- ORG 0000H;
- LJMP MAIN;
- ORG 0100H
- MAIN:
- MOV SP,#6FH;
- MOV R1,#01H;配合字模信号
- MOV R2,#01H;高字节在后,从01开始
- MOV R3,#10H;循环16次
- LOAD:
- MOV DPTR,#DATAH;存储行扫描信号;
- MOV A,R1;
- MOVC A,@A+DPTR;
- MOV SELH,A;存储高字节
- DEC R1; 指向低字节
- MOV A,R1;
- MOVC A,@A+DPTR;
- MOV SELL,A; 存储低字节
- INC R1;
- INC R1;
- INC R1;指向下一个高字节
- MOV DPTR,#DATAL; ;存储字模数据,过程同上
- MOV A, R2
- MOVC A, @A+DPTR
- MOV ROWH, A
- DEC R2
- MOV A, R2
- MOVC A, @A+DPTR
- MOV ROWL, A
- INC R2
- INC R2
- INC R2
- LCALL LATCH;运行锁存自程序
- LCALL DELAY;延时
- DJNZ R3, LOAD;重复执行16次,显示所有行
- LJMP MAIN;静态显示
- LATCH:
- CLR FOE ;允许输出
- CLR STR ;为上升沿将移位寄存器数据锁存入数据寄存器
- MOV R4, SELH ; 做准备
- MOV R5, ROWH ;高位行扫描型号和字模信号
- MOV R6, #08H ;高低位分开读,每次读8位
- LATCH1:
- CLR CLK ;为上升沿读入移位寄存器做准备
- MOV A, R4
- RRC A ;移出最高位
- MOV R4, A
- MOV DH, C ;由P1.0输出准备进入移位寄存器
- MOV A, R5
- RRC A
- MOV R5, A
- MOV DL, C ;由P1.1输出准备进入移位寄存器
- SETB CLK ;CLK上升沿,P1.0和P1.1数据进入移位寄存器
- DJNZ R6, LATCH1
- MOV R4, SELL
- MOV R5, ROWL
- MOV R6, #08H
- LATCH2: ;同上
- CLR CLK
- MOV A, R4
- RRC A
- MOV R4, A
- MOV DH, C
- MOV A, R5
- RRC A
- MOV R5, A
- MOV DL, C
- SETB CLK
- DJNZ R6, LATCH2
- SETB STR ;STR上升沿移位寄存器数据所存入数据寄存器
- RET ;显示
- DELAY: ;延迟程序
- MOV R6, #02H
- LOOP1:
- MOV R7, #0F8H ;;估算:1us*2*(1+2*248+2) = 998us ≈ 1ms
- LOOP2:
- DJNZ R7, LOOP2
- DJNZ R6, LOOP1
- RET
- DATAH: ;SELECT ROW
- DB 80H, 00H
- DB 40H, 00H
- DB 20H, 00H
- DB 10H, 00H
- DB 08H, 00H
- DB 04H, 00H
- DB 02H, 00H
- DB 01H, 00H
- DB 00H, 80H
- DB 00H, 40H
- DB 00H, 20H
- DB 00H, 10H
- DB 00H, 08H
- DB 00H, 04H
- DB 00H, 02H
- DB 00H, 01H
- DATAL:
- /*
- DB; 0B..................,01H;
- DB; 0DDH,6DH,0C1H,6DH,0BFH,6DH,7FH,7DH,00H,01H,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH;;第一个字
- END;
- */
- /*每一列共阴极显示器
- /*每一行七段显示器的笔画
- /*动态显示电路,笔画锁存器控制行信号,位锁存器控制列信号
- */
- ; /*滚动
- DH BIT P1.0;
- DL BIT P1.1
- STR BIT P1.2
- CLK BIT P1.3
- FOE BIT P1.4
- ROWH EQU 40H
- ROWL EQU 41H
- SELH EQU 42H
- SELL EQU 43H
- WAIT EQU 44H ;负责控制滚动速度
- ORG 0000H
- LJMP MAIN
- ORG 0100H
- MAIN:
- MOV R0, #01H ;每次重新滚动时初始化
- NEXT:
- MOV WAIT, #0AH ;滚动速度设置,数字越大滚动越慢
- ROLL:
- MOV A, R0 ;变换显示的第一行以完成滚动
- MOV R1, #01H ;行扫描信号不变
- MOV R2, A
- MOV R3, #10H
- LOAD:
- MOV DPTR, #SEL_DATA ;
- MOV A, R1
- MOVC A, @A+DPTR
- MOV SELH, A ;
- DEC R1 ;
- MOV A, R1
- MOVC A, @A+DPTR
- MOV SELL, A ;
- INC R1 ;
- INC R1
- INC R1
- MOV DPTR, #ROW_DATA
- MOV A, R2
- MOVC A, @A+DPTR
- MOV ROWH, A
- DEC R2
- MOV A, R2
- MOVC A, @A+DPTR
- MOV ROWL, A
- INC R2
- INC R2
- INC R2
- LCALL LATCH
- LCALL DELAY
- DJNZ R3, LOAD
- ; 以上与第一部分相同
- DJNZ WAIT, ROLL ;循环以延时
- INC R0
- INC R0 ;R0指向下一行,以实现滚动
- CJNE R0, #41H, NEXT ;所有字符显示完毕后开始新的一轮 ;根据字符的个数不同而改变
- ; 以下与第一部分相同
- LJMP MAIN
- LATCH:
- CLR FOE
- CLR STR
- MOV R4, SELH
- MOV R5, ROWH
- MOV R6, #08H
- LATCH1:
- CLR CLK
- MOV A, R4
- RRC A
- MOV R4, A
- MOV DH, C
- MOV A, R5
- RRC A
- MOV R5, A
- MOV DL, C
- SETB CLK
- DJNZ R6, LATCH1
- ;
- MOV R4, SELL
- MOV R5, ROWL
- MOV R6, #08H
- LATCH2:
- CLR CLK
- MOV A, R4
- RRC A
- MOV R4, A
- MOV DH, C
- MOV A, R5
- RRC A
- MOV R5, A
- MOV DL, C
- SETB CLK
- DJNZ R6, LATCH2;
- SETB STR
- RET
- DELAY:
- MOV R6, #02H
- LOOP1:
- MOV R7, #0F8H
- LOOP2:
- DJNZ R7, LOOP2
- DJNZ R6, LOOP1
- RET
- SEL_DATA: ;SELECT ROW
- DB 80H, 00H
- DB 40H, 00H
- DB 20H, 00H
- DB 10H, 00H
- DB 08H, 00H
- DB 04H, 00H
- DB 02H, 00H
- DB 01H, 00H
- DB 00H, 80H
- DB 00H, 40H
- DB 00H, 20H
- DB 00H, 10H
- DB 00H, 08H
- DB 00H, 04H
- DB 00H, 02H
- DB 00H, 01H
- ROW_DATA:
- DB; 0B..................,01H;
- DB; 0DDH,6DH,0C1H,6DH,0BFH,6DH,7FH,7DH,00H,01H,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH;;第一个字
- DB; 7FH,0FFH,01H,81H,0BFH,0BDH,0C0H,3DH,0EDH,0BDH,0F5H,81H,0FEH,0EFH,80H,0F7H;
- DB ;0BDH,73H,0BDH,0A8H;...................,73H,80H,0FBH,0FDH,0FFH,0FBH,0FFH;第二个字
- DB ;16个;
- DB ;0DDH,6DH,0C1H,6DH,0BFH,6DH,7FH,7DH,00H,01H,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH;;;第一个字
- END
复制代码
所有资料51hei提供下载:
dianzhen.zip
(33.69 KB, 下载次数: 14)
|