1 / 7

实验五

实验五. P1 口输入、输出实验. 实验要求. 1 、 P1 口做输出口,接八只发光二极管,编写程序,使发光二极管循环点亮。 2 、 P1.0,P1.1 作输入口接两个拨动开关, P1.2,P1.3 作输出口,接两个发光二极管,编写程序读取开关状态,将此状态,在发光二极管上显示出来。编程时应注意 P1.0,P1.1 作为输入口时应先置 1, 才能正确读入值。. 实验目的. 1 、学习 P1 口的使用方法。 2 、学习延时子程序的编写和使用。. 实验电路及连线. 实验 1:P1 口循环点灯 实验 2:P1 口输入输出实验. 开始. 开始.

amory
Download Presentation

实验五

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 实验五 P1口输入、输出实验

  2. 实验要求 1、P1口做输出口,接八只发光二极管,编写程序,使发光二极管循环点亮。 2、P1.0,P1.1作输入口接两个拨动开关,P1.2,P1.3作输出口,接两个发光二极管,编写程序读取开关状态,将此状态,在发光二极管上显示出来。编程时应注意P1.0,P1.1作为输入口时应先置1,才能正确读入值。

  3. 实验目的 • 1、学习P1口的使用方法。 • 2、学习延时子程序的编写和使用。

  4. 实验电路及连线 实验1:P1口循环点灯 实验2:P1口输入输出实验

  5. 开始 开始 设置初始值 P1.0,P1.1置1 读入P1.0口值 设移位次数 数据输出 将读入的值输出到P1.2 读入P1.1口值 左移一位 延时 将读入的值输出到P1.3 是 否 移位次数完成? 程序框图 (B) P1口输入输出程序框图 (A) P1口循环点灯程序框图

  6. 程序清单 实验1:P1口循环点灯 Loop: mov a, #01h mov r2, #8 Output: mov P1, a rl a call Delay djnz r2, Output ljmp Loop Delay: mov r6, #0 mov r7, #0 DelayLoop: djnz r6, DelayLoop djnz r7, DelayLoop ret end

  7. 程序清单 实验2:P1口输入输出 KeyLeft equ P1.0 KeyRight equ P1.1 LEDLeft equ P1.2 LEDRight equ P1.3 setb KeyLeft setb KeyRight Loop: mov c, KeyLeft mov LEDLeft, c mov c, KeyRight mov LEDRight, c ljmp Loop end

More Related