找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 1605|回复: 0
打印 上一主题 下一主题
收起左侧

Data moving的单片机小程序与英文说明

[复制链接]
跳转到指定楼层
楼主


Instructions for the experiment on data moving

  • Experiment Objectives

The main objective of in-class lab 2 is to achieve data moving on the appropriate hardware and software development platform, with the specific objective as follow:

  •    Be able to use the different addressing mode, including immediate, register, direct, indirect, register indexed etc., to accomplish the required tasks.
  • Main Experiment Apparatus
  • Software platform:

This experiment could be implemented by using simulation software Keil μvision and burning software PZISP which are stored in the optical accompanied withmicrocontroller development toolkit.

  • Hardware platform:
  •    PRECHIN microcontroller development toolkit as shown below, including the main board (HC6800EM3-V3.0) and other accessories:

  •    Seven-segment display (SSD)

The SSD used in the experimental toolkit adopts common anode configuration with the circuit shown below.

  • Experiment Tasks and Requirements

Each student should complete the following task independently in class:

  •    Write a program to display your own student matriculation number on the seven-segment display (SSD) sequentially.

Reference steps:

  •    Connect the SSD (JP3) with port 0 (P0) with wires as shown in the following figure

  •    Create a project in Keil uvision IDE
  •    Add the assembly code “DataMoving.asm” into the project
  •    Write the program in the section shown in the following figure

  •    Store your student matriculation number in RAM address starting from 40H using immediate addressing mode.
  •    Copy each digit of the matriculation number stored in RAM using register indirect addressing mode to register A.
  •    Fetch the corresponding hexadecimal encoding stored in ROM using register indexed addressing mode and store it in register A.
  •    Copy the fetched hexadecimal encoding to port 0 (P0).
  •    After copying a number to P0, add an instruction “AJMP DELAY” below to pause for a moment so that we can check the result on SSD clearly.
  • Grading
  • Performance in-class (70%);
  • Lab report (30 %);



单片机源程序如下:
  1.         ORG         0000H            ;程序从此地址开始运行
  2.         LJMP         MAIN            ;跳转到 MAIN 程序处

  3.         ORG         030H            ;MAIN 从030H处开始
  4. MAIN:
  5. ;*************Add your code below*************************************
  6.         MOV                40H,#02H
  7.         MOV                41H,#00H
  8.         MOV                42H,#01H
  9.         MOV                43H,#06H
  10.         MOV                44H,#01H
  11.         MOV                45H,#04H
  12.         MOV                46H,#01H
  13.         MOV                47H,#04H
  14.         MOV                48H,#01H
  15.         MOV                49H,#01H
  16.         MOV                4AH,#02H
  17.         MOV                4BH,#02H
  18.         MOV                4CH,#02H        ;在40H-4CH里面存入2016141411222学号
  19.         MOV                DPTR,#TAB
  20.         MOV                R0,#40H                ;R0=40H
  21.         MOV                A,@R0                ;A=02H
  22.         MOVC        A,@A+DPTR        ;A=0A4H
  23.         MOV                P0,A                ;2
  24.         INC                R0                        ;R0=41H
  25.         LCALL        DELAY                ;延时
  26.         MOV                A,@R0                ;A=00H
  27.         MOVC        A,@A+DPTR        ;A=0C0H
  28.         MOV                P0,A                ;0
  29.         INC                R0                        ;R0=42H
  30.         LCALL        DELAY                                                         
  31.         MOV                A,@R0                ;A=01H
  32.         MOVC        A,@A+DPTR        ;A=0F9H
  33.         MOV                P0,A                ;1
  34.         INC                R0                        ;R0=43H
  35.         LCALL        DELAY
  36.         MOV                A,@R0                ;A=06H
  37.         MOVC        A,@A+DPTR        ;A=82H
  38.         MOV                P0,A                ;6
  39.         INC                R0                        ;R0=44H
  40.         LCALL        DELAY
  41.         MOV                A,@R0                ;A=01H
  42.         MOVC        A,@A+DPTR        ;A=0F9H
  43.         MOV                P0,A                ;1
  44.         INC                R0                        ;R0=45H
  45.         LCALL        DELAY
  46.         MOV                A,@R0                ;A=04H
  47.         MOVC        A,@A+DPTR        ;A=99H
  48.         MOV                P0,A                ;4
  49.         INC                R0                        ;R0=46H
  50.         LCALL        DELAY
  51.         MOV                A,@R0                ;A=01H
  52.         MOVC        A,@A+DPTR        ;A=0F9H
  53.         MOV                P0,A                ;1
  54.         INC                R0                        ;R0=47H
  55.         LCALL        DELAY               
  56.         MOV                A,@R0                ;A=04H
  57.         MOVC        A,@A+DPTR        ;A=99H
  58.         MOV                P0,A                ;4
  59.         INC                R0                        ;R0=48H
  60.         LCALL        DELAY
  61.         MOV                A,@R0                ;A=01H
  62.         MOVC        A,@A+DPTR        ;A=0F9H
  63.         MOV                P0,A                ;1
  64.         INC                R0                        ;R0=49H
  65.         LCALL        DELAY
  66.         MOV                A,@R0                ;A=01H
  67.         MOVC        A,@A+DPTR        ;A=0F9H
  68.         MOV                P0,A                ;1
  69.         INC                R0                        ;R0=4AH
  70.         LCALL        DELAY
  71.         MOV                A,@R0                ;A=02H
  72.         MOVC        A,@A+DPTR        ;A=0A4H
  73.         MOV                P0,A                ;2
  74.         INC                R0                        ;R0=4BH
  75.         LCALL        DELAY
  76.         MOV                A,@R0                ;A=02H
  77.         MOVC        A,@A+DPTR        ;A=0A4H
  78.         MOV                P0,A                ;2
  79.         INC                R0                        ;R0=4CH
  80.         LCALL        DELAY
  81.         MOV                A,@R0                ;A=02H
  82.         MOVC        A,@A+DPTR        ;A=0A4H
  83.         MOV                P0,A                ;2
  84.         LCALL        DELAY        
  85. ;*********************************************************************
  86.         AJMP         MAIN        ;跳转到主程序处

  87. DELAY:        
  88.         MOV         R5,#04H           ;将立即数传给寄存器R5
  89. F3:        
  90.         MOV         R6,#0FFH
  91. F2:        
  92.         MOV         R7,#0FFH
  93. F1:        
  94.         DJNZ         R7,F1               ;若为0程序向下执行,若不为0程序跳转到
  95.         DJNZ         R6,F2
  96.         DJNZ         R5,F3
  97.         RET

  98. ;七段数码显管显示数字编码(对应0~F)
  99. ;TAB: DB 3Fh,06h,5Bh,4Fh,66h,6Dh,7Dh,07h,7Fh,6Fh,77h,7Ch,39h,5Eh,79h,71h                 ;共阴极七段数码显管
  100. TAB: DB 0C0h,0F9h,0A4h,0B0h,99h,92h,82h,0F8h,80h,90h,88h,83h,0C6h,0A1h,86h,8Eh         ;共阳极七段数码显管
  101.         END
复制代码




所有资料51hei提供下载:
Lab 2.rar (1.88 MB, 下载次数: 4)


评分

参与人数 1黑币 +50 收起 理由
admin + 50 共享资料的黑币奖励!

查看全部评分

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表