You are on page 1of 9

Display 7 Segmentos

Microcontroladores y microprogramacion Ing. Postigo

Lookup tables
Segment: A B C D E F G Pin: 0 1 2 3 4 5 6 7 8 9 RC5 on off on on off on on on on on RC4 on on on on on off off on on on RC3 on on off on on on on on on on RC2 on off on on off on on off on on RC1 on off on off off off on off on off RC0 on off off off on on on off on on RA2 off off on on on on on off on on

get7sC
addwf PCL,f

retlw retlw retlw retlw retlw retlw retlw retlw retlw retlw

b'111111' b'011000' b'110110' b'111100' b'011001' b'101101' b'101111' b'111000' b'111111' b'111101'

; 0 ; 1 ; 2 ; 3 ; 4 ; 5 ; 6 ; 7 ; 8 ; 9

movlw movwf movf call movwf

HIGH get7sC ; load high bits of table base address PCLATH ; into PCLATH digit,w get7sC PORTC ; get digit to display ; lookup pattern for port C ; then output it

(assuming that the digit to be displayed is stored in a variable called digit)

such as movwf or addwf, writes to PCL, the upper five bits of the program counter is loaded from all five PCLATH bits: PCLATH<4:0> is copied to PC<12:8> if PCLATH is pointing to some other part of memory, your code will jump there, and not into your table, when you update PCL

Para programas que exeden los 256 bytes


movlw movwf HIGH (get7sC+1) PCLATH ; load PCLATH with base of table

movlw addwf

LOW (get7sC+1) digit,w

add offset of digit to display

btfsc incf call movwf

STATUS,C PCLATH,f get7sC PORTC

; ; ; ;

if overflow increment PCLATH lookup pattern for port C then output it

;***** MACROS ; Perform table lookup ; ; parameters: table = address of table base ('movwf PCL' instruction) ; off_var = 8-bit variable holding offset into table ; (assumes correct bank already selected) ; ; Table entry at given offset is returned in W ; (first entry is at offset 0) ; Lookup MACRO table,off_var movlw HIGH (table+1) ; load PCLATH with base of table movwf PCLATH movlw LOW (table+1) ; add offset to base addwf off_var,w btfsc STATUS,C ; if overflow incf PCLATH,f ; increment PCLATH call table ; perform table lookup ENDM

This macro assumes that the table offset is stored in a variable, which will normally be the case, as in this example, where we are using the digit variable.

DISPLAY MULTIPLEXER

PIC 16F676

You might also like