关于参数的选择各种意见: 这是CMG大师的论述: R6的取值,R6的值不是任意取的,要考虑两个因素:1)431参考输入端的电流,一般此电流为2uA左右,为了避免此端电流影响分压比和避免噪音的影响,一般取流过电阻R6的电流为参考段电流的100倍以上,所以此电阻要小于2.5V/200uA=12.5K. 2)待机功耗的要求,如有此要求,在满足《12.5K的情况下尽量取大值.
上传时间: 2013-10-26
上传用户:归海惜雪
带中文字库的128X64是一种具有4位/8位并行、2线或3线串行多种接口方式,内部含有国标一级、二级简体中文字库的点阵图形液晶显示模块;其显示分辨率为128×64, 内置8192个16*16点汉字,和128个16*8点ASCII字符集.利用该模块灵活的接口方式和简单、方便的操作指令,可构成全中文人机交互图形界面。可以显示8×4行16×16点阵的汉字. 也可完成图形显示.低电压低功耗是其又一显著特点。由该模块构成的液晶显示方案与同类型的图形点阵液晶显示模块相比,不论硬件电路结构或显示程序都要简洁得多,且该模块的价格也略低于相同点阵的图形液晶模块。 基本特性: 低电源电压(VDD:+3.0--+5.5V) 显示分辨率:128×64点 内置汉字字库,提供8192个16×16点阵汉字(简繁体可选) 内置 128个16×8点阵字符 2MHZ时钟频率 显示方式:STN、半透、正显 驱动方式:1/32DUTY,1/5BIAS 视角方向:6点 背光方式:侧部高亮白色LED,功耗仅为普通LED的1/5—1/10 通讯方式:串行、并口可选 内置DC-DC转换电路,无需外加负压 无需片选信号,简化软件设计 工作温度: 0℃ - +55℃ ,存储温度: -20℃ - +60℃ 12864(带字库汉字显示演示程序) ;*************************************************************************** ;* sxj1974@163.com (51c51 test web) www.8951.com * ;* Create by :石学军 www.51c51.com 更多例程请登陆网站 * ;*************************************************************************** RS EQU P2.0 RW EQU P2.1 E EQU P2.2 PSB EQU P2.3 RST EQU P2.5 ;----------------------------------------------- LCD_X EQU 30H LCD_Y EQU 31H COUNT EQU 32H COUNT1 EQU 33H COUNT2 EQU 34H COUNT3 EQU 35H ;----------------------------------------------- LCD_DATA EQU 36H LCD_DATA1 EQU 37H LCD_DATA2 EQU 38H STORE EQU 39H ;----------------------------------------------- ORG 0000H LJMP MAIN ORG 0100H ;----------------------------------------------- MAIN: MOV SP,#5FH CLR RST ;复位 LCALL DELAY4 SETB RST NOP SETB PSB ;通讯方式为8位数据并口 ;********************初始化********************** LGS0: MOV A,#34H ;34H--扩充指令操作 LCALL SEND_I MOV A,#30H ;30H--基本指令操作 LCALL SEND_I MOV A,#01H ;清除显示 LCALL SEND_I MOV A,#06H ;指定在资料写入或读取时,光标的移动方向 LCALL SEND_I ;DDRAM 的地址计数器(AC)加1 MOV A,#0CH ;开显示,关光标,不闪烁 LCALL SEND_I ;=============================================== TU_PLAY1: MOV DPTR,#TU_TAB1 ;显示图形 LCALL PHO_DISP LCALL DELAY3 ;================================================= ;;显示汉字和字符 ;加入80ms的延时,使你能够看清楚显示的过程 ;根据汉字显示坐标分段写入(顺序写入) ;================================================= HAN_WR2: LCALL CLEAR_P HAN_WR2A: MOV DPTR,#TAB1A ;显示汉字和字符 MOV COUNT,#10H ;地址计数器设为16。 MOV A,#80H ;第一行起始地址 LCALL SEND_I LCALL QUSHU HAN_WR2B: MOV DPTR,#TAB1B ;显示汉字和字符 MOV COUNT,#10H ;地址计数器设为16。 MOV A,#90H ;第二行起始地址 LCALL SEND_I LCALL QUSHU HAN_WR2C: MOV DPTR,#TAB1C ;显示汉字和字符 MOV COUNT,#10H ;地址计数器设为16。 MOV A,#88H ;第三行起始地址 LCALL SEND_I LCALL QUSHU HAN_WR2D: MOV DPTR,#TAB1D ;显示汉字和字符 MOV COUNT,#10H ;地址计数器设为16。 MOV A,#98H ;第四行起始地址 LCALL SEND_I LCALL QUSHU LCALL DELAY3 LCALL FLASH LCALL CLEAR_P JMP TU_PLAY2 ;---------------------------------------------- ;TU_PLAY1: MOV DPTR,#TU_TAB1 ;显示图形 LCALL PHO_DISP LCALL DELAY3 ;---------------------------------------------- TU_PLAY2: MOV DPTR,#TU_TAB2 ;显示图形 LCALL PHO_DISP LCALL DELAY3 ;---------------------------------------------- TU_PLAY3: MOV DPTR,#TU_TAB4 ;显示图形 LCALL PHO_DISP LCALL DELAY3 ;----------------------------------------------- ;显示点阵 ;----------------------------------------------- LATPLAY1: MOV A,#01H ;清屏 LCALL SEND_I MOV LCD_DATA1,#0CCH ;显示点阵 MOV LCD_DATA2,#0CCH LCALL LAT_DISP LCALL DELAY3 LCALL CLEAR_P KU_PLAY2: LJMP TU_PLAY1 ;=============================================== ;全屏显示图形子程序 ;=============================================== PHO_DISP: MOV COUNT3,#02H MOV LCD_X,#80H PHO_DISP1: MOV LCD_Y,#80H MOV COUNT2,#20H PHO_DISP2: MOV COUNT1,#10H LCALL WR_ZB PHO_DISP3: CLR A MOVC A,@A+DPTR LCALL SEND_D INC DPTR DJNZ COUNT1,PHO_DISP3 INC LCD_Y DJNZ COUNT2,PHO_DISP2 MOV LCD_X,#88H DJNZ COUNT3,PHO_DISP1 MOV A,#36H LCALL SEND_I MOV A,#30H LCALL SEND_I RET ;---------------------------------------------- CLRRAM: MOV LCD_DATA1,#00H ;GDRAM写0子程序 MOV LCD_DATA2,#00H LCALL LAT_DISP RET ;============================================== ;显示点阵子程序 ;============================================== LAT_DISP: MOV COUNT3,#02H MOV LCD_X,#80H LAT_DISP1: MOV LCD_Y,#80H CLR F0 MOV COUNT2,#20H LAT_DISP2: MOV COUNT1,#10H LCALL WR_ZB LAT_DISP3: JB F0,LAT_DISP32 MOV LCD_DATA,LCD_DATA1 AJMP LAT_DISP31 LAT_DISP32: MOV LCD_DATA,LCD_DATA2 LAT_DISP31: MOV A,LCD_DATA LCALL SEND_D DJNZ COUNT1,LAT_DISP31 INC LCD_Y CPL F0 DJNZ COUNT2,LAT_DISP2 MOV LCD_X,#88H DJNZ COUNT3,LAT_DISP1 MOV A,#36H LCALL SEND_I MOV A,#30H LCALL SEND_I RET ;--------------------------------------------- WR_ZB: MOV A,#34H LCALL SEND_I MOV A,LCD_Y LCALL SEND_I MOV A,LCD_X LCALL SEND_I MOV A,#30H LCALL SEND_I RET ;=============================================== FLASH: MOV A,#08H ;关闭显示 LCALL SEND_I LCALL DELAY5 MOV A,#0CH ;开显示,关光标,不闪烁 LCALL SEND_I LCALL DELAY5 MOV A,#08H ;关闭显示 LCALL SEND_I LCALL DELAY5 MOV A,#0CH ;开显示,关光标,不闪烁 LCALL SEND_I LCALL DELAY5 MOV A,#08H ;关闭显示 LCALL SEND_I LCALL DELAY5 RET ;================================================== ;清屏 ;================================================== CLEAR_P: MOV A,#01H ;清屏 LCALL SEND_I MOV A,#34H LCALL SEND_I MOV A,#30H LCALL SEND_I RET ;================================================== ;查表取数据送显示 ;================================================== QUSHU: CLR A MOVC A,@A+DPTR ;查表取数据 LCALL SEND_D ;送显示 INC DPTR LCALL DELAY4 ;延时80ms, DJNZ COUNT,QUSHU RET ;=============================================== ;写数据子程序 ;RS=1,RW=0,E=高脉冲,D0-D7=数据 ;=============================================== SEND_D: LCALL CHK_BUSY ;写数据子程序 SETB RS CLR RW MOV P0,A SETB E NOP NOP CLR E RET ;=============================================== ;写指令子程序 ;RS=0,RW=0,E=高脉冲,D0-D7=指令码 ;=============================================== SEND_I: LCALL CHK_BUSY CLR RS CLR RW MOV P0,A SETB E NOP NOP CLR E RET ;================================================ ;读数据子程序 ;RS=1,RW=1,E=H,D0-D7=数据 ;================================================ READ_D: LCALL CHK_BUSY ;读数据子程序 SETB RS SETB RW SETB E NOP MOV A,P0 CLR E MOV STORE,A RET ;================================================ ;;测忙碌子程序 ;RS=0,RW=1,E=H,D0-D7=状态字 ;================================================ CHK_BUSY: MOV P0,#0FFH ;测忙碌子程序 CLR RS SETB RW SETB E JB P0.7,$ CLR E RET ;================================================ ;延时子程序 DELAY3: MOV R5,#16H DEL31: MOV R6,#100 DEL32: MOV R7,#0FFH DEL33: DJNZ R7,DEL33 DJNZ R6,DEL32 DJNZ R5,DEL31 RET DELAY2: MOV R6,#0CH DEL21: MOV R7,#18H DEL22: DJNZ R7,DEL22 DJNZ R6,DEL21 RET DELAY1: MOV R6,#06H DEL11: MOV R7,#08H DEL12: DJNZ R7,DEL12 DJNZ R6,DEL11 RET DELAY4: MOV R6,#100 DEL41: MOV R7,#200 DEL42: DJNZ R7,DEL42 DJNZ R6,DEL41 RET DELAY5: MOV R5,#05H DEL51: MOV R6,#100 DEL52: MOV R7,#0FFH DEL53: DJNZ R7,DEL53 DJNZ R6,DEL52 DJNZ R5,DEL51 RET ;*********************************************** TAB1: TAB1A: DB ' 51单片机学习网(深圳学林电子有限公司) ' ;显示在第一行 TAB1C: DB '自学单片机第一站' ;显示在第三行 TAB1B: DB ' WWW.8951.COM ' ;显示在第二行 TAB1D: DB 'TEL 755-89956892' ;显示在第四行 ;*-------------------------------------------------------------------- * ;* Bitmap点阵数据表 * ;* 图片: E:\图形8.bmp,横向取模左高位,数据排列:从左到右从上到下 * ;* 图片尺寸: 128 * 64 * ;*-------------------------------------------------------------------- * TU_TAB1: ; 数据表 db 0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh db 80h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 80h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 80h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 80h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 80h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 80h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 80h, 00h, 00h, 00h, 00h, 3Ch, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 80h, 00h, 00h, 00h, 00h, 7Fh, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 80h, 00h, 00h, 00h, 00h,0FFh,0C0h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 80h, 00h, 00h, 00h, 01h,0BFh,0F8h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 80h, 00h, 00h, 00h, 01h,0FFh,0DCh, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 80h, 00h, 00h, 00h, 01h, 1Fh,0FEh, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 80h, 00h, 00h, 00h, 01h,0DFh,0FFh, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 80h, 00h, 00h, 00h, 00h,0FFh,0FFh, 19h, 8Ch, 03h, 06h, 00h, 18h, 00h,0FFh,0E1h db 80h, 00h, 00h, 00h, 00h, 3Fh,0FFh, 0Ch,0CCh, 03h, 06h, 00h, 18h, 00h,0FFh,0E1h db 80h, 00h, 00h, 00h, 00h, 7Fh,0FFh, 04h, 58h, 03h, 06h, 01h,0FFh,0C0h, 00h,0C1h db 80h, 00h, 00h, 00h, 00h, 7Fh,0DAh, 3Fh,0FEh, 0Fh,0DFh,0C1h,0FFh,0C0h, 01h, 81h db 80h, 00h, 00h, 00h, 00h, 7Fh, 8Ch, 3Fh,0FEh, 0Fh,0DFh,0C1h, 98h,0C0h, 07h, 01h db 80h, 00h, 00h, 00h, 00h, 7Fh,0B8h, 30h, 06h, 03h, 06h, 01h, 98h,0C0h, 06h, 01h db 80h, 00h, 00h, 00h, 00h,0FEh,0C0h, 0Fh,0F8h, 03h, 8Eh, 01h,0FFh,0C3h,0FFh,0F9h db 80h, 00h, 00h, 00h, 00h, 7Eh, 00h, 0Fh,0F8h, 07h,0CFh, 01h, 98h,0C3h,0FFh,0F9h db 80h, 00h, 00h, 00h, 00h, 7Fh, 00h, 00h, 60h, 07h, 5Fh, 81h, 98h,0C0h, 06h, 01h db 80h, 00h, 00h, 00h, 00h, 7Fh, 80h, 3Fh,0FEh, 0Fh, 36h,0C1h,0FFh,0C0h, 06h, 01h db 80h, 00h, 00h, 00h, 00h, 1Fh, 80h,0BFh,0FEh, 0Bh, 36h, 61h,0FFh,0C0h, 06h, 01h db 80h, 00h, 00h, 00h, 00h, 1Fh,0C7h, 00h,0C0h, 03h, 66h, 21h, 98h, 30h, 06h, 01h db 80h, 00h, 00h, 00h, 15h, 5Fh,0C7h, 00h,0C0h, 03h, 06h, 00h, 18h, 30h, 06h, 01h db 80h, 00h, 02h,0E0h, 06h, 7Fh,0CEh, 03h,0C0h, 03h, 06h, 00h, 1Fh,0F0h, 1Eh, 01h db 80h, 00h, 04h, 54h, 4Fh,0FFh,0FCh, 01h, 80h, 03h, 06h, 00h, 0Fh,0E0h, 0Ch, 01h db 80h, 00h, 03h,0FDh, 3Fh,0FFh,0D9h,0C0h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 80h, 00h, 1Dh,0FFh,0FFh,0FFh, 87h, 80h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 80h, 00h, 2Bh,0FFh,0F8h, 7Fh, 06h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 80h, 00h, 3Fh,0BFh,0F8h, 09h, 0Fh, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 80h, 00h, 1Fh, 9Fh,0F0h, 00h,0BCh, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 9Dh,0FEh, 1Fh, 8Fh,0F0h, 00h,0F8h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 9Fh,0FCh, 17h, 8Fh,0F0h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 81h,0FFh,0CFh, 9Fh,0E0h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 82h,0FFh,0FFh, 9Ch, 80h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 81h, 7Fh,0FFh,0FCh, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 80h, 6Fh,0FEh, 30h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 80h, 03h,0FCh, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 80h, 00h, 34h, 14h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 80h, 00h, 0Eh, 18h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 80h, 00h, 02h, 30h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 80h, 00h, 01h,0E0h, 00h, 00h, 7Fh, 04h, 00h, 3Fh, 82h, 00h, 00h, 00h, 00h, 01h db 80h, 00h, 00h, 00h, 00h, 00h, 7Fh, 0Ch, 00h, 3Fh, 86h, 00h, 00h, 00h, 00h, 01h db 80h, 00h, 00h, 00h, 00h, 00h, 7Fh, 1Ch, 00h, 3Fh, 8Eh, 00h, 00h, 00h, 00h, 01h db 83h,0BBh, 9Dh,0DCh,0EEh,0E0h, 70h, 7Ch, 38h, 38h, 3Eh, 00h,0E0h, 38h, 3Bh, 31h db 83h,0BBh, 9Dh,0DCh,0EEh,0E0h, 70h, 7Ch, 3Ch, 38h, 3Eh, 00h,0F0h, 7Ch, 3Fh,0F9h db 83h,0BBh, 9Dh,0DCh,0EEh,0E0h, 76h, 1Ch, 7Eh, 3Bh, 0Eh, 01h,0F8h,0FEh, 3Fh,0F9h db 83h,0BBh, 9Dh,0DCh,0EEh,0E0h, 7Fh, 1Ch, 76h, 3Fh, 8Eh, 01h,0D8h,0EEh, 3Bh,0B9h db 83h,0BBh, 9Dh,0DCh,0EEh,0E0h, 7Fh, 1Ch, 76h, 3Fh, 8Eh, 01h,0D8h,0EEh, 3Bh,0B9h db 83h,0BBh, 9Dh,0DCh,0EEh,0E0h, 77h, 1Ch, 76h, 3Bh, 8Eh, 01h,0D8h,0EEh, 3Bh,0B9h db 81h,0BBh, 0Dh,0D8h, 6Eh,0C0h, 07h, 1Ch, 70h, 03h, 8Eh, 01h,0C0h,0EEh, 3Bh,0B9h db 81h,0ABh, 0Dh, 58h, 6Ah,0C0h, 07h, 1Ch, 70h, 03h, 8Eh, 01h,0C0h,0EEh, 3Bh,0B9h db 81h,0ABh, 0Dh, 58h, 6Ah,0C0h, 77h, 1Ch, 70h, 3Bh, 8Eh, 01h,0C0h,0EEh, 3Bh,0B9h db 81h,0ABh, 0Dh, 58h, 6Ah,0C0h, 77h, 1Ch, 76h, 3Bh, 8Eh, 01h,0D8h,0EEh, 3Bh,0B9h db 81h,0EFh, 0Fh, 78h, 7Bh,0C0h, 77h, 1Ch, 76h, 3Bh, 8Eh, 01h,0D8h,0EEh, 3Bh,0B9h db 81h,0EFh, 0Fh, 78h, 7Bh,0DCh, 77h, 1Ch, 76h, 3Bh, 8Eh, 39h,0D8h,0EEh, 3Bh,0B9h db 81h,0EFh, 0Fh, 78h, 7Bh,0DCh, 7Fh, 1Ch, 7Eh, 3Fh, 8Eh, 39h,0F8h,0FEh, 3Bh,0B9h db 81h,0EFh, 0Fh, 78h, 7Bh,0DCh, 3Eh, 1Ch, 3Ch, 1Fh, 0Eh, 38h,0F0h, 7Ch, 3Bh,0B9h db 81h,0EFh, 0Fh, 78h, 7Bh,0DCh, 1Ch, 1Ch, 3Ch, 0Eh, 0Eh, 38h,0F0h, 78h, 3Bh,0B9h db 80h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh ;*-------------------------------------------------------------------- * ;* Bitmap点阵数据表 * ;* 图片: E:\图形12.bmp,横向取模左高位,数据排列:从左到右从上到下 * ;* 图片尺寸: 128 * 64 * ;*-------------------------------------------------------------------- * TU_TAB2: ; 数据表 db 40h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 03h, 65h,0E8h, 80h, 00h, 01h db 9Ah,0D6h,0B4h, 42h, 00h, 00h, 00h, 00h, 00h, 00h, 34h,0DAh,0D0h, 00h, 00h, 01h db0A4h, 00h, 02h, 10h, 6Bh, 30h, 00h, 00h, 00h, 00h, 8Bh,0FFh, 30h, 00h, 00h, 01h db 42h,0D6h,0B0h, 42h, 80h, 00h, 00h, 00h, 00h, 16h, 77h,0FEh,0C0h, 00h, 00h, 01h db 42h,0D6h,0B0h, 42h, 80h, 00h, 00h, 00h, 00h, 16h, 77h,0FEh,0C0h, 00h, 00h, 01h db0B9h, 20h, 04h, 00h, 00h, 02h, 10h, 00h, 00h, 00h,0BCh,0BCh, 00h, 00h, 00h, 01h db 46h,0D6h,0B1h,0ACh, 6Bh, 30h, 00h, 00h, 02h, 29h,0CBh, 40h, 00h, 00h, 00h, 01h db0FFh,0F9h, 04h, 01h, 00h, 00h, 00h, 00h, 01h, 16h,0B4h,0A0h, 00h, 00h, 00h, 01h db0FFh,0FFh,0F2h, 50h, 00h, 40h, 00h, 00h, 00h, 29h, 4Bh, 00h, 00h, 00h, 00h, 01h db0FFh,0FFh,0F2h, 50h, 00h, 40h, 00h, 00h, 00h, 29h, 4Bh, 00h, 00h, 00h, 00h, 01h db0FFh,0FFh,0BDh, 82h, 94h, 00h, 40h, 00h, 00h,0C9h, 30h, 02h, 00h, 00h, 00h, 01h db0FFh,0FFh,0FBh,0B0h, 00h, 08h, 00h, 00h, 05h, 16h, 44h, 40h, 00h, 00h, 00h, 01h db0FFh,0FFh,0FFh,0EFh, 90h, 40h, 00h, 00h, 00h, 21h, 00h, 04h,0C8h, 30h, 00h, 01h db0A5h,0FFh,0FFh,0FDh, 6Bh, 00h, 00h, 00h, 00h,0C8h, 00h, 99h, 16h,0FAh, 40h, 01h db0A5h,0FFh,0FFh,0FDh, 6Bh, 00h, 00h, 00h, 00h,0C8h, 00h, 99h, 16h,0FAh, 40h, 01h db 82h, 2Fh,0FFh,0FFh,0E8h, 84h, 00h, 00h, 00h, 00h, 08h, 00h,0DFh,0FFh,0ECh, 01h db 24h,0C1h, 7Fh,0FFh,0F4h, 30h, 00h, 00h, 00h, 00h, 00h,0A7h,0FFh,0FFh,0FCh, 01h db 42h, 28h, 05h,0BFh,0FBh, 80h, 00h, 00h, 00h, 00h, 04h, 1Bh,0FFh,0FFh,0FFh, 81h db 98h,0C1h, 4Ah, 53h,0ECh, 48h, 00h, 00h, 00h, 00h, 40h, 7Fh,0FFh,0FFh,0FFh,0E1h db 98h,0C1h, 4Ah, 53h,0ECh, 48h, 00h, 00h, 00h, 00h, 40h, 7Fh,0FFh,0FFh,0FFh,0E1h db 42h, 28h, 00h, 0Ch, 77h, 82h, 00h, 00h, 00h, 00h, 33h,0BFh,0FFh,0FFh,0FFh, 89h db 18h,0C1h, 4Ah, 51h, 9Bh, 74h, 00h, 00h, 00h, 00h, 04h,0FFh, 3Fh,0FFh,0DFh,0F1h db0C2h, 28h, 00h, 0Ch, 04h, 80h, 00h, 00h, 00h, 00h, 40h,0FEh, 1Fh,0F9h,0C3h,0F9h db 1Ah,0D6h,0B5h,0A1h, 6Bh, 75h, 80h, 00h, 00h, 00h, 8Fh,0FCh, 3Fh,0F2h, 0Fh, 1Fh db 1Ah,0D6h,0B5h,0A1h, 6Bh, 75h, 80h, 00h, 00h, 00h, 8Fh,0FCh, 3Fh,0F2h, 0Fh, 1Fh db0C5h, 29h, 79h, 8Ch, 00h, 88h, 00h, 00h, 00h, 00h, 03h,0F8h, 1Fh,0C8h, 52h, 81h db 22h,0FFh,0FFh,0F2h, 6Bh, 35h, 80h, 00h, 00h, 00h, 37h,0C2h, 3Fh,0FBh,0FCh, 09h db 9Ah,0FFh,0FFh,0FFh, 00h, 48h, 00h, 00h, 00h, 00h, 07h,0D8h, 1Fh,0FFh,0E3h, 81h db 9Ah,0FFh,0FFh,0FFh, 00h, 48h, 00h, 00h, 00h, 00h, 07h,0D8h, 1Fh,0FFh,0E3h, 81h db 47h,0FFh,0FFh,0FFh,0F3h, 35h, 80h, 00h, 00h, 00h, 8Fh,0C1h, 0Fh,0FFh,0ACh, 01h db0B9h,0FFh,0FFh,0FFh,0FCh, 4Ah, 20h, 00h, 00h, 00h, 0Fh,0A4h, 07h,0FEh, 40h, 01h db 5Fh,0FFh,0C7h,0FFh,0FCh,0B5h, 80h, 00h, 00h, 00h, 4Fh,0DAh,0FFh,0F8h, 00h, 01h db0A7h,0FFh,0B7h,0FFh,0FFh, 8Ah, 20h, 00h, 00h, 00h, 0Fh,0FFh,0EFh, 40h, 00h, 01h db0A7h,0FFh,0B7h,0FFh,0FFh, 8Ah, 20h, 00h, 00h, 00h, 0Fh,0FFh,0EFh, 40h, 00h, 01h db 7Fh,0FFh, 47h,0FDh, 7Fh,0C5h, 80h, 00h, 00h, 00h, 3Fh,0DAh,0D0h, 00h, 00h, 01h db0A7h,0FEh, 37h,0FFh, 7Ch,0FAh, 50h, 00h, 00h, 00h, 0Ch,0A4h, 08h, 00h, 00h, 01h db0DFh,0FEh, 43h,0FFh,0F8h,0C1h, 80h, 00h, 00h, 00h, 48h, 01h, 00h, 00h, 00h, 01h db 27h,0FFh, 4Bh,0FFh,0FFh,0FAh, 2Ch, 00h, 00h, 00h, 03h, 58h, 20h, 00h, 00h, 01h db 27h,0FFh, 4Bh,0FFh,0FFh,0FAh, 2Ch, 00h, 00h, 00h, 03h, 58h, 20h, 00h, 00h, 01h db 9Bh,0FFh,0C3h,0FFh,0FFh,0F1h,0C0h, 00h, 00h, 00h, 08h, 00h, 00h, 00h, 00h, 01h db 64h, 3Fh,0FDh,0FFh, 6Bh, 7Ch, 10h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 03h,0D7h,0FFh,0FDh, 10h, 01h,0A0h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db0D8h, 29h, 4Fh,0A2h, 80h,0B5h, 90h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db0D8h, 29h, 4Fh,0A2h, 80h,0B5h, 90h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 05h, 10h,0B0h, 4Ch, 0Bh, 08h, 40h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db0A0h,0C9h, 0Ah, 00h, 00h, 42h, 10h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 04h, 10h, 40h, 21h, 64h, 09h,0A0h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db0A2h,0C1h, 35h, 8Ch, 00h, 44h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db0A2h,0C1h, 35h, 8Ch, 00h, 44h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 00h, 16h, 00h, 21h, 14h, 09h,0A0h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db0A5h, 00h,0B5h, 80h, 83h, 44h, 0Ch, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 00h, 26h, 00h, 12h, 08h, 09h,0A0h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db0DAh, 00h,0B4h, 40h, 60h, 44h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db0DAh, 00h,0B4h, 40h, 60h, 44h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 80h,0C8h, 00h, 00h, 04h, 01h,0A0h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db0A2h, 20h, 89h, 91h, 10h, 8Ah, 10h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 44h, 06h, 00h, 00h, 00h, 30h, 40h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 44h, 06h, 00h, 00h, 00h, 30h, 40h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 80h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 80h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 80h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 80h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh ;*-------------------------------------------------------------------- * ;*-------------------------------------------------------------------- * ;* Bitmap点阵数据表 * ;* 图片: E:\图形13.bmp,横向取模左高位,数据排列:从左到右从上到下 * ;* 图片尺寸: 128 * 64 * ;*-------------------------------------------------------------------- * TU_TAB4: ; 漂亮姑娘看过来 db 0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh db 80h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 80h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h db 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h db 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h db 00h, 00h, 00h, 00h, 00h, 00h, 00h, 11h,0FFh, 80h, 40h, 08h, 30h, 10h, 20h, 00h db 00h, 00h, 00h, 00h, 00h, 00h, 00h, 0Ch, 68h, 3Fh,0FFh, 08h, 30h, 11h,0F8h, 00h db 00h, 00h, 00h, 00h, 00h, 00h, 00h, 0Ch, 68h, 3Fh,0FFh, 08h, 30h, 11h,0F8h, 00h db 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h,0FFh, 00h, 00h, 7Fh,0FEh, 7Dh, 08h, 00h db 00h, 00h, 00h, 00h, 00h, 00h, 00h, 11h, 6Bh, 07h,0FCh, 16h, 30h, 2Dh,0F8h, 00h db 00h, 00h, 00h, 00h, 00h, 00h, 00h, 0Dh,0FFh, 04h, 0Ch, 16h, 30h, 2Dh, 08h, 00h db 00h, 00h, 00h, 00h, 00h, 00h, 00h, 0Ch, 00h, 3Fh,0FFh, 16h, 30h, 2Dh,0F8h, 00h db 00h, 00h, 00h, 00h, 00h, 00h, 00h, 0Ch, 00h, 3Fh,0FFh, 16h, 30h, 2Dh,0F8h, 00h db 00h, 00h, 00h, 00h, 00h, 00h, 00h, 0Ch,0FFh, 30h, 01h, 66h,0FEh, 2Dh, 26h, 00h db 00h, 00h, 00h, 00h, 00h, 00h, 00h, 1Ch, 00h, 03h,0F0h, 76h, 82h, 2Dh, 28h, 00h db 00h, 00h, 00h, 00h, 00h, 00h, 00h, 0Dh,0FFh, 82h, 11h, 08h, 82h, 11h, 10h, 00h db 00h, 00h, 00h, 00h, 00h, 00h, 00h, 0Ch, 8Bh, 04h, 11h, 16h, 82h, 2Dh, 28h, 00h db 00h, 00h, 00h, 00h, 00h, 00h, 00h, 0Ch, 8Bh, 04h, 11h, 16h, 82h, 2Dh, 28h, 00h db 00h, 00h, 00h, 00h, 00h, 00h, 00h, 0Dh, 18h,0B8h, 1Fh, 60h,0FEh, 41h,0C6h, 00h db 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h db 00h, 07h, 8Fh,0FFh, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h db 00h, 08h, 70h, 40h,0EFh, 80h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h db 00h, 08h, 70h, 40h,0EFh, 80h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h db 00h, 10h, 00h, 80h, 10h, 60h, 00h, 0Fh,0FFh, 30h, 0Ch, 00h, 80h, 00h, 00h, 00h db 00h, 20h, 18h, 38h, 20h, 60h, 00h, 00h, 60h, 08h, 0Ch, 1Fh,0FCh, 1Ch, 00h, 00h db 00h,0C0h, 64h, 45h, 00h, 60h, 00h, 03h,0FCh, 0Bh,0FFh, 00h, 80h, 3Eh, 00h, 00h db 00h,0C1h, 00h, 01h, 00h, 10h, 00h, 00h, 80h, 00h, 0Ch, 08h, 88h, 3Eh, 00h, 00h db 00h,0C1h, 00h, 01h, 00h, 10h, 00h, 00h, 80h, 00h, 0Ch, 08h, 88h, 3Eh, 00h, 00h db 01h, 01h, 00h, 00h,0C0h, 10h, 00h, 1Fh,0FFh,0BDh, 8Ch, 06h,0B0h, 3Eh, 00h, 00h db 02h, 0Eh, 18h, 1Ch,0C0h, 10h, 00h, 01h, 00h, 04h, 4Ch, 7Fh,0FEh, 1Ch, 00h, 00h db 02h, 16h, 64h, 22h, 20h, 10h, 00h, 03h,0FCh, 04h, 4Ch, 01h,0C0h, 1Ch, 00h, 00h db 02h, 16h, 64h, 22h, 20h, 10h, 00h, 03h,0FCh, 04h, 4Ch, 01h,0C0h, 1Ch, 00h, 00h db 04h,0E8h, 83h, 41h, 1Ch, 08h, 00h, 0Dh, 04h, 04h, 0Ch, 06h,0B0h, 00h, 00h, 00h db 07h, 10h, 8Fh, 47h, 03h, 88h, 00h, 11h,0FCh, 04h, 3Ch, 08h, 88h, 1Ch, 00h, 00h db 00h, 20h, 6Ch, 26h, 01h, 78h, 00h, 01h, 04h, 0Ah, 00h, 70h, 86h, 1Ch, 00h, 00h db 00h,0C0h, 18h, 1Ch, 00h, 80h, 00h, 01h,0FCh, 31h,0FFh, 00h, 80h, 00h, 00h, 00h db 00h,0C0h, 18h, 1Ch, 00h, 80h, 00h, 01h,0FCh, 31h,0FFh, 00h, 80h, 00h, 00h, 00h db 00h,0C1h, 87h, 80h, 00h, 80h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h db 01h, 06h, 78h, 3Ch, 20h, 60h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h db 01h, 08h, 07h,0C2h,0C0h, 60h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h db 01h, 08h, 00h, 01h,0C0h, 60h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h db 01h, 08h, 00h, 01h,0C0h, 60h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h db 01h, 08h, 18h, 01h,0C0h, 60h, 00h, 00h, 00h,0F1h,0F3h, 87h,0C0h, 00h, 00h, 00h db 00h,0C6h, 18h,0C2h, 20h, 80h, 00h, 00h, 03h, 0Eh, 1Ch, 78h, 70h, 00h, 00h, 00h db 00h,0C1h, 00h,0C2h, 00h, 80h, 00h, 00h, 04h, 44h, 11h, 10h, 38h, 00h, 00h, 00h db 00h, 26h,0E0h, 04h, 01h, 00h, 00h, 00h, 04h, 80h, 12h, 00h, 38h, 00h, 00h, 00h db 00h, 26h,0E0h, 04h, 01h, 00h, 00h, 00h, 04h, 80h, 12h, 00h, 38h, 00h, 00h, 00h db 00h, 11h, 18h, 38h, 03h, 00h, 00h, 00h, 04h, 80h, 12h, 00h, 38h, 00h, 00h, 00h db 00h, 0Eh, 87h,0C2h, 1Ch, 00h, 00h, 00h, 04h, 00h, 10h, 00h, 38h, 00h, 00h, 00h db 00h, 01h,0E0h, 04h,0E0h, 00h, 00h, 00h, 03h, 00h, 1Ch, 00h, 70h, 00h, 00h, 00h db 00h, 1Eh, 18h, 3Fh, 1Eh, 00h, 00h, 00h, 00h, 80h, 32h, 00h,0C0h, 00h, 00h, 00h db 00h, 1Eh, 18h, 3Fh, 1Eh, 00h, 00h, 00h, 00h, 80h, 32h, 00h,0C0h, 00h, 00h, 00h db 00h, 38h, 07h,0C0h, 0Fh, 00h, 00h, 00h, 00h, 40h, 61h, 01h, 80h, 00h, 00h, 00h db 00h,0E9h,0FFh,0FFh, 0Dh, 80h, 00h, 00h, 00h, 31h,0C0h, 87h, 00h, 00h, 00h, 00h db 01h,0E9h, 1Bh,0B9h, 0Dh,0E0h, 00h, 00h, 00h, 0Bh, 80h, 6Eh, 00h, 00h, 00h, 00h db 03h,0C9h,0F0h, 1Fh, 0Ch,0F0h, 00h, 00h, 00h, 06h, 00h, 18h, 00h, 00h, 00h, 00h db 03h,0C9h,0F0h, 1Fh, 0Ch,0F0h, 00h, 00h, 00h, 06h, 00h, 18h, 00h, 00h, 00h, 00h db 07h, 06h,0E0h, 06h, 10h, 78h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h db 07h,0C1h, 00h, 00h, 20h,0F8h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h db 07h,0E0h, 80h, 00h,0C1h,0F8h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h db 07h,0E0h, 80h, 00h,0C1h,0F8h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h db 80h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 00h, 01h db0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh end
上传时间: 2013-10-13
上传用户:123啊
清单1 LSDAA: ADC R16,R16 ;十进制数(在R16中)左移调整子程序 ADDAA: IN R6,SREG ;bcd码相加调整子程序,先保存相加后的 LDI R17,$66 ;状态the old status ADD R16,R17 ;再将和预加立即数$66 IN R17,SREG ;输入相加后新状态(the new status) OR R6,R17 ;新旧状态相或 SBRS R6,0 ;相或后进位置位则跳行 SUBI R16,$60 ;否则减去$60(十位bcd不满足调整条件) SBRS R6,5 ;半进位置位则跳行 SUBI R16,6 ;否则减去$06(个位bcd不满足调整条件) ROR R6 ;向高位BCD返还进位位! RET
上传时间: 2013-10-08
上传用户:zh_901
单片机入门基础知识大全免费下载 单片机第八课(寻址方式与指令系统) 通过前面的学习,我们已经了解了单片机内部的结构,并且也已经知道,要控制单片机,让它为我们干学,要用指令,我们已学了几条指令,但很零散,从现在开始,我们将要系统地学习8051的指令部份。 一、概述 1、指令的格式 我们已知,要让计算机做事,就得给计算机以指令,并且我们已知,计算机很“笨”,只能懂得数字,如前面我们写进机器的75H,90H,00H等等,所以指令的第一种格式就是机器码格式,也说是数字的形式。但这种形式实在是为难我们人了,太难记了,于是有另一种格式,助记符格式,如MOV P1,#0FFH,这样就好记了。 这两种格式之间的关系呢,我们不难理解,本质上它们完全等价,只是形式不一样而已。 2、汇编 我们写指令使用汇编格式,而计算机只懂机器码格式,所以要将我们写的汇编格式的指令转换为机器码格式,这种转换有两种方法:手工汇编和机器汇编。手工汇编实际上就是查表,因为这两种格式纯粹是格式不同,所以是一一对应的,查一张表格就行了。不过手工查表总是嫌麻烦,所以就有了计算机软件,用计算机软件来替代手工查表,这就是机器汇编。 二、寻址 让我们先来复习一下我们学过的一些指令:MOV P1,#0FFH,MOV R7,#0FFH这些指令都是将一些数据送到相应的位置中去,为什么要送数据呢?第一个因为送入的数可以让灯全灭掉,第二个是为了要实现延时,从这里我们可以看出来,在用单片机的编程语言编程时,经常要用到数据的传递,事实上数据传递是单片机编程时的一项重要工作,一共有28条指令(单片机共111条指令)。下面我们就从数据传递类指令开始吧。 分析一下MOV P1,#0FFH这条指令,我们不难得出结论,第一个词MOV是命令动词,也就是决定做什么事情的,MOV是MOVE少写了一个E,所以就是“传递”,这就是指令,规定做什么事情,后面还有一些参数,分析一下,数据传递必须要有一个“源”也就是你要送什么数,必须要有一个“目的”,也就是你这个数要送到什么地方去,显然在上面那条指令中,要送的数(源)就是0FFH,而要送达的地方(目的地)就是P1这个寄存器。在数据传递类指令中,均将目的地写在指令的后面,而将源写在最后。 这条指令中,送给P1是这个数本身,换言之,做完这条指令后,我们可以明确地知道,P1中的值是0FFH,但是并不是任何时候都可以直接给出数本身的。例如,在我们前面给出的延时程序例是这样写的: MAIN: SETB P1.0 ;(1) LCALL DELAY ;(2) CLR P1.0 ;(3) LCALL DELAY ;(4) AJMP MAIN ;(5) ;以下子程序 DELAY: MOV R7,#250 ;(6) D1: MOV R6,#250 ;(7) D2: DJNZ R6,D2 ;(8) DJNZ R7,D1 ;(9) RET ;(10) END ;(11) 表1 MAIN: SETB P1.0 ;(1) MOV 30H,#255 LCALL DELAY ; CLR P1.0 ;(3) MOV 30H,#200 LCALL DELAY ;(4) AJMP MAIN ;(5) ;以下子程序 DELAY: MOV R7,30H ;(6) D1: MOV R6,#250 ;(7) D2: DJNZ R6,D2 ;(8) DJNZ R7,D1 ;(9) RET ;(10) END ;(11) 表2 这样一来,我每次调用延时程序延时的时间都是相同的(大致都是0.13S),如果我提出这样的要求:灯亮后延时时间为0.13S灯灭,灯灭后延时0.1秒灯亮,如此循环,这样的程序还能满足要求吗?不能,怎么办?我们可以把延时程序改成这样(见表2):调用则见表2中的主程,也就是先把一个数送入30H,在子程序中R7中的值并不固定,而是根据30H单元中传过来的数确定。这样就可以满足要求。 从这里我们可以得出结论,在数据传递中要找到被传递的数,很多时候,这个数并不能直接给出,需要变化,这就引出了一个概念:如何寻找操作数,我们把寻找操作数所在单元的地址称之为寻址。在这里我们直接使用数所在单元的地址找到了操作数,所以称这种方法为直接寻址。除了这种方法之外,还有一种,如果我们把数放在工作寄存器中,从工作寄存器中寻找数据,则称之为寄存器寻址。例:MOV A,R0就是将R0工作寄存器中的数据送到累加器A中去。提一个问题:我们知道,工作寄存器就是内存单元的一部份,如果我们选择工作寄存器组0,则R0就是RAM的00H单元,那么这样一来,MOV A,00H,和MOV A,R0不就没什么区别了吗?为什么要加以区分呢?的确,这两条指令执行的结果是完全相同的,都是将00H单元中的内容送到A中去,但是执行的过程不同,执行第一条指令需要2个周期,而第二条则只需要1个周期,第一条指令变成最终的目标码要两个字节(E5H 00H),而第二条则只要一个字节(E8h)就可以了。 这么斤斤计较!不就差了一个周期吗,如果是12M的晶振的话,也就1个微秒时间了,一个字节又能有多少? 不对,如果这条指令只执行一次,也许无所谓,但一条指令如果执行上1000次,就是1毫秒,如果要执行1000000万次,就是1S的误差,这就很可观了,单片机做的是实时控制的事,所以必须如此“斤斤计较”。字节数同样如此。 再来提一个问题,现在我们已知,寻找操作数可以通过直接给的方式(立即寻址)和直接给出数所在单元地址的方式(直接寻址),这就够了吗? 看这个问题,要求从30H单元开始,取20个数,分别送入A累加器。 就我们目前掌握的办法而言,要从30H单元取数,就用MOV A,30H,那么下一个数呢?是31H单元的,怎么取呢?还是只能用MOV A,31H,那么20个数,不是得20条指令才能写完吗?这里只有20个数,如果要送200个或2000个数,那岂不要写上200条或2000条命令?这未免太笨了吧。为什么会出现这样的状况?是因为我们只会把地址写在指令中,所以就没办法了,如果我们不是把地址直接写在指令中,而是把地址放在另外一个寄存器单元中,根据这个寄存器单元中的数值决定该到哪个单元中取数据,比如,当前这个寄存器中的值是30H,那么就到30H单元中去取,如果是31H就到31H单元中去取,就可以解决这个问题了。怎么个解决法呢?既然是看的寄存器中的值,那么我们就可以通过一定的方法让这里面的值发生变化,比如取完一个数后,将这个寄存器单元中的值加1,还是执行同一条指令,可是取数的对象却不一样了,不是吗。通过例子来说明吧。 MOV R7,#20 MOV R0,#30H LOOP:MOV A,@R0 INC R0 DJNZ R7,LOOP 这个例子中大部份指令我们是能看懂的,第一句,是将立即数20送到R7中,执行完后R7中的值应当是20。第二句是将立即数30H送入R0工作寄存器中,所以执行完后,R0单元中的值是30H,第三句,这是看一下R0单元中是什么值,把这个值作为地址,取这个地址单元的内容送入A中,此时,执行这条指令的结果就相当于MOV A,30H。第四句,没学过,就是把R0中的值加1,因此执行完后,R0中的值就是31H,第五句,学过,将R7中的值减1,看是否等于0,不等于0,则转到标号LOOP处继续执行,因此,执行完这句后,将转去执行MOV A,@R0这句话,此时相当于执行了MOV A,31H(因为此时的R0中的值已是31H了),如此,直到R7中的值逐次相减等于0,也就是循环20次为止,就实现了我们的要求:从30H单元开始将20个数据送入A中。 这也是一种寻找数据的方法,由于数据是间接地被找到的,所以就称之为间址寻址。注意,在间址寻址中,只能用R0或R1存放等寻找的数据。 二、指令 数据传递类指令 1) 以累加器为目的操作数的指令 MOV A,Rn MOV A,direct MOV A,@Ri MOV A,#data 第一条指令中,Rn代表的是R0-R7。第二条指令中,direct就是指的直接地址,而第三条指令中,就是我们刚才讲过的。第四条指令是将立即数data送到A中。 下面我们通过一些例子加以说明: MOV A,R1 ;将工作寄存器R1中的值送入A,R1中的值保持不变。 MOV A,30H ;将内存30H单元中的值送入A,30H单元中的值保持不变。 MOV A,@R1 ;先看R1中是什么值,把这个值作为地址,并将这个地址单元中的值送入A中。如执行命令前R1中的值为20H,则是将20H单元中的值送入A中。 MOV A,#34H ;将立即数34H送入A中,执行完本条指令后,A中的值是34H。 2)以寄存器Rn为目的操作的指令 MOV Rn,A MOV Rn,direct MOV Rn,#data 这组指令功能是把源地址单元中的内容送入工作寄存器,源操作数不变。
上传时间: 2013-10-13
上传用户:3294322651
入口条件:待转换的双字节BCD码小数在R4、R5中。出口信息:转换后的双字节十六进制小数在R2、R3中。*影响资源:PSW、A、R2~R6 堆栈需求: 2字节BHD2: MOV R6,#10H ;准备计算两个字节小数BHD3: MOV A,R5 ;按十进制倍增
上传时间: 2013-10-23
上传用户:zhang_yi
入口条件:被除数在R2、R3、R4、R5中,除数在R6、R7中。出口信息:OV=0时商在R2、R3中,OV=1时溢出。影响资源:PSW、A、B、R1~R7 堆栈需求: 5字节DIVS: LCALL MDS ;计算结果的符号和两个操作数的绝对值PUSH PSW ;保存结果的符号LCALL DIVD ;计算两个绝对值的商JNB OV,DVS1 ;溢出否?POP ACC ;溢出,放去结果的符号,保留溢出标志
上传时间: 2013-11-09
上传用户:lht618
用单片机AT89C51改造普通双桶洗衣机:AT89C2051作为AT89C51的简化版虽然去掉了P0、P2等端口,使I/O口减少了,但是却增加了一个电压比较器,因此其功能在某些方面反而有所增强,如能用来处理模拟量、进行简单的模数转换等。本文利用这一功能设计了一个数字电容表,可测量容量小于2微法的电容器的容量,采用3位半数字显示,最大显示值为1999,读数单位统一采用毫微法(nf),量程分四档,读数分别乘以相应的倍率。电路工作原理 本数字电容表以电容器的充电规律作为测量依据,测试原理见图1。电源电路图。 压E+经电阻R给被测电容CX充电,CX两端原电压随充电时间的增加而上升。当充电时间t等于RC时间常数τ时,CX两端电压约为电源电压的63.2%,即0.632E+。数字电容表就是以该电压作为测试基准电压,测量电容器充电达到该电压的时间,便能知道电容器的容量。例如,设电阻R的阻值为1千欧,CX两端电压上升到0.632E+所需的时间为1毫秒,那么由公式τ=RC可知CX的容量为1微法。 测量电路如图2所示。A为AT89C2051内部构造的电压比较器,AT89C2051 图2 的P1.0和P1.1口除了作I/O口外,还有一个功能是作为电压比较器的输入端,P1.0为同相输入端,P1.1为反相输入端,电压比较器的比较结果存入P3.6口对应的寄存器,P3.6口在AT89C2051外部无引脚。电压比较器的基准电压设定为0.632E+,在CX两端电压从0升到0.632E+的过程中,P3.6口输出为0,当电池电压CX两端电压一旦超过0.632E+时,P3.6口输出变为1。以P3.6口的输出电平为依据,用AT89C2051内部的定时器T0对充电时间进行计数,再将计数结果显示出来即得出测量结果。整机电路见图3。电路由单片机电路、电容充电测量电路和数码显示电路等 图3 部分组成。AT89C2051内部的电压比较器和电阻R2-R7等组成测量电路,其中R2-R5为量程电阻,由波段开关S1选择使用,电压比较器的基准电压由5V电源电压经R6、RP1、R7分压后得到,调节RP1可调整基准电压。当P1.2口在程序的控制下输出高电平时,电容CX即开始充电。量程电阻R2-R5每档以10倍递减,故每档显示读数以10倍递增。由于单片机内部P1.2口的上拉电阻经实测约为200K,其输出电平不能作为充电电压用,故用R5兼作其上拉电阻,由于其它三个充电电阻和R5是串联关系,因此R2、R3、R4应由标准值减去1K,分别为999K、99K、9K。由于999K和1M相对误差较小,所以R2还是取1M。数码管DS1-DS4、电阻R8-R14等组成数码显示电路。本机采用动态扫描显示的方式,用软件对字形码译码。P3.0-P3.5、P3.7口作数码显示七段笔划字形码的输出,P1.3-P1.6口作四个数码管的动态扫描位驱动码输出。这里采用了共阴数码管,由于AT89C2051的P1.3-P1.6口有25mA的下拉电流能力,所以不用三极管就能驱动数码管。R8-R14为P3.0-P3.5、P3.7口的上拉电阻,用以驱动数码管的各字段,当P3的某一端口输出低电平时其对应的字段笔划不点亮,而当其输出高电平时,则对应的上拉电阻即能点亮相应的字段笔划。
上传时间: 2013-12-31
上传用户:ming529
基于单片机的红外门进控制系统设计与制作:我们所做的创新实验项目“基于单片机的红外门控系统”已基本完成,现将其工作原理简要说明。该系统主要分为两大部分:一是红外传感器部分。二是单片机计数显示控制部分。基本电路图如下:其中红外传感器部分我们采用红外对管实现,红外对管平行放置,平常处于接收状态,经比较器输出低电平,当有人经过时,红外线被挡住,接收管接收不到红外线,经比较器输出高电平。这样,当有人经过时便会产生一个电平的跳变。单片机控制部分主要是通过外部两个中断判断是否有人经过,如果有人经过,由于电平跳变的产生,进入中断服务程序,这里我们采用了两对红外传感器接到两个外部中断口,中断0作为入口,实现加1操作,中断1作为出口,实现减1操作。另外,我们通过P0口控制室内灯的亮暗,当寄存器计数值为0时,熄灯,不为0时,灯亮。显示部分,采用两位数码管动态显示,如有必要,可以很方便的扩展为四位计数。精益求精!在实验过程中,我们走了非常多的弯路,做出来的东西根本不是自己想要的,我们本想做成室内只有一个门的进出计数,原理已清楚,即在门的两边放置两对红外对管,进出时,挡住两对对管的顺序不同,因此,可判断是进入还是出去,从而实现加减计数,编程时,可分别在两个中断服务程序的入口置标志位,根据标志位判断进出,详细内容在程序部分。理论如此,但在实际过程中,还是发现实现不了上述功能,我们初步判定认为是程序掌握得不够好,相信随着自己对单片机了解的深入,应该会做出更好的 (因为我们是临时学的单片机),程序的具体内容如下: $MOD52 ORG 0000H LJMP MAIN ORG 0003H LJMP 0100H ORG 0013H LJMP 0150H ORG 0050HMAIN: CLR A MOV 30H , A ;初始化缓存区 MOV 31H , A MOV 32H , A MOV 33H , A MOV R6 , A MOV R7 , A SETB EA SETB EX0 SETB EX1 SETB IT0 SETB IT1 SETB PX1NEXT1: ACALL HEXTOBCDD ;调用数制转换子程序 ACALL DISPLAY ;调用显示子程序 LJMP NEXT1 ORG 0100H ;中断0服务程序 LCALL DELY mov 70h,#2 djnz 70h,next JBC F0,NEXT SETB F0 CLR P0.0 LCALL DELY0 SETB P0.0 MOV A , R7 ADD A , #1 MOV R7, A MOV A , R6 ADDC A , #0 MOV R6 , A CJNE R6 , #07H , NEXT CLR A MOV R6 , A MOV R7 , ANEXT: RETI ORG 0150H ;中断1服务程序 LCALL DELY mov 70h,#2 djnz 70h,next2 JBC F0,NEXT2 SETB F0 CLR P0.0 LCALL DELY0 SETB P0.0 CLR C MOV A , R7 SUBB A , #1 MOV R7, A MOV A , R6 SUBB A , #0 MOV R6 , A CJNE R6 , #07H , NEXT2 CLR A MOV R6 , A MOV R7 , ANEXT2: RETI ORG 0200HHEXTOBCDD:MOV A , R6 ;由十六进制转化为十进制 PUSH ACC MOV A , R7 PUSH ACC MOV A , R2 PUSH ACC CLR A MOV R3 , A MOV R4 , A MOV R5 , A MOV R2 , #10HHB3: MOV A , R7 ;将十六进制中最高位移入进位位中 RLC A MOV R7 , A MOV A , R6 RLC A MOV R6 , A MOV A , R5 ;每位数加上本身相当于将这个数乘以2 ADDC A , R5 DA A MOV R5 , A MOV A , R4 ADDC A , R4 DA A ;十进制调整 MOV R4 , A MOV A , R3 ADDC A , R3 DJNZ R2 , HB3 POP ACC MOV R2 , A POP ACC MOV R7 , A POP ACC MOV R6 , A RET ORG 0250HDISPLAY: MOV R0 , #30H MOV A , R5 ANL A , #0FH MOV @R0 , A MOV A , R5 SWAP A ANL A , #0FH INC R0 MOV @R0 , A MOV A , R4 ANL A , #0FH INC R0 MOV @R0 , A MOV A , R4 SWAP A ANL A , #0FH INC R0 MOV @R0 , A MOV R0 , #30H MOV R2 , #11111110BAGAIN: MOV A , R2 MOV P2 , A MOV A , @R0 MOV DPTR , #TAB MOVC A , @A+DPTR MOV P1 , A ACALL DELAY INC R0 MOV A , R2 RL A MOV R2 , A JB ACC.4 , AGAIN RETTAB: DB 03FH , 06H , 5BH , 4FH , 66H , 6DH , 7DH , 07H , 7FH , 6FH ;七段码表DELY: MOV R1,#80D1: MOV R2,#100 DJNZ R2,$ DJNZ R1,D1 RET DELAY: MOV TMOD , #01H ;延时子程序 MOV TL0 , #0FEH MOV TH0 , #0FEH SETB TR0WAIT: JNB TF0 , WAIT CLR TF0 CLR TR0 RETDELY0: MOV R1, #200D3: MOV R2,#250 DJNZ R2,$ DJNZ R1,D3 RET END 该系统实际应用广泛。可用在生产线上产品数量统计、公交车智能计数问候(需添加语音芯片)、超市内人数统计等公共场合。另外,添加串口通信部分便可实现与PC数据交换的功能。 由于,实验简化了,剩下不少零件和资金,所以我们又做了两项其他的实验。
上传时间: 2013-12-22
上传用户:tangsiyun
微型51/AVR 编程器套件装配说明书 请您在动手装配这个编程器之前,务必先看完本说明书,避免走弯路。 1.收到套件后请对照元器件列表检查一下,元件、配件是否齐全? Used Part Type Designator ==== ================ ========== 1 1k R6 1 1uf 50V C11 5 2k2 R2 R3 R4 R5 R11 1 10K*8 RN1 2 11.0592MHZ Q1 Q2 1 12V,0.5W D2 2 15k R7 R8 2 21k R9 R10 4 33p C6 C7 C8 C9 1 47uf 25V C10 1 74HC164 IC6 2 78L05 IC4 IC5 1 100uf 25V C12 1 220R R1 1 AT89C51 IC2 1 B40C800(W02) D1 2 BS170 T1 T2 1 BS250 T3 1 DB9/F J2 1 J1X2 J1 1 LED GN5 D3 1 LM317L IC1 1 TLC2272 IC7 1 ZIF40 IC3 5 1uf C1 C2 C3 C4 C5 另外,套件配有1.5米串行电缆一根和配套的PCB一块,不含电源。编程器使用的15V交流电源或12V直流电源需要自己配套。2.装配要点:先焊接阻容元件,3个集成电路插座(IC2,IC7,IC6)其次是晶振, 全桥,稳压IC 等,然后焊接J2,最后焊接T1,T2,T3三只场效应管。焊接场效应管时务必按照以下方法:拔去电烙铁的电源,使用电烙铁余温去焊接三只场效应管,否则静电很容易损坏管子。这是装配成功的关键。这三只管子有问题,最典型的现象是不能联机。由于电源插座封装比较特殊,国内无法配套上,已改用电源线接线柱,可直接焊接在PCB板焊盘上,如下图1所示(在下图中两个红色圆圈内指示的焊盘),然后在连接到套件中配套的电源插座上。最近有朋友反映用15V交流比较麻烦,还要另外配变压器。如果要使用12V的直流电,无需将全桥焊上,将两个接线柱分别焊接在全桥的正负输出位置的焊盘上即可,如下图2所示,蓝色圆圈内指示的焊盘,连接电源的时候要注意正负极,不要接错了。方形焊盘是正极。40脚ZIF插座焊接前,应该将BR1飞线焊接好。注意:由于焊盘比较小,注意焊接温度,不要高温长时间反复焊接,会导致焊盘脱落。
上传时间: 2013-12-31
上传用户:caiguoqing
基于AT89C2051的红外遥控学习器源程序6 源程序 ORG 0000H AJMP MAIN ORG 0003H AJMP KEYPRESS ORG 000BH AJMP TIMEOUT ORG 001BH AJMP TIMEOUT SENDDUAN BIT P3.0 JIEDUAN BIT P3.1 INTRPO BIT P3.2 JIEXUAN BIT P3.3 SENDLIGHT BIT P3.4 JIELIGHT BIT P3.5 CS BIT P3.7 DATADUAN BIT P1.6 CLK BIT P1.7 JIANWEI EQU R5 JIANMA EQU R6 SHANGJIAN EQU 07H;R7 OPENKEY EQU 81H CLOSEKEY EQU 00H CHUT0 EQU 11H CHUT1 EQU 11H BUFBEGIN EQU 18H OPENT1 EQU 88H CLOSET1 EQU 00H OPENT0 EQU 82H CLOSET0 EQU 00H DATABEG1 EQU 0AAH DATABEG2 EQU 33H ORG 0030HMAIN: MOV IE,#80H MOV IP,#00H MOV P3,#0FFH CLR CS SETB P1.0 SETB P1.1 SETB P1.2 CLR P1.3 CLR P1.4 CLR P1.5 CLR P1.6 CLR P1.7 MOV R3,#80H MOV R0,00HCYCLE1: MOV @R0,#00H INC R0 DJNZ R3,CYCLE1 MOV PSW,#00H MOV SP,#07H MOV TMOD,#11H MOV TCON,#00H START: MOV SP,#07H SETB SENDDUAN CLR F0 SETB EXOWAITKEY: MOV C,F0 JNC WAITKEY CJNC JIANMA,#1BH,SEND LCALL LEARNP LJMP STARTSEND: LCALL SENDP LJMP START SENDP: SETB SENDDUAN CLR F0 MOV TMOD,#CHUT1
上传时间: 2013-10-15
上传用户:lyy1234