Had a few extra minutes and rewrote the code - I think it should work - I don't have any 16F676's to try it on.
(yer way ahead of me... my brain died off around 5 or so)...
Code:@ DEVICE PIC16F676,INTRC_OSC_NOCLKOUT,WDT_ON,PWRT_OFF,BOD_OFF,PROTECT_OFF,CPD_OFF,MCLR_OFF LED var PORTA.0 BlinkCount var byte CounterA var byte OLDPORTA VAR byte NEWPORTA VAR byte ; DISABLE ANALOG INPUT, COMPARATOR ON PORTA, A/D reference... ANSEL = 0 : CMCON = 7 : VRCON = 0 TRISA = %00111110 ; PortA In/Out states WPUA = %00000110 INTCON = %10000000 : IOCA = %00111000 : OPTION_REG = %00001000 LED = 0 : PAUSE 1000 : LED = 1 GOTO BASE ; ; SUBROUTINES MYINT: NEWPORTA = PORTA ; read current PortA state INTCON = %10000000 ; IF NEWPORTA.5 <> OLDPORTA.5 THEN BlinkCount = 3 ; Set up for 4 blinks ENDIF ; IF NEWPORTA.4 <> OLDPORTA.4 THEN BlinkCount = 2 ; Set up for 3 blinks ENDIF ; IF NEWPORTA.3 <> OLDPORTA.3 THEN BlinkCount = 1 ; Set up for 2 blinks ENDIF ; for CounterA = 0 to BlinkCount LED = 0 : PAUSE 1000 : LED = 1 : PAUSE 1000 next CounterA RESUME Base ; The above section could have an error trap in case none of the IF's are true for some reason. ; A "Select Case" might use less code space. ; ; Start main program loop here ; BASE: BlinkCount=0 : OLDPORTA = PORTA ; ON INTERRUPT GOTO MYINT INTCON = %10001000 ; LOOP: SLEEP 240 : GOTO LOOP end
Arch




Bookmarks