LAB ASSIGNMENT Embedded System Design

Similar documents
Flash Microcontroller. Architectural Overview. Features. Block Diagram. Figure 1. Block Diagram of the AT89C core

8051 Serial Port. Crystal TXD. I/O Device RXD. Embedded Systems Peripherals

CoE3DJ4 Digital Systems Design. Chapter 4: Timer operation

Flash Microcontroller. Memory Organization. Memory Organization

8051 hardware summary

8085 MICROPROCESSOR PROGRAMS

Atmel 8051 Microcontrollers Hardware Manual

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Question Bank Subject Name: EC Microprocessor & Microcontroller Year/Sem : II/IV

Instruction Set. Microcontroller Instruction Set. Instructions that Affect Flag Settings (1) The Instruction Set and Addressing Modes

4 Character 5x7 LED Matrix Display

Embedded. Engineer s. Development. Tool (EEDT 5.0)

T.C. Yeditepe University. Department of Electrical-Electronics Engineering

AN108 IMPLEMENTING A REALTIME CLOCK. Relevant Devices. Introduction. Key Points. Overview

8-bit Microcontroller with 2/4-Kbyte Flash AT89LP2052 AT89LP4052

Z80 Instruction Set. Z80 Assembly Language

AT89C Bit Microcontroller with 1 Kbyte Flash. Features. Description. Pin Configuration

Serial Communications

Quick Start Tutorial. Using the TASKING* Software Development Tools with the Intel 8x930 Family Evaluation Board

8085 INSTRUCTION SET

University of Portsmouth Faculty of Technology Department of Electronic and Computer Engineering. Content

Keil C51 Cross Compiler

SHENZHEN JINGHUA DISPLAYS CO.,LTD.

8-Bit Flash Microcontroller for Smart Cards. AT89SCXXXXA Summary. Features. Description. Complete datasheet available under NDA

ELEG3924 Microprocessor Ch.7 Programming In C

PART B QUESTIONS AND ANSWERS UNIT I

Section Microcontroller Instruction Set

MACHINE ARCHITECTURE & LANGUAGE

Microcomputer Components SAB 80515/SAB 80C515 8-Bit Single-Chip Microcontroller Family

MICROPROCESSOR AND MICROCOMPUTER BASICS

Interfacing Analog to Digital Data Converters

Hardware and Software Requirements

Design and Implementation of Home Monitoring System Using RF Technology

Complete 8086 instruction set

8051 MICROCONTROLLER COURSE

8-bit Microcontroller with 2K/4K Bytes Flash AT89S2051 AT89S4051

MEMOBUS/Modbus Communications

TDA General description. 2. Features and benefits. Low power single card reader

COMPUTERS ORGANIZATION 2ND YEAR COMPUTE SCIENCE MANAGEMENT ENGINEERING JOSÉ GARCÍA RODRÍGUEZ JOSÉ ANTONIO SERRA PÉREZ

DS87C520/DS83C520 EPROM/ROM High-Speed Micro

8-bit Microcontroller with 2K Bytes Flash AT89C2051

M6800. Assembly Language Programming

Site Master S251B Antenna and Cable Analyzer

Technical Note. SFDP for MT25Q Family. Introduction. TN-25-06: Serial Flash Discovery Parameters for MT25Q Family. Introduction

AN135 CACHE OPTIMIZATIONS FOR C8051F12X. Overview. Relevant Devices. Introduction. Key Points

DS1621 Digital Thermometer and Thermostat

Using the Intel MCS -51 Boolean Processing Capabilities

Appendix C: Keyboard Scan Codes

8-bit Microcontroller with 8K Bytes In-System Programmable Flash. AT89LP52 - Preliminary

Small Hardware Development and Prototyping Board for the SX28

AVR305: Half Duplex Compact Software UART. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

8-bit Microcontroller with 12K Bytes Flash and 2K Bytes EEPROM AT89S8253

8-bit Microcontroller with 8K Bytes In-System Programmable Flash AT89S52

ARM Thumb Microcontrollers. Application Note. Software ISO 7816 I/O Line Implementation. Features. Introduction

DS1621 Digital Thermometer and Thermostat

LABORATORY MANUAL EE0310 MICROPROCESSOR & MICROCONTROLLER LAB

8051 Integrated Development Environment

DS87C530/DS83C530. EPROM/ROM Micro with Real Time Clock PRELIMINARY FEATURES PACKAGE OUTLINE DALLAS DS87C530 DS83C530 DALLAS DS87C530 DS83C530

2011, The McGraw-Hill Companies, Inc. Chapter 3

PACKAGE OUTLINE DALLAS DS2434 DS2434 GND. PR 35 PACKAGE See Mech. Drawings Section

Faculty of Engineering Student Number:

CAM-VGA100 User Manual


The stack and the stack pointer

Timer A (0 and 1) and PWM EE3376

Modbus RTU Communications RX/WX and MRX/MWX

Application Note. Introduction AN2471/D 3/2003. PC Master Software Communication Protocol Specification

80C51/87C51/80C52/87C52 80C51 8-bit microcontroller family 4 K/8 K OTP/ROM low voltage (2.7 V 5.5 V), low power, high speed (33 MHz), 128/256 B RAM

Software design for self-sustaining embedded systems

24-Bit Analog-to-Digital Converter (ADC) for Weigh Scales FEATURES S8550 VFB. Analog Supply Regulator. Input MUX. 24-bit Σ ADC. PGA Gain = 32, 64, 128

Interrupts and the Timer Overflow Interrupts Huang Sections What Happens When You Reset the HCS12?

8-Bit Microcontroller with 8K Bytes Flash AT89S8252. Features. Description

PROBLEMS (Cap. 4 - Istruzioni macchina)

Sécurité des cartes à puce

Microcontroller Basics A microcontroller is a small, low-cost computer-on-a-chip which usually includes:

1 Classical Universal Computer 3

Embedded Based Automated Student Attendance Governing System

Develop a Dallas 1-Wire Master Using the Z8F1680 Series of MCUs

PIN ASSIGNMENT PIN QFP

Lesson-16: Real time clock DEVICES AND COMMUNICATION BUSES FOR DEVICES NETWORK

Z80 Family. CPU User Manual

Lab Experiment 1: The LPC 2148 Education Board

Z80 Microprocessors Z80 CPU. User Manual UM Copyright 2014 Zilog, Inc. All rights reserved.

MBP_MSTR: Modbus Plus Master 12

Hi Hsiao-Lung Chan Dept Electrical Engineering Chang Gung University, Taiwan

Interface Protocol v1.2

8-bit RISC Microcontroller. Application Note. AVR236: CRC Check of Program Memory

A single register, called the accumulator, stores the. operand before the operation, and stores the result. Add y # add y from memory to the acc

Microcontroller Systems. ELET 3232 Topic 8: Slot Machine Example

Programing the Microprocessor in C Microprocessor System Design and Interfacing ECE 362

LENORD. +BAUER... automates motion. Fieldbus connection absolute encoders CANopen. Reference. Communication profile DS-301 Device profile DS-406

ASCII and BCD Arithmetic. Chapter 11 S. Dandamudi

Introduction to Microcontrollers

AN141 SMBUS COMMUNICATION FOR SMALL FORM FACTOR DEVICE FAMILIES. 1. Introduction. 2. Overview of the SMBus Specification. 2.1.

The goal is to program the PLC and HMI to count with the following behaviors:

Microprocessor & Assembly Language

Instruction Set Architecture

Virtual Integrated Design Getting started with RS232 Hex Com Tool v6.0

Old Company Name in Catalogs and Other Documents

MICROPROCESSOR. Exclusive for IACE Students iacehyd.blogspot.in Ph: /422 Page 1

Call Subroutine (PC<15:0>) TOS, (W15)+2 W15 (PC<23:16>) TOS, Process data. Write to PC NOP NOP NOP NOP

Transcription:

LAB ASSIGNMENT Embedded System Design Student: ID: Class:

Embedded System Design Lab Page - 2/21 CONTENTS 010 Problem: Page 1. Addressing modes... 3 2. Double number... 4 3. Xor and compare... 5 4. Plus unsigned numbers at 3 memory location... 6 5. Plus unsigned numbers at 3 memory location... 7 6. Plus BCD numbers... 8 7. Loop... 9 8. Multiply... 10 9. Divide... 11 10. Define Byte DB and compare... 12 11. Sorting values in memory locations... 13 12a. Linear search external memory... 15 12b. Binary search external memory... 17 13. Interrupt transmission... 18 14. Polling transmisstion... 19 15. Serial communication... 20 16. Input output ports, COM port communication... 21

Embedded System Design Lab Page - 3/21 Problem 1: Copy the byte in TCON to register R2 using at least four different methods. a. Use the direct address for TCON b. Use the direct address for TCON and R2 c. Use R1 as a pointer to R2 and use the address for TCON d. Push the content of TCON into direct address Code listing a: mov 88h, #50h mov R2, 88h ; TCON address is 88h ; copy content TCON from its direct address Code listing b: mov 02h, 88h ; copy direct addrect of TCON to direct address of R2 Code listing c: mov R1, #02h mov @R1, 88h ; R1 contains value 02h which is direct address of R2 ; copy TCON to direct address that R1 point to Code listing d: push 88h pop 02h ; push TCON to stack ; pop top of stack to direct addrect of R2

Embedded System Design Lab Page - 4/21 Problem 2: Double the number in register R2, and put the result in registers R3 (high byte) and R4 (low byte). mov R2, #0F2H mov A, R2 mov R3, #0 add A, R2 mov R4, A jnc over mov R3, #1 over: ; copy R2 content to A ; copy R2 content to A ; clear R3 ; double R2 ; copy low byte result to R4 ; if CY = 0 then finish ; if CY=1 then set 1 to R3 (high byte result)

Embedded System Design Lab Page - 5/21 Problem 3: Find a number that, when XORed to the register A, results in the number 3Fh in A. mov R1,#0FFh ; copy initial maximum value to R1 again: mov A,#54h ; copy test value #54h to A xrl A, R1 ; xor A with R1 dec R1 ; decrement R1 cjne A,#3Fh, again ; test if result = #3Fh inc R1 ; finding number contains in R1 54h = 01010100 6Bh = 01101011 xor = 00111111 = 3Fh

Embedded System Design Lab Page - 6/21 Problem 4: Add the unsigned numbers found in internal RAM locations 25h, 26h and 27h together and put the result in RAM location 31h(MSB) and 30h(LSB). mov 25h,#0FFh ; copy test value #0FFh to address 25h mov 26h,#0FAh ; copy test value #0FAh to address 26h mov 27h,#0EEh ; copy test value #0EEh to address 27h mov R1,#0 ; clear R1 clr C ; clear Carry mov A,25h ; copy value from address 25h to A add A,26h ; add value from address 26h to A jnc next1 ; if CY=0 then add next value inc R1 ; if CY=1 then increase R1 clr C ; clear Carry next1: add A,27h ; add next value from address 27h to A jnc next2 ; if CY=0 then report the result inc R1 ; if CY=1 then increase R1 next2: mov 30h,A ; copy LSB to address 30h mov 31h,R1 ; copy MSB to address 31h

Embedded System Design Lab Page - 7/21 Problem 5: Add the signed numbers found in internal RAM locations 25h, 26h and 27h together and put the result in RAM location 31h(MSB) and 30h(LSB). mov 25h,#+20 ; copy test value #+20 to address 25h mov 26h,#-30 ; copy test value #-30 to address 26h mov 27h,#+70 ; copy test value #+70 to address 27h mov R1,#0 ; clear R1 mov A,25h ; copy value from address 25h to A add A,26h ; add value from address 26h to A jb PSW.2,over ; if overflow flag OV=1 then cancelled jnc next1 ; if CY=0 then add next value inc R1 ; if CY=1 then increase R1 next1: add A,27h ; add next value from address 27h to A jb PSW.2,over ; if overflow flag OV=1 then cancelled jnc next2 ; if CY=0 then add next value inc R1 ; if CY=1 then increase R1 next2: mov 30h,A ; copy LSB to address 30h mov 31h,R1 ; copy MSB to address 31h over:

Embedded System Design Lab Page - 8/21 Problem 6: Add the BCD numbers found in internal RAM locations 25h, 26h and 27h together and put the result in RAM location 31h(MSB) and 30h(LSB). mov 25h,#37h ; copy test value #37h to address 25h mov 26h,#48h ; copy test value #48h to address 26h mov 27h,#87h ; copy test value #87h to address 27h mov R1,#0 ; clear R1 mov A,25h ; copy value from address 25h to A add A,26h ; add value from address 26h to A da A ; adjust A to BCD number jnc next1 ; if CY=0 then add next value inc R1 ; if CY=1 then increase R1 next1: add A,27h ; add next value from address 27h to A da A ; adjust A to BCD number jnc next2 ; if CY=0 then add next value inc R1 ; if CY=1 then increase R1 next2: mov 30h,A ; copy LSB to address 30h mov 31h,R1 ; copy MSB to address 31h

Embedded System Design Lab Page - 9/21 Problem 7: Place any number in internal RAM location 3Ch and increment it until the number equals 2Ah. mov 3Ch,#20h ; test value in address 3Ch mov R1,#3Ch ; R1 contains value #3Ch again: mov A,@R1 ; copy value in address that R1 point to A cjne A,#2Ah,next ; compare A with value #2Ah sjmp over ; if equal then finish next: inc @R1 ; increment value in address 3Ch sjmp again ; repeat while not equal over:

Embedded System Design Lab Page - 10/21 Problem 8: Multiply the data in RAM location 22h by the data in RAM location 15h.Put the result in RAM Location 19h(LSB) and 1Ah(MSG). mov 15h,#40 ; test value 1 in address 15h mov 22h,#7 ; test value 2 in address 22h mov A,15h ; copy test value 1 to A mov B,22h ; copy test value 2 to B mul AB ; multiply A with B mov 19h,A ; copy LSB of result to address 19h mov 1Ah,B ; copy MSB of result to 1Ah

Embedded System Design Lab Page - 11/21 Problem 9: Divide the data in RAM Location 3Eh by the number 12h. Put the quotient in R4 and remainer in R5 mov 3Eh,#29h mov A,3Eh mov B,#12h div AB mov R4,A mov R5,B ; test value #29h in address 3Eh ; copy value in address 3Eh to A ; copy #12h to B ; divide A to B ; copy quotient to R4 ; copy remainer to R5

Embedded System Design Lab Page - 12/21 Problem 10: Define a number in external RAM using DB. Check whether the number is even or odd. If it is even set C to 1, otherwise clear C. org 500h ; at address 500h, define byte value 7h data1: DB 7h ; 7h in external memory 500h org 0 mov DPTR, #500h ; DPTR contain external address 500h clr A ; clear A movc A, @a+dptr ; copy value from external memory to A clr C ; reset Carry rrc A ; rotate right A to carry jb CY,odd ; if odd setb C ; if even sjmp over ; finish odd: clr C over:

Embedded System Design Lab Page - 13/21 Problem 11: Write a program to sort (ascing/descing) the array which is stored in external RAM. mov 30h,#4h ; test values put in address 30h-33h mov 31h,#6h mov 32h,#5h mov 33h,#1h mov R1,#30h mov R7,#3 ; outer loop counter mov R6,#4 ; inner loop counter outerloop: mov A,R1 mov R0,A mov A,@R1 ;copy first value for each cycle dec R6 mov 03h,R6 interloop: clr c inc R0 ; travel inner loop mov 40h,@R0 ; use addr 40h for compare value cjne A,40h,next ; cy=1 if a less than sjmp nextloop next: jnc exchange ; if cy=1 then swap sjmp nextloop exchange: mov 02h,A mov A,@R0 mov @R0,02h nextloop: nop djnz R6,interloop mov @R1,A mov R6,03h inc R1 djnz R7,outerloop mov R4,30h mov R5,31h mov R6,32h mov R7,33h ; display result in registers R4-R7

Embedded System Design Lab Page - 14/21

Embedded System Design Lab Page - 15/21 Problem 12a: Linear Search Write a program for searching an element which is stored in external RAM location between 0100h and 0200h. Also find out the address of the found element. Address of the element will be stored in the register R6 (LSB) and R7 (MSB). Return A=1 if element is found otherwise 0. Perform searching using at least any two following techniques. 1. Linear Search 2. Binary search 3. even/odd Search Code listing(linear search): mov DPTR,#100h ; DPTR point to address 100h external memory mov A,#20h ; sample data movx @DPTR,A ; copy sample data to 100h mov DPTR,#123h ; DPTR point to address 123h mov A,#15h ; sample data #15h movx @DPTR,A ; copy sample data to 123h mov DPTR,#100h ; start address to search mov R1,#100 ; loop 100 times from address 100h to 200h mov R0,#15h ; value need to find again: movx A,@DPTR ; fetch value that DPTR point to cjne A,0h,next ; compare content of A with R0 mov A,#1 ; if found sjmp found ; find the address next: inc DPTR ; not equal then loop next djnz R1,again ; count number of loops mov A,#0 ; not found sjmp notfound ; finish found: mov R6,DPl ; identify low byte of found external memory location mov R7,DPH ; identify high byte of found external memory location notfound:

Embedded System Design Lab Page - 16/21

Problem 12b: Binary Search Embedded System Design Lab Page - 17/21 mov A,#100 ; initial value mov R3,#101 mov DPTR,#100 loop: movx @DPTR,A ; initiate ;memory location from 100 ;to 200 values from 100-201 inc A inc DPTR djnz R3,loop ; repeat 101s mov R0,#123 ; find this value ; #7Bh(test value) mov DPTR,#100 mov R1,#100 ; each loop divide ; 2 and plus to DPTR mov B,#2 mov A,R1 div AB mov R1,A mov A,DPL add A,R1 mov DPL,A ; DPTR point to ; middle element mov A,DPH jnc next1 inc A mov DPH,A next1: movx A,@DPTR ; copy value ;of middle element to A clr C cjne A,0h,next2; compare ;with value #7Bh in R0 mov R6,DPL ; store LSB mov R7,DPH ; store MSB sjmp over ; equal finish next2: jnc left ; dest < source then CY=1 mov A,R1 ; DPTR move right mov B,#2 div AB jnz A_e_0 mov A,#1 A_e_0: mov R1,A mov A,DPL ; calculate ; position of middle element add A,R1 mov DPL,A mov A,DPH jnc next3 inc A mov DPH,A next3: sjmp next1 left: clr C ; DPTR move left mov A,R1 mov B,#2 div AB jnz A_e_02 A_e_02: mov A,#1 mov R1,A mov A,DPL ; calculate ; position of middle element subb A,R1 mov DPL,A mov A,DPH jnc next4 inc A mov DPH,A next4: sjmp next1 over:

Problem 13: Interrupt transmission Embedded System Design Lab Page - 2/21 Write a program for transmitting character using following method Interrupt Transmission When timer 1 interrupt occurs then increasing A and transmit it to P1 org 0 ljmp start org 001Bh inc A mov P1,A reti ; timer 1 interrupt vector table ; increment A ; copy A to P1 ; return from interrupt service routine org 40h start: mov TMOD,#20h ; timer 1, mode 2 (8-bit auto-reload) mov TH1,#0 ; initial value mov IE,#10001000b ; enable timer 1 setb TR1 again: sjmp again ; loop forever and wait timer 1 interrupt

Problem 14: Polling transmission Embedded System Design Lab Page - 3/21 Write a program for transmitting character using following method Polling Transmission mov TMOD,#01h ; timer 0, mode 1 (16-bit timer) repeat: mov TH0,#0 ; initial value mov TL0,#10 ; iniital value setb TR0 again: jnb TF0, again ; monitor timer flag 0 clr TR0 ; stop timer 0 clr TF0 ; clear timer flag 0 inc A ; increasing A mov P0,A ; copy A to port P0 sjmp repeat ; repeat forever

Problem 15: Serial Communication Embedded System Design Lab Page - 4/21 Write a program that takes the character in the A register, transmits it, delays for the transmission time, and then returns to the calling program with following specifications a. Timer 1 must be used to set the baud rate 2400 b. The delay for one 10-bit character is 1,000/240 or 4.16 milliseconds c. The timer 1 should generate baud rate at SBUF Assuming XTAL = 11.0592 MHz Machine cycle = 11.0592 MHz / 12 = 921.6 khz Cycle time = 1 / 921.6 khz = 1.085 µs UART frequency = 921.6 khz / 32 = 28800 Hz Use timer 1 mode 2 (8-bit auto-reload) To set baud rate 2400: 28800/2400 = 12 then assign TH1=#-12 Time delay for one 10-bit character is 4.16 ms (1000/240) 4160/1.805 = 3834 a. Timer 1 must be used to set the baud rate 2400 mov TMOD,#20h ; timer 1, mode 2 (8-bit auto-reload) mov TH1,#-12 ; baud rate 2400 setb TR1 ; start timer 1 mov SBUF,A ; copy content of A to SBUF for transmit wait: jnb TF1, wait ; monitor TF1 clr TR1 ; stop timer 1 clr TF1 ; clear timer flag 1 b. The delay for one 10-bit character is 1,000/240 or 4.16 milliseconds 65536 3834 = 61702 = F106h mov TMOD,#10 ; timer 1, mode 1 (16-bit timer) mov TH1,#0F1h ; initial high byte value mov TL1,#6h ; initial low byte value setb TR1 ; start timer 1 mov SBUF,A ; copy content of A to SBUF for transmit wait: jnb TF1,wait ; monotor TF1 clr TR1 clr TF1

Embedded System Design Lab Page - 5/21 Problem 16: Write a 8051 program to read data from port 1 and write to port 2 continuously while giving a copy of it to serial COM port to be transferred serially. Specification: i. Baud rate 9600/2400 ii. XTAL 11.0592 iii. write a single Interrupt routine for TI & RI org 0 ljmp start org 0023h ; interrupt vector table for serial ljmp serial org 30h ; by-pass interrupt vector table start: mov P1,#0FFh ; P1 becomes input port mov P1,#11001100B ; test value at P1 mov TMOD,#20h ; timer 1, mode 2 (auto-reload) mov TH1,#-3 ; set baud rate 9600 mov SCON, #192 ; serial mode 1, 8-bit, 1 start bit, 1 stop bit mov IE,#10010000B ; enable serial interrupt setb TR1 ; start timer 1 repeat: mov A,P1 ; copy P1 to A mov P2,A ; issue A to P2 mov SBUF,A ; serial transmit A to COM port cpl A ; complement A for testing mov P1,A ; assign new value for P1 sjmp repeat ; do it continuously serial:jnb TI,serial ; interrupt service routine clr TI ; clear TI reti