书签 分享 收藏 举报 版权申诉 / 43
上传文档赚钱

类型单片机在线系统AY-MPU89S51E课件.ppt

  • 上传人(卖家):晟晟文业
  • 文档编号:4538473
  • 上传时间:2022-12-17
  • 格式:PPT
  • 页数:43
  • 大小:522.50KB
  • 【下载声明】
    1. 本站全部试题类文档,若标题没写含答案,则无答案;标题注明含答案的文档,主观题也可能无答案。请谨慎下单,一旦售出,不予退换。
    2. 本站全部PPT文档均不含视频和音频,PPT中出现的音频或视频标识(或文字)仅表示流程,实际无音频或视频文件。请谨慎下单,一旦售出,不予退换。
    3. 本页资料《单片机在线系统AY-MPU89S51E课件.ppt》由用户(晟晟文业)主动上传,其收益全归该用户。163文库仅提供信息存储空间,仅对该用户上传内容的表现方式做保护处理,对上传内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知163文库(点击联系客服),我们立即给予删除!
    4. 请根据预览情况,自愿下载本文。本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
    5. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007及以上版本和PDF阅读器,压缩文件请下载最新的WinRAR软件解压。
    配套讲稿:

    如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。

    特殊限制:

    部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。

    关 键  词:
    单片机 在线 系统 AY MPU89S51E 课件
    资源描述:

    1、实验用硬件平台(含USB接口写入线)蜂鸣器驱动器ADEEPROM232电平转换晶振继电器实验用硬件平台(含并口写入线和电源)单片机在线系统AY-MPU89S51E AT89S52单片机(跳线接上排针时)6位数码管动态显示(P0输出字形、P2.05选择位)8位LED显示(P1)6位按键输入(P2.72,P3.3)EEPROM:256字节(IIC接口,P3.2 P3.4)8位AD(串行接口)P3.57 蜂鸣器(P1.7)、继电器 RS232接口(P3.1、P3.2)温度传感器EA/VP31X119X218RESET9RD17WR16INT012INT113T014T115P101P112P123P

    2、134P145P156P167P178P0039P0138P0237P0336P0435P0534P0633P0732P2021P2122P2223P2324P2425P2526P2627P2728PSEN29ALE/P30TXD11RXD10U112348765A0A1A2GNDSDASCLWPVCC24C02VCC8CLK7DO6DI5/CS1CH02CH13GND4ADC0832LCD_LM40116D07D18D29D310D411D512D613D714RS4R/W5+5V2VIN3GND1E115E216EN6U5GND15CG6CV2VCC16T1I11R1O12T2I10R2O

    3、9T1O14R1I13T2O7R2I8C2+4C2-5C1+1C1-3TC232U6in11in22in33in44in55in66in77com18out116out215out314out413out512out611out710com29ULN2003l1l2l3l41234567891K*8+C15+C14+C13+C0212345678P0_112345678P0_212345678P0_312345678P2_112345678P2_2CY1K1SW1SW2SW3SW412345678JP3012345678JP31+C16R02R03R04R05R06R07R08R09R10R1

    4、1a7b6c4d2e1f9g10dp5Com13Com285LEDLD1a7b6c4d2e1f9g10dp5Com13Com285LEDLD2a7b6c4d2e1f9g10dp5Com13Com285LEDLD3a7b6c4d2e1f9g10dp5Com13Com285LEDLD412POWERRledaledbledcleddledeledfledgledpledaledbledcleddledeledfledgledpjp001jp002jp003jp004jp005jp006jp007jp008jp001jp002jp003jp004jp005jp006jp007jp008P00P01P

    5、02P03P04P05P06P0712345678P0_4ledaledbledcleddledeledfledgledpledaledbledcleddledeledfledgledpledaledbledcleddledeledfledgledpLD1LD2LD3LD4RQ1RQ2RQ3RQ4P27P26P25P24P23P22P21P20L4led1led2led3led4led4led3led2led1L3L2L1VCCBEEPCKrq6rq5rq4rq3rq2rq1rq1rq2rq3rq4rq4rq3rq1rq2ld2ld4ld1ld3VCCVCCVCCVCCVCCbeepTXDRX

    6、DVCCRXDTXDSCLSDAKEYCSDI P30P31P32P33P34P36P37P35VCCP00P01P02P03P04P05P06P07P20P21P22P23P24P25P26P27P30P31ALEPSENP10P11P12P13P14P15P16P17P33P32P35P34VCCRSTP37P36VCCRSTSRETVCCVCCVCCGND12345STEP1234567CONTROLGNDVCC vcc162738495DB9a7b6c4d2e1f9g10dp5Com13Com285LEDLD6ledaledbledcleddledeledfledgledpLD6a7b

    7、6c4d2e1f9g10dp5Com13Com285LEDLD5ledaledbledcleddledeledfledgledpLD5rq5rq5ld5VCCrq6rq6ld6VCCl5l6l7l8L8led8led7led6led5L7L6L5SW5SW6RQ5RQ612345678910111213141516液晶扩展口D0D1D2D3D4D5D6D7RSR/WENVINE1E2GNDVCCVINRSR/WEND0D1D2D3D4D5D6D7E1E2led5led6led7led8Vin1GND2+5V3Q0C01C02C03KEYC04VCCV+123456ISPVCCGNDRSTP17

    8、P16P15SCLSDACSCKDODIDOQ5Q6Q2Q1Q4Q312345P4_412345678P1_1L1L2L3L4L5L6L7L8VCC电源输入端P0口上排针P0口中排针P0口下排针P0口焊盘P2口上排针P2口中排针12345678P2_312345678P2_4P2口下排针P2口焊盘LED小灯限流电阻P1口上排针12345678P1_2P17P16P15P14P13P12P11P10P1口中排针12345678P1_312345678P1_4P1口下排针P1口焊盘12345678P3_312345678P3_4P3口下排针P3口焊盘P3口中排针P3口上排针VCCGNDPSENAL

    9、ERST在线下载口电源指示灯GNDC310UFVCCBEEPBUZZER123ADCAD输入口CH0CH1控制信号输入口abcdDCMSPKJDQABCD步进电机输出VCC7A继电器123RELAY继电器输出COMCKCB直流电机输出喇叭输出VCC123温度传感器DS18B20R14.7KVCCVCCGNDP1.0*复位开关AT89S51/52GNDGND12MHzGNDRS232串行口C127pFC227pFR01L9LED显示部分232接口驱动+继电器EA/VP31X119X218RESET9RD17WR16INT012INT113T014T115P101P112P123P134P145P

    10、156P167P178P0039P0138P0237P0336P0435P0534P0633P0732P2021P2122P2223P2324P2425P2526P2627P2728PSEN29ALE/P30TXD11RXD10U1+C14+C13+C02CY1+C16R09R10R1112POWERRTXDRXDVCCP00P01P02P03P04P05P06P07P20P21P22P23P24P25P26P27P30P31ALEPSENP10P11P12P13P14P15P16P17P33P32P35P34VCCRSTP37P36VCCRSTSRET162738495DB9Vin1GND2

    11、+5V3Q0C01C02C03C04VCCV+电源输入端电源指示灯复位开关AT89S51/52GNDGND12MHzGNDRS232串行口C127pFC227pFL9LEDLCD_LM40116D07D18D29D310D411D512D613D714RS4R/W5+5V2VIN3GND1E115E216EN6U5VCCGNDD0D1D2D3D4D5D6D7RSR/WENVINE1E2123温度传感器DS18B20R14.7KVCCVCCGNDP1.0*12348765A0A1A2GNDSDASCLWPVCC24C02VCC8CLK7DO6DI5/CS1CH02CH13GND4ADC0832i

    12、n11in22in33in44in55in66in77com18out116out215out314out413out512out611out710com29ULN2003K1VCCVCC12345STEP1234567CONTROLGNDVCC vcc12345678910111213141516液晶扩展口GNDVCCVINRSR/WEND0D1D2D3D4D5D6D7E1E2SCLSDACSCKDODIGND123ADCAD输入口CH0CH1控制信号输入口abcdDCMSPKJDQABCD步进电机输出VCC7A继电器123RELAY继电器输出COMCKCB直流电机输出喇叭输出VCC1234

    13、56ISPVCCGNDRSTP17P16P15GND15CG6CV2VCC16T1I11R1O12T2I10R2O9T1O14R1I13T2O7R2I8C2+4C2-5C1+1C1-3TC232U6VCCSW1SW2SW3SW4KEYRQ6RQ5RQ1RQ2RQ3RQ4SW6SW512345678P0_112345678P0_212345678P0_312345678P2_112345678P2_212345678JP3012345678JP31jp001jp002jp003jp004jp005jp006jp007jp008P00P01P02P03P04P05P06P0712345678P0_

    14、4P27P26P25P24P23P22P21P20BEEPCKrq6rq5rq4rq3rq2rq1VCCbeepRXDTXDSCLSDAKEYCSDI P30P31P32P33P34P36P37P35DO12345P4_412345678P1_1L1L2L3L4L5L6L7L8P0口上排针P0口中排针P0口下排针P0口焊盘P2口上排针P2口中排针12345678P2_312345678P2_4P2口下排针P2口焊盘P1口上排针12345678P1_2P17P16P15P14P13P12P11P10P1口中排针12345678P1_312345678P1_4P1口下排针P1口焊盘12345678

    15、P3_312345678P3_4P3口下排针P3口焊盘P3口中排针P3口上排针VCCGNDPSENALERSTC310UFVCCBEEPBUZZERl1l2l3l41234567891K*8R02R03R04R05R06R07R08a7b6c4d2e1f9g10dp5Com13Com285LEDLD1a7b6c4d2e1f9g10dp5Com13Com285LEDLD2a7b6c4d2e1f9g10dp5Com13Com285LEDLD3a7b6c4d2e1f9g10dp5Com13Com285LEDLD4ledaledbledcleddledeledfledgledpledaledbledc

    16、leddledeledfledgledpjp001jp002jp003jp004jp005jp006jp007jp008ledaledbledcleddledeledfledgledpledaledbledcleddledeledfledgledpledaledbledcleddledeledfledgledpLD1LD2LD3LD4L4led1led2led3led4led4led3led2led1L3L2L1VCCrq1rq2rq3rq4rq4rq3rq1rq2ld2ld4ld1ld3VCCVCCVCCVCCa7b6c4d2e1f9g10dp5Com13Com285LEDLD6ledale

    17、dbledcleddledeledfledgledpLD6a7b6c4d2e1f9g10dp5Com13Com285LEDLD5ledaledbledcleddledeledfledgledpLD5rq5rq5ld5VCCrq6rq6ld6VCCl5l6l7l8L8led8led7led6led5L7L6L5led5led6led7led8Q5Q6Q2Q1Q4Q3LED小灯限流电阻R01流水灯实验(实验1、2)1、掌握51单片机如何控制信号输出。2、掌握Keil C集成开发环境的使用。3、掌握51开发平台的使用。4、8个发光管(L1L8)接在P1的07,为0时点亮。5、功能:首先点亮L1、然后

    18、L2、最后是L8接着点亮L8、然后是L7 L6 L1如此循环,间隔0.11.0秒实验1:流水灯实验(汇编程序)ORG 000HSTART:MOV A,#0FFHCLR CMOV R2,#08H LOOP:RLC AMOV P1,A ;输出至P1口LCALL DELAY ;调用延迟子程序(延迟100毫秒)DJNZ R2,LOOP MOV R2,#07H ;设右移7次LOOP1:RRC A MOV P1,A ;输出至P1口 LCALL DELAYDJNZ R2,LOOP1JMP START ;跳回到START,再一次循环。DELAY:MOV R4,#200 ;延迟子程序(100毫秒)250*2*2

    19、00=500*200usD1:MOV R5,#248;=50*2ms=100msDJNZ R5,$;2us DJNZ R4,D1;2us RETEND流水灯实验(C程序)#include reg52.hvoid Delay()unsigned char i,j;for(i=0;i255;i+)for(j=0;j255;j+);void main()unsigned char i,dat;while(1)dat=0 x01;for(i=0;i8;i+)P1=dat;/L1 is first light,then L2 L3 L8dat=dat1;Delay();dat=0 x80;for(i=0

    20、;i1;Delay();查表法点亮LED 给定表格(33个8位数)为1则点亮相应的发光二极管 间隔0.30.9秒实验2:流水灯实验(汇编程序)BEEP BIT P2.0 BUFF_LED_LP EQU 21H ;亮灯循环寄存器 org 000h JMP START ORG 100H;-start:mov P1,#0ffh ;初始化MCU端口 MOV A,#00H ;初始化寄存器 MOV PSW,#00H MOV IE,#00H MOV SP,#30H MOV BUFF_LED_LP,#00HLOOP:MOV DPTR,#TAB_A_LAMP ;设置亮灯花型列表地址(32种)MOV A,BUFF

    21、_LED_LP ;查询方式读取花型 MOVC A,A+DPTR CPL A MOV P1,A ;LED小灯控制口 LCALL DEL1S INC BUFF_LED_LP MOV A,BUFF_LED_LP CJNE A,#32,LOOP MOV BUFF_LED_LP,#00H JMP LOOP实验2:流水灯实验(汇编程序)续TAB_A_LAMP:DB 00111100B,10000001B,11000011B,11100111B,11111111B,11100111B,11000011B,10000001B,00000000B DB 00011000B,00111100B,01111110B

    22、,11111111B,00000000B,10101010B,10101010B,11001100B DB 10000000B,11000000B,11100000B,11110000B,11111000B,11111100B,11111110B,11111111B DB 11111110B,11111100B,11111000B,11110000B,11100000B,11000000B,10000000B,00000000BdeL1S:MOV R5,#03H ;延时子程序(约0.5秒)DEL1S0:mov R6,#0ffh DEL1S1:mov R7,#0ffh djnz R7,$djnz

    23、 R6,del1S1 DJNZ R5,DEL1S0 ;CPL BEEP ret END实验2:流水灯实验(C程序)#include reg52.hcode unsigned char tab=0 x3c,0 x81,0 xc3,0 xe7,0 xff,0 xe7,0 xc3,0 x81,0 x00,0 x18,0 x3c,0 x7e,0 xff,0 x00,0 xaa,0 xaa,0 xcc,0 x80,0 xc0,0 xe0,0 xf0,0 xf8,0 xfc,0 xfe,0 xff,0 xfe,0 xfc,0 xf8,0 xf0,0 xe0,0 xc0,0 x80,0 x00;void d

    24、elay()unsigned char i,j,k;for(i=0;i2;i+)for(j=0;j255;j+)for(k=0;k255;k+);void main()unsigned char i;while(1)for(i=0;i33;i+)P1=tabi;delay();实验5:按键应用实验(汇编)KEY BIT P3.3 SW1 BIT P2.7;P2.2 by htq ORG 000H START:mov sp,#40h mov p2,#0ffh mov p3,#0ffh MOV P1,#0ffh;clr key WAIT:;JB KEY,$;等候按键!by htq JB SW1,$

    25、lcall delay cpl P1.0 JNB SW1,$;wait key is released lcall delay;by htq JMP wait DELAY:MOV R3,#200 D1:MOV R4,#200 DJNZ R4,$DJNZ R3,D1 RET END功能:按下功能:按下SW1一次,发光管一次,发光管L1点点亮或熄灭亮或熄灭实验5:按键应用实验(C)/key SW1 is down,LED1 is swap(on or off)#include reg52.h#define uchar unsigned charsbit KEY=P33;sbit SW1=P27;s

    26、bit LED1=P10;void Delay()uchar i,j;for(i=0;i200;i+)for(j=0;j200;j+);void main()KEY=0;while(1)while(SW1);Delay();LED1=!LED1;while(!SW1);Delay();check all 6 key,light correspond LEDs,edit by htq 2009.9.4 keydat equ 22h KEY BIT P3.3ORG 000H START:mov sp,#40h mov p2,#0ffh mov p3,#0ffh MOV P1,#0ffh;clr k

    27、eyWAIT:;JB KEY,$;等候按键等候按键!by htq mov a,P2 cpla;if some key is down,then the bit is 0 anla,#0fch movkeydat,a;mov P0,a jznokey;the down key is 1;some key is down jbkeydat.7,sw1;sw1 is down jbkeydat.6,sw2;sw2 is down jbkeydat.5,sw3;sw3 is down jbkeydat.4,sw4;sw4 is down jbkeydat.3,sw5;sw5 is down jbkey

    28、dat.2,sw6;sw6 is down sjmpnokey实验5:按键应用实验(keylight1.asm)sw1:cplp1.0 sjmpnokey1sw2:cplp1.1 sjmpnokey1sw3:cplp1.2 sjmpnokey1sw4:cplp1.3 sjmpnokey1sw5:cplp1.4 sjmpnokey1sw6:cplp1.5nokey1:call delay;by htqnokey:JMP waitDELAY:movR2,#5 d2:MOV R3,#200D1:MOV R4,#200 DJNZ R4,$DJNZ R3,D1 djnzr2,d2 RET END实验5:

    29、按键应用实验(keylight1.c)/check all 6 key,light correspond LEDs,edit by htq 2009.9.18#include reg52.h#define uchar unsigned charsbit KEY=P33;sbit SW1=P27;sbit LED1=P10;sbit LED2=P11;sbit LED3=P12;sbit LED4=P13;sbit LED5=P14;sbit LED6=P15;bdata uchar KeyDat;void Delay()uchar i,j;for(i=0;i200;i+)for(j=0;j8;

    30、TL0=(unsigned char)(65536-4000);Count4ms=Count4ms+1;if(Count4ms=250)Count4ms=0;SecFlag=1;P2=Tabdisp_cnt;/dispP0=Tab1disp_buffdisp_cnt;disp_cnt=disp_cnt+1;if(disp_cnt=2)disp_cnt=0;void FillDispBuffer(void)disp_buff0=sec/10;disp_buff1=sec%10;void ChangeTime(void)SecFlag=0;sec=sec-1;if(sec=255)sec=99;F

    31、illDispBuffer();void main()/initialTMOD=0 x01;TH0=(65536-4000)8;TL0=(unsigned char)(65536-4000);TR0=1;ET0=1;EA=1;sec=99;FillDispBuffer();while(1)if(SecFlag)ChangeTime();void ChangeTime(void)SecFlag=0;sec=sec-1;if(sec=255)sec=99;FillDispBuffer();void main()/initialTMOD=0 x01;TH0=(65536-4000)8;TL0=(un

    32、signed char)(65536-4000);TR0=1;ET0=1;EA=1;/sec=99;FillDispBuffer();while(1)if(SecFlag)ChangeTime();实验14 电子时钟设计 6个数码管显示时、分、秒 6个按键分别对时、分、秒进行加1、减1设定 6按键SW1、SW6分别对应于P2.7P2.2 蜂鸣器:P2.0,为0时鸣响;问题:C程序中,是如何控制蜂鸣器的按键时鸣响的?C程序:变量定义部分#include reg52.hsbit Key=P33;bit KeyDownFlg;bit SecFlag;unsigned char Count4ms;un

    33、signed char disp_buff6;unsigned char disp_cnt;/0.5unsigned char hour,min,sec;unsigned char Beep_cnt;unsigned char P2_buff;unsigned char KeyBuff;code unsigned char Tab1=0 xC0,0 xF9,0 xA4,0 xB0,0 x99,0 x92,0 x82,0 xF8,0 x80,0 x90,0 x88,0 x83,0 xA7,0 xA1,0 x86,0 x8E;/;数码管显示字型表code unsigned char Tab6=0

    34、x7f,0 xbf,0 xdf,0 xef,0 xf7,0 xfb;C程序:定时器0中断服务子程序void T0_service(void)interrupt 1TH0=(65536-4000)8;TL0=(unsigned char)(65536-4000);Count4ms=Count4ms+1;if(Count4ms=250)Count4ms=0;SecFlag=1;P2_buff=Tabdisp_cnt;if(KeyDownFlg)P2_buff=P2_buff&0 xfe;/Buzzer is onBeep_cnt=Beep_cnt+1;if(Beep_cnt=100)/Buzzer

    35、 is offKeyDownFlg=0;/dispP2=P2_buff;P0=Tab1disp_buffdisp_cnt;disp_cnt=disp_cnt+1;if(disp_cnt=6)disp_cnt=0;C程序:主程序部分void main()/initialdisp_cnt=0;Count4ms=0;hour=0;min=0;sec=0;/TMOD=0 x01;TH0=(65536-4000)8;TL0=(unsigned char)(65536-4000);TR0=1;ET0=1;EA=1;while(1)if(SecFlag)ChangeTime();if(!Key)DealKe

    36、y();按键检测及处理void DealKey(void)KeyBuff=P2;if(KeyDownFlg)return;if(KeyBuff&0 x80)!=0 x80)/hour=hour+1;if(KeyBuff&0 x40)!=0 x40)/hour=hour-1;if(KeyBuff&0 x20)!=0 x20)/min=min+1;if(KeyBuff&0 x10)!=0 x10)/min=min-1;if(KeyBuff&0 x08)!=0 x08)/sec=sec+1;if(KeyBuff&0 x04)!=0 x04)/sec=sec-1;/check datahour=Che

    37、ckData(hour,24);min=CheckData(min,60);sec=CheckData(sec,60);FillDispBuffer();Beep_cnt=0;KeyDownFlg=1;实验14 电子时钟设计(shizhong1.asm)BUFF_KEY EQU 21H ;键盘键键盘键 BUFF_LED1 EQU 22H ;数码管显示缓存数码管显示缓存 BUFF_LED2 EQU 23H BUFF_LED3 EQU 24H BUFF_LED4 EQU 25H BUFF_LED5 EQU 26H BUFF_LED6 EQU 27H BUFF_LED_LP EQU 28H ;T0键

    38、盘显示扫描缓存键盘显示扫描缓存 HOR EQU 30H ;小时值缓存小时值缓存 MIN EQU 31H ;分钟值缓存分钟值缓存 SEC EQU 32H ;秒值缓存秒值缓存 MSequ 33h F_BEEP BIT 01H LED_PORT EQU P0 DIG_PORT EQU P2 KEY_PORT EQU P2 SW1 BIT P2.7 SW2 BIT P2.6 SW3 BIT P2.5 SW4 BIT P2.4 SW5 BIT P2.3 SW6 BIT P2.2 BEEP BIT P2.0 KEY BIT P3.3主程序:初始化部分 ORG 000H JMP MAIN ORG 00BH

    39、JMP T0_INT ORG 100HMAIN:MOV SP,#40H MOV PSW,#00H MOV R0,#7FH ;初始化初始化RAM区区,CLR_RAM:MOV A,#00H MOV R0,A DJNZ R0,CLR_RAM MOV P1,0FFH ;INIT MOV P2,0FFH MOV P0,0FFH MOV P3,0FFH MOV TMOD,#21h MOV TH0,#240 ;T0=4MS MOV TL0,#96 SETB TR0 SETB ET0 SETB EA 主程序:按键检测与处理(1)WAIT_KEY:JB KEY,$;等候按键等候按键!JNB SW1,SW1_OK

    40、 JNB SW2,SW2_OK JNB SW3,SW3_OK JNB SW4,SW4_OK JNB SW5,SW5_OKA JNB SW6,SW6_OKA JMP WAIT_KEYSW5_OKA:JMP SW5_OK SW6_OKA:JMP SW6_OKSW1_OK:MOV A,HOR CJNE A,#24,SW1_OVER MOV HOR,#00H SETB F_BEEP CLR BEEP LCALL DEL SETB BEEP CLR F_BEEP JMP WAIT_KEYSW1_OVER:INC HOR ;时加时加1 SETB F_BEEP CLR BEEP LCALL DEL SETB

    41、 BEEP CLR F_BEEP JMP WAIT_KEYSW2_OK:MOV A,HOR CJNE A,#00,SW2_OVER MOV HOR,#23 SETB F_BEEP CLR BEEP LCALL DEL SETB BEEP CLR F_BEEP JMP WAIT_KEYSW2_OVER:DEC HOR ;时减时减1 SETB F_BEEP CLR BEEP LCALL DEL SETB BEEP CLR F_BEEP JMP WAIT_KEYSW3_OK:MOV A,MIN CJNE A,#59,SW3_OVER MOV MIN,#00H SETB F_BEEP CLR BEEP

    42、 LCALL DEL SETB BEEP CLR F_BEEP JMP WAIT_KEYSW3_OVER:INC MIN ;分加分加1 SETB F_BEEP CLR BEEP LCALL DEL SETB BEEP CLR F_BEEP JMP WAIT_KEYSW4_OK:MOV A,MIN CJNE A,#00,SW4_OVER MOV MIN,#59 SETB F_BEEP CLR BEEP LCALL DEL SETB BEEP CLR F_BEEP JMP WAIT_KEYSW4_OVER:DEC MIN ;分减分减1 SETB F_BEEP CLR BEEP LCALL DEL

    43、SETB BEEP CLR F_BEEP JMP WAIT_KEYSW5_OK:MOV A,SEC CJNE A,#59,SW5_OVER MOV SEC,#00H SETB F_BEEP CLR BEEP LCALL DEL SETB BEEP CLR F_BEEP JMP WAIT_KEYSW5_OVER:INC SEC ;秒加秒加1 SETB F_BEEP CLR BEEP LCALL DEL SETB BEEP CLR F_BEEP JMP WAIT_KEYSW6_OK:MOV A,SEC CJNE A,#00,SW6_OVER MOV HOR,#59 SETB F_BEEP CLR

    44、BEEP LCALL DEL SETB BEEP CLR F_BEEP JMP WAIT_KEYSW6_OVER:DEC SEC ;时减时减1 SETB F_BEEP CLR BEEP LCALL DEL SETB BEEP CLR F_BEEP JMP WAIT_KEYDEL:MOV R5,#02 ;为演示方便为演示方便,人为人为插入的延时插入的延时DEL01:MOV R6,#200DEL02:MOV R7,#200 DJNZ R7,$DJNZ R6,DEL02 DJNZ R5,DEL01 RET中断程序:修改时间部分T0_INT:PUSH ACC PUSH PSW MOV TH0,#240

    45、 ;T0=4MS MOV TL0,#96 INC BUFF_LED_LP MOV A,BUFF_LED_LP CJNE A,#250,CONT_SCAN ;250*4MS=1S MOV BUFF_LED_LP,#00H INC SEC MOV A,SEC CJNE A,#60,CONT_SCAN MOV SEC,#00H INC MIN MOV A,MIN CJNE A,#60,CONT_SCAN MOV MIN,#00H INC HOR MOV A,HOR CJNE A,#24,CONT_SCAN MOV HOR,#00H中断程序:填充显示缓冲区CONT_SCAN:MOV A,SEC LCA

    46、LL BIN_BCD MOV BUFF_LED6,B MOV BUFF_LED5,A MOV A,MIN LCALL BIN_BCD MOV BUFF_LED4,B MOV BUFF_LED3,A MOV A,HOR LCALL BIN_BCD MOV BUFF_LED2,B MOV BUFF_LED1,A MOV A,BUFF_LED_LP MOV B,#06 DIV AB MOV A,B RL A MOV DPTR,#TAB_SCAN JMP A+DPTR中断程序:动态显示TAB_SCAN:AJMP SCAN_L1 AJMP SCAN_L2 AJMP SCAN_L3 AJMP SCAN_L

    47、4 AJMP SCAN_L5 AJMP SCAN_L6SCAN_L1:MOV DIG_PORT,#01111111B MOV A,BUFF_LED1 JMP END_SCANSCAN_L2:MOV DIG_PORT,#10111111B MOV A,BUFF_LED2 JMP END_SCANSCAN_L3:MOV DIG_PORT,#11011111B MOV A,BUFF_LED3 JMP END_SCANSCAN_L4:MOV DIG_PORT,#11101111B MOV A,BUFF_LED4 JMP END_SCANSCAN_L5:MOV DIG_PORT,#11110111B M

    48、OV A,BUFF_LED5 JMP END_SCANSCAN_L6:MOV DIG_PORT,#11111011B MOV A,BUFF_LED6END_SCAN:MOV DPTR,#TAB_LED MOVC A,A+DPTR MOV LED_PORT,A JNB F_BEEP,EXIT_T0 CLR BEEPEXIT_T0:POP PSW POP ACC RETITAB_LED:DB 0C0H,0F9H,0A4H,0B0H,99H,92H ;数码管显示字型表DB 82H,0F8H,80H,90H,88H,83H,0A7HDB 0A1H,86H,8EH 实验19 AD转换器的使用 功能:对输

    49、入的电压进行AD转换,并将结果(0255)用数码管进行显示 使用ADC0832 双通道,8位AD转换器,单+5V供电,Vref=5V AD输入模拟电压范围:05V 5V对应:255 串行接口(4线)CS(P3.5)CLK(P2.1)DI(P3.6)DO(P3.7)ADC0832接口时序最大的问题 动态显示资源与AD转换器冲突 AD转换器与单片机接口的实现实验19 AD转换器的使用(ad.c)#include reg52.hsbit ADC_CS=P35;sbit ADC_CLK=P21;sbit ADC_DI=P36;sbit ADC_DO=P37;bit SecFlag;bit F_ADC_

    50、CLK;unsigned char Count4ms;unsigned char disp_buff6;unsigned char disp_cnt;/0.5unsigned char hour,min,sec;unsigned char Beep_cnt;unsigned char P2_buff;unsigned char ADData;code unsigned char Tab117=0 xC0,0 xF9,0 xA4,0 xB0,0 x99,0 x92,0 x82,0 xF8,0 x80,0 x90,0 x88,0 x83,0 xA7,0 xA1,0 x86,0 x8E,0 xff;

    展开阅读全文
    提示  163文库所有资源均是用户自行上传分享,仅供网友学习交流,未经上传用户书面授权,请勿作他用。
    关于本文
    本文标题:单片机在线系统AY-MPU89S51E课件.ppt
    链接地址:https://www.163wenku.com/p-4538473.html

    Copyright@ 2017-2037 Www.163WenKu.Com  网站版权所有  |  资源地图   
    IPC备案号:蜀ICP备2021032737号  | 川公网安备 51099002000191号


    侵权投诉QQ:3464097650  资料上传QQ:3464097650
       


    【声明】本站为“文档C2C交易模式”,即用户上传的文档直接卖给(下载)用户,本站只是网络空间服务平台,本站所有原创文档下载所得归上传人所有,如您发现上传作品侵犯了您的版权,请立刻联系我们并提供证据,我们将在3个工作日内予以改正。

    163文库