› ... › pdf › ece375_lab4_ppt.pdf · ece375 lab 42019-10-23 · 10/23/2019 1 ece375 lab 4 ta:...

Post on 25-Feb-2020

3 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

10/23/2019

1

ECE375 Lab 4

TA: Youngbin JinSchool of Electrical Engineering and Computer ScienceOregon State University

Demo and Plagiarism

Show your demo.◦ Even your demo does not run successfully,

show your code and demo in order to get partial credit.

Do not copy other’s code.◦ It is never okay to represent another person's

work as your own.

10/23/2019

2

Data Manipulation & LCD

Data Manipulation◦ Program memory <-> Register◦ Data memory <-> Register◦ Program memory <-> Data Memory

Display LCD◦ LCD driver is provided

AVR Microarchitecture

10/23/2019

3

Data Memory to Register

$D1$D2$D3$D4$D5$D6$D7

$0100$0101$0102$0103$0104$0105$0106

$16$17$18$19

R16R17R18R19

8 Bit

8 Bit

Data Memory to Register

$D1$D2$D3$D4$D5$D6$D7

$0100$0101$0102$0103$0104$0105$0106

$16$17$18$19

R16R17R18R19

8 Bit

8 Bit

Y

ldiYL, $00ldiYH, $01

10/23/2019

4

Data Memory to Register

$D1$D2$D3$D4$D5$D6$D7

$0100$0101$0102$0103$0104$0105$0106

$16$17$18$19

R16R17R18R19

ldiYL, $00ldiYH, $01Ld r16, Y+

$D1$D1Y

8 Bit

8 Bit

Y+

Data Memory to Register

$D1$D2$D3$D4$D5$D6$D7

$0100$0101$0102$0103$0104$0105$0106

$16$17$18$19

R16R17R18R19

ldiYL, $00ldiYH, $01Ld r16, Y+stY, r17

$D1$17

$D1Y

8 Bit

8 Bit

10/23/2019

5

Program Memory to Register

$A1$A3$A5$A7$A9$AB$AD

$0100$0200$0201$0202$0203$0204$0205

$00$01$16$17

R0R1R16R17

$A2$A4$A6$A8$AA$AC$AE

Z??

ldi ZL, $00ldi ZH, $02

16 Bit 8 Bit

Program Memory(16 bits) ≠ Register (8bits)Cannot move directly

Program Memory to Register

$A1$A3$A5$A7$A9$AB$AD

$0100$0200$0201$0202$0203$0204$0205

$00$01$16$17

R0R1R16R17

$A2$A4$A6$A8$AA$AC$AE

16 Bit 8 Bit

Z= 0b0000001000000000

0 2 0 0ZH ZL

ldi ZL, $00ldi ZH, $02

10/23/2019

6

Program Memory to Register

$A1$A3$A5$A7$A9$AB$AD

$0100$0200$0201$0202$0203$0204$0205

$00$01$16$17

R0R1R16R17

$A2$A4$A6$A8$AA$AC$AE

16 Bit 8 Bit

Z= 0b0000001000000000

0 1 0 0

high/low

Z

ldi ZL, $00ldi ZH, $02

Program Memory to Register

$A1$A3$A5$A7$A9$AB$AD

$0100$0200$0201$0202$0203$0204$0205

$00$01$16$17

R0R1R16R17

$A2$A4$A6$A8$AA$AC$AE

16 Bit 8 Bit

Z= 0b0000001000000001

0 1 0 0

high/low

Z

ldi ZL, $00ldi ZH, $02

10/23/2019

7

Program Memory to Register

$A1$A3$A5$A7$A9$AB$AD

$0100$0200$0201$0202$0203$0204$0205

$A2$A4$A6$A8$AA$AC$AE

16 Bit

Zldi ZL, $00ldi ZH, $02

ldi ZL, ($00<<1)ldi ZH, ($02<<1)

or

ldi ZL, $00ldi ZH, $04

Program Memory to Register

$A1$A3$A5$A7$A9$AB$AD

$0100$0200$0201$0202$0203$0204$0205

$A2$A4$A6$A8$AA$AC$AE

16 Bit

Z$00$01$16$17

R0R1R16R17

8 Bit

ldi ZL, $00 <<1ldi ZH, $02 <<1lpm r16, z+lpm r17, z+spm z+

10/23/2019

8

Program Memory to Register

$A1$A3$A5$A7$A9$AB$AD

$0100$0200$0201$0202$0203$0204$0205

$A2$A4$A6$A8$AA$AC$AE

16 Bit

Z$00$01$16$17

R0R1R16R17

8 Bit

ldi ZL, $00<<1ldi ZH, $02<<1lpm r16, z+lpm r17, z+spm z+

$A3

Program Memory to Register

$A1$A3$A5$A7$A9$AB$AD

$0100$0200$0201$0202$0203$0204$0205

$A2$A4$A6$A8$AA$AC$AE

16 Bit

Z+$00$01$16$17

R0R1R16R17

8 Bit

ldi ZL, $00<<1ldi ZH, $02<<1lpm r16, z+lpm r17, z+spm z+

$A3

10/23/2019

9

Program Memory to Register

$A1$A3$A5$A7$A9$AB$AD

$0100$0200$0201$0202$0203$0204$0205

$A2$A4$A6$A8$AA$AC$AE

16 Bit

Z$00$01$A3$17

R0R1R16R17

8 Bit

ldi ZL, $00<<1ldi ZH, $02<<1lpm r16, z+lpm r17, z+spm z+

$A4

Program Memory to Register

$A1$A3$A5$A7$A9$AB$AD

$0100$0200$0201$0202$0203$0204$0205

$A2$A4$A6$A8$AA$AC$AE

16 Bit

$00$01$A3$17

R0R1R16R17

8 Bit

ldi ZL, $00<<1ldi ZH, $02<<1lpm r16, z+lpm r17, z+spm z+

$A4Z+

10/23/2019

10

Program Memory to Data Memory

$AA$CC$EE

$0200$0201$0202

$16$17$18$19

R16R17R18R19

$BB$DD$FF

$D1$D2$D3$D4

$0100$0101$0102$0103

ldiYL, $00ldiYH, $01

Y

Program Memory to Data Memory

$AA$CC$EE

$0200$0201$0202

$16$17$18$19

R16R17R18R19

$BB$DD$FF

$D1$D2$D3$D4

$0100$0101$0102$0103

ldiYL, $00ldiYH, $01ldi ZL,$02<<1ldi ZH, $02<<1

YZ

10/23/2019

11

Program Memory to Data Memory

$AA$CC$EE

$0200$0201$0202

$16$17$18$19

R16R17R18R19

$BB$DD$FF

$D1$D2$D3$D4

$0100$0101$0102$0103

ldiYL, $00ldiYH, $01ldi ZL,$02<<1ldi ZH, $02<<1lpm r16, Z

YZ

$EE

Program Memory to Data Memory

$AA$CC$EE

$0200$0201$0202

$16$17$18$19

R16R17R18R19

$BB$DD$FF

$D1$D2$D3$D4

$0100$0101$0102$0103

ldiYL, $00ldiYH, $01ldi ZL,$02<<1ldi ZH, $02<<1lpm r16, ZstY, r16

YZ

$EE

$EE

10/23/2019

12

Display LCD LCD driver provided◦ Add LCD driver in your main asm file.

LCDWrite◦ Display 1st line : $0100 - $010F ◦ Display 2nd line : $0110 - $011F

Store Data in Program Memory◦ DO NOT make redundant data EX) .DB “Youngbin Jin Dongjun Lee ”

.DB “Dongjun Lee Youngbin Jin ” Use pointer properly

Move to Data Memory $0100-$011F before rcall LCDWritefunction

Demo

Button 0 (PD0)◦ Youngbin Jin (1st String)◦ Dongjun Lee (2nd String)

Button 1 (PD1)◦ Dongjun Lee (2nd String)◦ Youngbin Jin (1st String)

Button 7 (PD7)◦ Clear

10/23/2019

13

Checklist for Lab 4 Demo Checklist ◦ Strings displayed on both lines of LCD?◦ Strings are controlled by PD0, PD1, and PD7?◦ No garbage/uninitialized characters?◦ Strings declared in ProgMem using .DB?◦ Strings copied to DataMem using a loop?◦ Sufficient explanation of <<1 for LPM?

Challenge Checklist◦ Strings scroll from line 1 to line 2?◦ Strings scroll can be controlled by PD5 and PD6?◦ Reasonable scrolling interval (~0.25 sec)?

Questions?

top related