aLec24_arrays_math

aLec24_arrays_math - Introduction to Embedded Microcomputer...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Introduction to Embedded Microcomputer Systems Lecture 24.1 Jonathan W. Valvano Recap I/O synchronization Interrupts Output compare periodic interrupts Overview Arrays, Table lookup Extended math Proper ways to acknowledge (software makes C3F zero) ldaa #$08 staa TFLG1 movb #$08,TFLG1 TFLG1 = 0x08; These attempts have no effect on TFLG1 ldaa #$00 staa TFLG1 clr TFLG1 TFLG1 = 0; These attempts clear all bits C7F, C6F… C0F in TFLG1 bset TFLG1,#$08 movb #$FF,TFLG1 TFLG1 |= 0x08; TFLG1 = 0xFF; Multiply instructions mul unsigned A*B into D emul unsigned D*Y into 32-bit Y:D emuls signed D*RegY into RegY:D Divide instructions idiv unsigned D/X into X, D remainder idivs signed D/X into X, D remainder fdiv unsigned (D:0)/X into X, D remainder ediv unsigned (Y:D)/X into Y, D remainder edivs signed (Y:D)/X into Y, D remainder Example Count (0 to 199) = 9 5 ×Angle(0 to 359) * Count =(5*Angle)/9 ldd Angle ldy #5 emul ;(Y:D)= 5*Angle ldx #9 ediv ;Y=(5*Angle)/9 sty Count Example Angle (0 to 359) = 5 9 ×Count(0 to 199) * Angle =(9*Count)/5 (65536*Count)/36409 ldd Count ldx #36409 fdiv stx Angle
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Introduction to Embedded Microcomputer Systems Lecture 24.2 Jonathan W. Valvano Example Column (0 to 6) = 7 256 × Xpos (0 to 255) * Column =(7*Xpos)/256 ldaa Xpos ldab #7 mul ;RegD=7*Xpos staa Column ;RegA=(7*Xpos)/256 Unsigned 8 to 16-bit promotion instructions ; to promote RegB into RegD clra ; to promote RegA into RegX tfr A,B clra tfr D,X Signed 8 to 16-bit promotion instructions sex A,D (same instruction as tfr A,D ) sex B,D (same instruction as tfr B,D ) sex A,X (same instruction as tfr A,X ) sex B,X (same instruction as tfr B,X ) sex A,Y (same instruction as tfr A,Y ) sex B,Y (same instruction as tfr B,Y ) 16 to 8-bit demotion instructions (signed or unsigned) tfr D,A tfr D,B tfr X,A tfr X,B tfr Y,A tfr Y,B Example Column (0 to 6) = 7 256 × Xpos (0 to 255) * Column =(7*Xpos)/256 ldab Xpos clra ;promote ldy #7 emul ;(Y:D)=Y*D ldx #256 ediv ;(Y:D)/X into Y, D remainder tfr Y,A ;demote staa Column Arrays Used to store data of the same type. All elements are the same size and are stored together I be the row index (starts with 0), n be the number of bytes for each element Base is the base address of the array then the address of the element at A[I] is Base+n*I Convert ADC data into integer part of fixed point 1) Equation 2) Little table and interpolation 3) Big table and explicit table lookup Temperature versus ADC T = -1.9768n + 3971.1 1000 1500 2000 2500 3000 3500 4000 4500 0 128 256 384 512 640 768 896 1024 ADC, n T (0.01 ˚ C)
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 09/19/2010 for the course E E 16280 taught by Professor Valvano during the Fall '10 term at University of Texas.

Page1 / 5

aLec24_arrays_math - Introduction to Embedded Microcomputer...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online