I need help with interrupts, I know that they pause the executing of main program and execute the code under the interrupt function. I was trying to flash a led on PORTB = 0x80 the RB7 bit. And it didn't work here's the code:
Code: Select all
void main()
{
INTCON.GIE = 1; //Ukljuci sve Interrupte
INTCON.INTE = 1; //Ukljuci RB0/INT interrupt
OPTION_REG.INTEDG = 1; //interrupt on rising edge of RB0/INT pin.
TRISA = 0xFF;
PORTA = 0x00;
PORTB = 0x00;
TRISB = 0b00000001; //Binarno znaci da samo RB0 bude ulazni port
while(1)
{
PORTB = 0x02; //Ukljuci diodu na RB1
}
}
void interrupt()
{
INTCON.GIE = 0; //Iskljuci sve prekide (interrupte)
PORTB = 0x80; //Ukljuci led diodu na RB7
Delay_ms(2000);
INTCON.INTF = 0; //Ocisti RB0 Interupt flag
INTCON.GIE = 1; //Ukljuci sve prekide (interrupte)
}
I'm 100% sure that the scheme works. I think I don't know how to use the interrupts. So please correct my error here!
Thanks in advance!