Instructions for the experiment on data moving
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
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. - 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.
- Performance in-class (70%);
- Lab report (30 %);
单片机源程序如下:
- ORG 0000H ;程序从此地址开始运行
- LJMP MAIN ;跳转到 MAIN 程序处
- ORG 030H ;MAIN 从030H处开始
- MAIN:
- ;*************Add your code below*************************************
- MOV 40H,#02H
- MOV 41H,#00H
- MOV 42H,#01H
- MOV 43H,#06H
- MOV 44H,#01H
- MOV 45H,#04H
- MOV 46H,#01H
- MOV 47H,#04H
- MOV 48H,#01H
- MOV 49H,#01H
- MOV 4AH,#02H
- MOV 4BH,#02H
- MOV 4CH,#02H ;在40H-4CH里面存入2016141411222学号
- MOV DPTR,#TAB
- MOV R0,#40H ;R0=40H
- MOV A,@R0 ;A=02H
- MOVC A,@A+DPTR ;A=0A4H
- MOV P0,A ;2
- INC R0 ;R0=41H
- LCALL DELAY ;延时
- MOV A,@R0 ;A=00H
- MOVC A,@A+DPTR ;A=0C0H
- MOV P0,A ;0
- INC R0 ;R0=42H
- LCALL DELAY
- MOV A,@R0 ;A=01H
- MOVC A,@A+DPTR ;A=0F9H
- MOV P0,A ;1
- INC R0 ;R0=43H
- LCALL DELAY
- MOV A,@R0 ;A=06H
- MOVC A,@A+DPTR ;A=82H
- MOV P0,A ;6
- INC R0 ;R0=44H
- LCALL DELAY
- MOV A,@R0 ;A=01H
- MOVC A,@A+DPTR ;A=0F9H
- MOV P0,A ;1
- INC R0 ;R0=45H
- LCALL DELAY
- MOV A,@R0 ;A=04H
- MOVC A,@A+DPTR ;A=99H
- MOV P0,A ;4
- INC R0 ;R0=46H
- LCALL DELAY
- MOV A,@R0 ;A=01H
- MOVC A,@A+DPTR ;A=0F9H
- MOV P0,A ;1
- INC R0 ;R0=47H
- LCALL DELAY
- MOV A,@R0 ;A=04H
- MOVC A,@A+DPTR ;A=99H
- MOV P0,A ;4
- INC R0 ;R0=48H
- LCALL DELAY
- MOV A,@R0 ;A=01H
- MOVC A,@A+DPTR ;A=0F9H
- MOV P0,A ;1
- INC R0 ;R0=49H
- LCALL DELAY
- MOV A,@R0 ;A=01H
- MOVC A,@A+DPTR ;A=0F9H
- MOV P0,A ;1
- INC R0 ;R0=4AH
- LCALL DELAY
- MOV A,@R0 ;A=02H
- MOVC A,@A+DPTR ;A=0A4H
- MOV P0,A ;2
- INC R0 ;R0=4BH
- LCALL DELAY
- MOV A,@R0 ;A=02H
- MOVC A,@A+DPTR ;A=0A4H
- MOV P0,A ;2
- INC R0 ;R0=4CH
- LCALL DELAY
- MOV A,@R0 ;A=02H
- MOVC A,@A+DPTR ;A=0A4H
- MOV P0,A ;2
- LCALL DELAY
- ;*********************************************************************
- AJMP MAIN ;跳转到主程序处
- DELAY:
- MOV R5,#04H ;将立即数传给寄存器R5
- F3:
- MOV R6,#0FFH
- F2:
- MOV R7,#0FFH
- F1:
- DJNZ R7,F1 ;若为0程序向下执行,若不为0程序跳转到
- DJNZ R6,F2
- DJNZ R5,F3
- RET
- ;七段数码显管显示数字编码(对应0~F)
- ;TAB: DB 3Fh,06h,5Bh,4Fh,66h,6Dh,7Dh,07h,7Fh,6Fh,77h,7Ch,39h,5Eh,79h,71h ;共阴极七段数码显管
- TAB: DB 0C0h,0F9h,0A4h,0B0h,99h,92h,82h,0F8h,80h,90h,88h,83h,0C6h,0A1h,86h,8Eh ;共阳极七段数码显管
- END
复制代码
所有资料51hei提供下载:
Lab 2.rar
(1.88 MB, 下载次数: 4)
|