I hae managed to get that working with the include file, scrapped the template and used the demo that came with my programmer. Tell me, if i wanted to use my PIC to drive an L.E.D. matrix, how exactly would I change the assignment of inputs and outputs to reference the 10 outputs i require and 4 inputs?
I have this code file so far.
[code];**************************************************************************
list p=16f627
#include <p16f627.inc>
__CONFIG _BODEN_ON & _CP_OFF & _DATA_CP_OFF & _PWRTE_ON & _WDT_OFF & _LVP_OFF & _MCLRE_ON & _XT_OSC
;==========================================================================
; Variable Definition
;==========================================================================
;INPUTS
SW1 EQU H’00’ ;SW1 is triggering RA0
SW2 EQU H’01’ ;SW2 is triggering RA1
SW3 EQU H’02’ ;SW3 is triggering RA2
SW4 EQU H’03’ ;SW4 is triggering RA3
TIMER1 EQU H’20’ ;Used in delay routine
TIMER2 EQU H’21’ ; " " "
PATERN EQU H’22’ ;Pattern data for effect’s
ORG 0 ;Reset vector address
GOTO RESET ;goto RESET routine when boot.
; *********************************************
; * Delay routine *
; *********************************************
DELAY_ROUTINE MOVLW D’100’ ;54 Generate approx 10mS delay at 4Mhz CLK
MOVWF TIMER2
DEL_LOOP1 MOVLW D’100’ ;60
MOVWF TIMER1
DEL_LOOP2 BTFSC PORTA,SW1
GOTO MENU
BTFSC PORTA,SW2
GOTO MENU
BTFSC PORTA,SW3
GOTO MENU
BTFSC PORTA,SW4
GOTO MENU
DECFSZ TIMER1,F
GOTO DEL_LOOP2
DECFSZ TIMER2,F
GOTO DEL_LOOP1
RETLW 0
; **********************************
; ** RESET : main boot routine **
; **********************************
RESET MOVLW B’00000111’ ;Disable Comparator module’s
MOVWF CMCON
;
BSF STATUS,RP0 ;Switch to register bank 1
;Disable pull-ups
;INT on rising edge
;TMR0 to CLKOUT
;TMR0 Incr low2high trans.
;Prescaler assign to Timer0
;Prescaler rate is 1:256
MOVLW B’11010111’ ;Set PIC options (See datasheet).
MOVWF OPTION_REG ;Write the OPTION register.
;
CLRF INTCON ;Disable interrupts
MOVLW B’11000000’
MOVWF TRISB ;RB7 & RB6 are inputs.
;RB5…RB0 are outputs.
MOVLW B’11111111’ ;all RA ports are inputs
MOVWF TRISA
BCF STATUS,RP0 ;Switch Back to reg. Bank 0
CLRF PORTB
GOTO EFFECT_4
;
MENU CLRF PORTB
;
BTFSC PORTA,SW1
GOTO EFFECT_1
BTFSC PORTA,SW2
GOTO EFFECT_2
BTFSC PORTA,SW3
GOTO EFFECT_3
BTFSC PORTA,SW4
GOTO EFFECT_4
GOTO MENU
EFFECT_1 BTFSC PORTA,SW1
GOTO EFFECT_1
E1 ; effect 1 here
GOTO E1
EFFECT_2 BTFSC PORTA,SW2
GOTO EFFECT_2
E2 ; effect 2 here
GOTO E2
EFFECT_3 BTFSC PORTA,SW3
GOTO EFFECT_3
E3 ; effect 3 here
GOTO E3
EFFECT_4 BTFSC PORTA,SW4
GOTO EFFECT_4
E4 ; effect 4 here
GOTO E4
END[/code]
If I changed this so that it would output 4 effects to an L.E.D. matrix, of 5 x 5 i would need 10 outputs, what additional circuitry would I need with the PIC? Do I need an external oscillator or any other components or can I just power up the PIC and have it drive the L.E.D’s with no additional circuitry? (Other than the necessary resistors of course). Could someone also explain the whole “reset” of this thing to me? I tried copying eerything except the reset process into the template and it would not work.
Thanks