Please check if my code is good for interrupt

Status
Not open for further replies.

ernytony

Newbie level 6
Joined
Jun 30, 2005
Messages
12
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,376
iterrupt

this code is good for an interrupt???
#include <pic.h>
#include <delay.c>
#include <delay.h>
main(){
GIE=1; //--> enable global interrupt
T0IE=1; //--> enable l'interrupt sul tmr0
TRISD=0;
TRISB=0;
TRISC=0;
while(1){
PORTC=255;
}

}
void interrupt prv_int(void)
{
unsigned int i=1;
TRISB=0;
TRISD=0;
PORTD=0;
PORTB=0;

PORTD=1;

if(T0IF){

while(i<256){
PORTB=i;
i++;
}
T0IF=0; //Riabilita linterrupt flag
} //altrimenti non
} //vi saranno altri int TMR0
/*-------------------- EOF interrupt ----------------*/
 

iterrupt

You need to set up OPTION_REG to get your timer to work.

If you want the timer to increment every clock cycle you would set OPTION_REG = B'00001000' (assuming you're using a PIC16F87X).
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…