I'm trying to get 3 int's working but 'm having trouble.
Hardware: EasyPic2 8MHz
Using 4 buttons on PORTB<7:4> under interrupt
2 Buttons (PORTB.0 & 1) to simulate interrupt on INT0, INT1
GLCD to monitor some states.
I can't publish the whole source because it is approx. 30kB
Following are the most important parts:
<initial setup>
Code: Select all
{===================================================================}
{INTCON2 : %01100001 >> $61
: 0 = RBIP RB PORT CHANGE
: 1 = -
: 2 = TMR0IP TMR0 OVERFLOW
: 3 = -
: 4 = INTEDGE2 1=RISING/0=FALLING EDGE
: 5 = INTEDGE1 1=RISING/0=FALLING EDGE
: 6 = INTEDGE0 1=RISING/0=FALLING EDGE
: 7 = RBPU 1=PORTB PULLUP ENABLED, 0= DISABLED
}
intcon2 := $61; //rising edge on INT0/INT1
{INTCON3 : %01001000 >> $48
: 0 = INT1IF 1=INT OCCURRED
: 1 = INT2IF
: 2 = -
: 3 = INT1IE 1=INT1 ENABLED
: 4 = INT2IE 1=INT2 ENABLED
: 5 = -
: 6 = INT1IP 1=HIGH PRIORITY
: 7 = INT2IP
}
intcon3 := $48; //enable INT1 high prio
//delay_ms(5000);
{INTCON : %11011000 >> $D8
: 0 = RBIF PORTB<7:4> STATE CHANGE
: 1 = INT0IF INT OCCURRED
: 2 = TMR0IF TMR0 OVERFLOW OCCURRED
: 3 = RBIE 1=PORTB CHANGE ENABLED
: 4 = INT0IE 1=INT0 ENABLED
: 5 = TMR0IE 1=TMR0 OVERFLOW INT ENABLED
: 6 = PEIE/GIEL 1=HIGH PRIORITY
: 7 = GIE/GIEH 1=GLOBAL INT'S ENABLED
}
intcon := $D8; //enable RBIE & INT0
{======================================================================}
Code: Select all
procedure interrupt;
begin
// intcon := $0F;
if TestBit(INTCON,RBIF) <> 0 then // test if RBIF is set
begin
delay_us(1000); // wait 5 mS
new_portb:=portb and $F0;
intcon:=$D8; // enable global int &int0,rbie
end
else
if TestBit(INTCON,INT0IF) <> 0 then // test if INT0IE is set
begin
clearbit(intcon,7); // disable global int
TMR1H := $00;
TMR1L := $00;
int0_t:=true;
clearbit(intcon,INT0IF); // clear INT0IF
setbit(INTCON,INT0IE);
setbit(T1CON,1); //START timer1
setbit(portc,5);
setbit(intcon,7); // enable global int
end
else
if TestBit(INTCON3,INT1IF) <> 0 then // test if INT1IE is set
begin
clearbit(intcon,7); // disable global int
clearbit(portc,5);
clearbit(T1CON,0); // stop timer1
clearbit(intcon3,INT1IF); // clear INT1IF
setbit(INTCON3,INT1IE);
setbit(intcon,7); // enable global int
end;
end;
working, sometimes they don't.
I switched PIC's w/out any results.
I'm done (for now).....