tvojmuc
Newbie level 4
OK..I'm beginner so please be gently
How to use interrupt:
I have 16f887 PIC
BCD decoder on D0,1,2,3 and 4 led on B0,1,2,3
With interrupt routine I would like to read BCD code and then turn on LED
my code: -> and is not working
How to use interrupt:
I have 16f887 PIC
BCD decoder on D0,1,2,3 and 4 led on B0,1,2,3
With interrupt routine I would like to read BCD code and then turn on LED
my code: -> and is not working
Code:
program LIGHT
dim pre as byte
sub procedure interrupt ' Interrupt routine
'PORTE.0 = 1 'just to see int
'delay_ms(500)
pre = PORTD
'PORTE.0 = 0 'just to see int
'delay_ms(500)
TMR0 = 155 ' Timer0 (or counter) returns its initial value
INTCON = 0x20 ' Bit T0IE is set, bit T0IF is cleared
end sub
main:
OPTION_REG = 0x04 ' Prescaler (1:32) is assigned to Timer0
TMR0 = 155 ' Timer0 counts from 155 to 255
INTCON = 0xA0 ' Enable interrupt on TMR0 overflow
TRISB = %00000000 'output = 0
TRISD = %11111111 'input = 1
TRISE.0 = 0 'output = 0
TRISE.1 = 0 'output = 0
zacetek:
PORTE.1 = 1 'just to see progress
delay_ms(500)
select case pre
case 0
PORTB = 1
case 1
PORTB = 2
case 2
PORTB = 4
case 3
PORTB =8
end select
PORTE.1 = 0 'just to see progress
delay_ms(500)
goto zacetek
end.