I need help on my pic program, the program goes like this the combination of LED to be turned ON depends on the input from serin but I want to put an interrupt so that when the interrupt is enabled all LED would be turned on..., I couldn't make it work is it possible that there is some conflict on the serin with interrupt?
Im planning to let the pic read first the last input that when there would be black out it would still retain it's last input , thats why the program is written that way. my problem is interrupt, I want it that if there is voltage in Rb0 all the LED would be high please help me.
this is the code:
@ DEVICE pic16F628A,INTOSC_OSC_NOCLKOUT
@ DEVICE pic16F628A,WDT_OFF
@ DEVICE pic16F628A,CPD_OFF
@ DEVICE PIC16F628A,PROTECT_OFF
@ DEVICE PIC16F628A,BOD_OFF
@ DEVICE PIC16F628A,LVP_OFF
@ DEVICE PIC16F628A,MCLR_OFF
TRISB = %00000011
TRISA = %00000000
CMCON=7
Include "modedefs.bas"
MARCUS VAR BYTE
B0 VAR BYTE
LED VAR PORTB.3
TRUE CON 1
FALSE CON 0
LOW PORTB.3
LOW PORTB.4
LOW PORTB.5
LOW PORTB.6
OPTION_REG = %00111111
On Interrupt Goto myint ' Define interrupt handler
INTCON = %10010000
START
SERIN PORTB.1,2,["U"],MARCUS
SEROUT PORTB.2,2,["ERROR",10,13]
IF MARCUS.0=TRUE THEN
HIGH PORTB.3
ELSE
LOW PORTB.3
ENDIF
IF MARCUS.1=TRUE THEN
HIGH PORTB.4
ELSE
LOW PORTB.4
ENDIF
IF MARCUS.2=TRUE THEN
HIGH PORTB.5
ELSE
LOW PORTB.5
ENDIF
IF MARCUS.3=TRUE THEN
HIGH PORTB.6
ELSE
LOW PORTB.6
ENDIF
GOTO START
Disable 'No interrupts past this point
myint:
PORTB.3 = FALSE
PORTB.4 = TRUE
PORTB.5 = TRUE
PORTB.6 = TRUE
pause 500
INTCON.1 = 0 ' Clear interrupt flag
Resume ' Return to main program
Enable
Im planning to let the pic read first the last input that when there would be black out it would still retain it's last input , thats why the program is written that way. my problem is interrupt, I want it that if there is voltage in Rb0 all the LED would be high please help me.
this is the code:
@ DEVICE pic16F628A,INTOSC_OSC_NOCLKOUT
@ DEVICE pic16F628A,WDT_OFF
@ DEVICE pic16F628A,CPD_OFF
@ DEVICE PIC16F628A,PROTECT_OFF
@ DEVICE PIC16F628A,BOD_OFF
@ DEVICE PIC16F628A,LVP_OFF
@ DEVICE PIC16F628A,MCLR_OFF
TRISB = %00000011
TRISA = %00000000
CMCON=7
Include "modedefs.bas"
MARCUS VAR BYTE
B0 VAR BYTE
LED VAR PORTB.3
TRUE CON 1
FALSE CON 0
LOW PORTB.3
LOW PORTB.4
LOW PORTB.5
LOW PORTB.6
OPTION_REG = %00111111
On Interrupt Goto myint ' Define interrupt handler
INTCON = %10010000
START
SERIN PORTB.1,2,["U"],MARCUS
SEROUT PORTB.2,2,["ERROR",10,13]
IF MARCUS.0=TRUE THEN
HIGH PORTB.3
ELSE
LOW PORTB.3
ENDIF
IF MARCUS.1=TRUE THEN
HIGH PORTB.4
ELSE
LOW PORTB.4
ENDIF
IF MARCUS.2=TRUE THEN
HIGH PORTB.5
ELSE
LOW PORTB.5
ENDIF
IF MARCUS.3=TRUE THEN
HIGH PORTB.6
ELSE
LOW PORTB.6
ENDIF
GOTO START
Disable 'No interrupts past this point
myint:
PORTB.3 = FALSE
PORTB.4 = TRUE
PORTB.5 = TRUE
PORTB.6 = TRUE
pause 500
INTCON.1 = 0 ' Clear interrupt flag
Resume ' Return to main program
Enable
Last edited: