1 / 9

Embedded Systems 7763B

Embedded Systems 7763B. Mt Druitt College of TAFE Electrical Engineering Lesson 3 Declaring variables in memory for storing data. Assignment 1b new spec. Using EQU ate. Used to declare a variable and allocate defined memory location

mura
Download Presentation

Embedded Systems 7763B

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. Embedded Systems7763B Mt Druitt College of TAFE Electrical Engineering Lesson 3Declaring variables in memory for storing data

  2. Assignment 1b new spec. Mike Stacey 2008

  3. Using EQUate • Used to declare a variable and allocate defined memory location • .equ pin_1 = 0x0060 ; assigns data space address 0060 to variable named pin_1. • Use .equ to assign memory space for the pin numbers in assignment 3. Mike Stacey 2008

  4. GetPin Subroutine ; Assign data space ; address to variables.equ pin1 = 0x0060.equ pin2 = 0x0061.equ pin3 = 0x0062.equ pin4 = 0x0063 • You can then access this data using load and store instructions: • LDS ; load direct from data space. Loads 1 byte from data space to register in uC. • STS ; store direct to data space. Stores 1 byte from register in uC to data space • See DEMO of GetPin in class Mike Stacey 2008

  5. Code example [1] ; Store PIN ldi pin_holder, '9' sts pin1, pin_holder ldi pin_holder, '1' sts pin2, pin_holder ldi pin_holder, '5' sts pin3, pin_holder ldi pin_holder, '6' sts pin4, pin_holder GetPin: rcall displayReady ldi pin_holder, $00 lds pin_holder, pin1 rcall GetKey cp pin_holder, k1 brne DisplayError lds pin_holder, pin2 rcall GetKey cp pin_holder, k1 brne DisplayError lds pin_holder, pin3 rcall GetKey cp pin_holder, k1 brne DisplayError lds pin_holder, pin4 rcall GetKey cp pin_holder, k1 brne DisplayError Mike Stacey 2008

  6. Code example [2] DisplayOK: ldi temp, $55 out PortA, temp rjmp Clear DisplayError: ldi temp, $66 out PortA, temp rjmp Clear DisplayReady: ldi temp, $AA out PortA, temp ret Clear: rcall GetKey cpi k1, 'C' brne Clear rjmp GetPin Mike Stacey 2008

  7. Addition to ‘GetKey’ • You need to add a bit of code that will only allow GetKey to return after the key pressed has been released Mike Stacey 2008

  8. Code example [1] GetKey: ldi k1,$00 rcall keyscan cpi keyval,$ff breq GetKey mov k1,keyval rcall delay rcall keyscan cp k1,keyval brne GetKey ;// Only return from GetKey ;// when the key has been ;//released Release: rcall keyscan cpi keyval,$ff brne release ;/// Key pressed is ;/// in 'k1' ret Mike Stacey 2008

  9. GetKey • See web for new version Mike Stacey 2008

More Related