Ranbeer Singh
Full Member level 5
- Joined
- Jul 30, 2015
- Messages
- 259
- Helped
- 22
- Reputation
- 44
- Reaction score
- 22
- Trophy points
- 1,298
- Location
- Faridabad India
- Activity points
- 3,266
// High priority interrupt vector
#pragma code isr = 0x08 // store the below code at address 0x08
#pragma interrupt isr
void isr()
{
// function statements
if(INTCONbits.INT0IF)
{
RPM++;
PORTBbits.RB2=1;
INTCONbits.INT0IF = 0;
}
}
#pragma code
void main()
{
TRISA=0xFF;
TRISC=0x00;
PORTC=0x00;
TRISB=0x01;
T0CON=0x06;
PR2=220; // Puse width OnTime in Micro Second = PR2+1/prescaler(16)/Postscaler(16)
CCPR2L=0; // OnTime from AN0 pin.
ADCON0=0x01; // Use AN0 for analogic input
ADCON1=0x0D;
ADCON2=0xAE;
// interrupts / USART interrupts configuration
RCONbits.IPEN = 0; // disable interrupt priority
INTCONbits.GIE = 1; // enable interrupts
INTCONbits.PEIE = 1; // enable peripheral interrupts.
INTCONbits.INT0IE=1;
INTCONbits.INT0IF=0;
INTCON2bits.INTEDG0=1;
}
Interupt is Hardware flags, when an Hardware signal has make an event or overfloat, that rice a Hardware flag bit. that the ISR read, and when it read this flag it will run the ISR.What type of timer? I am talking for interrupts.
**broken link removed**Basically i don't know more for interrupts. Please explain me. I am not using any timer for interrupts.
https://ww1.microchip.com/downloads/en/DeviceDoc/31008a.pdfThanks for your valued help. But no codes for external interrupt. Request to you for send a example codes for external interrupt handling.
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 T0CON =0x87; //TMR0ON=1; T08BIT=0; T0CS=0; T0SE=0; PSA=0; T0PS2:T0PS0=111; INTCON=0xe0;//GIE/GIEH=1 PEIE/GIEL=1 TMR0IE=1 00 TMR0IF=0 00 //------------------------------------------------------------------------------------------------- void interrupt tc_int(void) { if (TMR0IE && TMR0IF) { TMR0IF=0; rf++; LATC1 =!LATC1;//blaa_off = !blaa_off } // process other interrupt sources here, if required }
#include<p18f2520.h>
// High priority interrupt vector
void INT0_ISR(void);
void chk_isr(void);
#pragma interrupt chk_isr
void chk_isr(void)
{
if(INTCONbits.INT0IF==1) INT0_ISR();
}
#pragma code isr = 0x08 // store the below code at address 0x08
void isr(void)
{
_asm
GOTO chk_isr
_endasm
}
#pragma code
void main()
{
TRISB=1; // B0 as Input
INTCONbits.INT0IE=1;
INTCONbits.INT0IF=0;
INTCONbits.GIE=1;
while(1){}
}
void INT0_ISR()
{
PORTBbits.RB2=1;
INTCONbits.INT0IF=0;
}
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?