hi i used the code form this page and adapted it, thank you,
it uses all 8 bits of portb and 2 bits of portc, the 2 bits of port c are used to multiplex 2 sets of 8 leds, so ya get 16 outputs. 3 shown here. what i want to know how could i impliment a lookup table for setting the data in port b and port c. i have shown 3 patterns in this code , but has 16, long code.
please help driving me nuts, thought it may also help others who got to this section
list P=PIC16F870 ; Tells MPASM the target processor
include "p16f870.inc"
__config _XT_OSC & _WDT_ON & _PWRTE_ON & _BODEN_ON & _LVP_OFF & _CPD_ON & _CP_OFF & _DEBUG_OFF & _WRT_ENABLE_OFF
; Tells MPASM our Configuration Fuse Definitions
;
STATUS EQU 3h ;Define lable STATUS to 3
PORTB EQU 6h ;Define lable PORTB to 6 (Bank 0)
TRISB EQU 86h ;Define lable TRISB to 6 (Bank 1)
PORTC EQU 7h ;Define lable PORTB to 6 (Bank 0)
TRISC EQU 87h ;Define lable TRISB to 6 (Bank 1)
;
COUNT_a EQU 20h ;Define lable COUNT_1 to RAM adress 20h
COUNT_b EQU 21h ;Define lable COUNT_2 to RAM adress 21h
DELAY EQU 22H
;
STARTADR: ORG 000h ;Point to adress 000h which is the start adress
GOTO START ;Jump over the fist adresses and to START
;
ORG 010h ;Point to adress 010h.
START: MOVLW b'00100000' ;Load W register so bank 1 will be set (see statusreg in datasheets)
MOVWF STATUS ;Move W into STATUS and now Bank 1 will be selected
MOVLW b'00000000' ;Load W with data direction for TRISB 1=input 0=output (binary for lights)
MOVWF TRISB ;Move W into TRISB and RB0 will be an output(all outputs hehe =00000000)
;extra bits i added for setting trisc
MOVLW b'11001111' ;Load W with data direction for TRISC 1=input 0=output (binary for lights)rc4 and rc5 as outputs
MOVWF TRISC ;Move W into TRISC and RB0 will be an output(all outputs hehe =00000000)
;
MOVLW b'00000000' ;Load W register so bank 0 will be set (see statusreg in datasheets)
MOVWF STATUS ;Move W into STATUS and now Bank 0 will be selected
;
BACK:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;1st set led is 10000000 00000000
;port b is the pattern and port c is the bank
;
MOVLW b'00000001' ;load pattern into W
CALL ledbankleft ;load pattern into portb and select right led bank, ie port rc04
MOVLW b'00000000' ;
CALL ledbankright ; select right led bank, ie port rc05
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;
;2nd set led is 110000000 00000000
MOVLW b'00000011' ;
CALL ledbankleft
MOVLW b'00000000' ;
CALL ledbankright
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;
;3nd set led is 11100000 00000000
MOVLW b'00000111' ;
CALL ledbankleft
MOVLW b'00000000' ;
CALL ledbankright
GOTO BACK
loop:
MOVLW 07fh ;Load W with Loop time
; MOVLW DELAY
MOVWF COUNT_a ;Move W to RAM adress
;
NEXT_a: MOVLW 07fh ;Load W with Loop time
MOVWF COUNT_b ;Move W to RAM adress
NEXT_b: DECFSZ COUNT_b,F ;Decrease COUNT_2 and execute next instruction if result not zero.
GOTO NEXT_b ;
;
DECFSZ COUNT_a,F ;Decrease COUNT_1 and execute next instruction if result not zero.
GOTO NEXT_a ;
;2ndloop
MOVLW 07fh ;Load W with Loop time
MOVWF COUNT_a ;Move W to RAM adress
NEXT_c: MOVLW 07fh ;Load W with Loop time
MOVWF COUNT_b ;Move W to RAM adress
NEXT_d: DECFSZ COUNT_b,F ;Decrease COUNT_2 and execute next instruction if result not zero.
GOTO NEXT_d ;
;
DECFSZ COUNT_a,F ;Decrease COUNT_1 and execute next instruction if result not zero.
GOTO NEXT_c ;
RETURN
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;
ledbankright: MOVWF PORTB
MOVLW b'00100000' ;select led bank 1
MOVWF PORTC ;Move W to port B and now RC5 will go Hi.
CALL loop
RETURN
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;
ledbankleft: MOVWF PORTB
MOVLW b'00010000' ;select led bank 1
MOVWF PORTC ;Move W to port B and now RC5 will go Hi.
RETURN
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;
END
Bookmarks