The problem is you can't declare interupt to have no value (void interrupt) and use the return; statement. Remove the return statement. If interrupt were to return something you would change the line to something like char interrupt. Don't do it though, you shouldn't call the ISR from your mainline code.
Edit: Looking more at the function of your code I have to say you really shouldn't just sit in an ISR as a delay, there are better methods. Any interrupts that are supposed to occur while it;s just sitting there will be ignored. If you're counting on a timed interrupt to give you specific delays the method you're attempting won't work. I could really go into a lot of boring detail here but it'd be better just to hear from you what you're trying to attempt and letting us guide you to good code.
managed to work things with your helps guys thanks ...
now i moved to more "complicated" problem
my goal is to turn led 1,2,3 in turn if INT0 is pressed it is changed to led 3,2,1(working)
if INT1 is pressed the delay between the light is changing.
the int1 command seems to be ignored not sure why...
Code:
#include <p18f452.h>
#include <stdlib.h>
#include <portb.h>
unsigned char a;
void delay(int);
void time(void);
void sw(void);
#pragma code high_vector=0x08
void high_vector(void)
{
if (INTCONbits.INT0IE==1)
_asm GOTO sw _endasm
if (INTCON3bits.INT1IE==1)
_asm GOTO time _endasm
}
#pragma code
////////////////////////////////////////
#pragma interrupt sw
void sw(void)
{
unsigned int j1;
a=a+1;
for(j1=0;j1<2000;j1++); //DELAY
INTCONbits.INT0IF=0;// RESET INT0
return;
}
////////////////////////////////////////
#pragma interrupt time
void time(void)
{
unsigned int j1;
a=a+1;
for(j1=0;j1<2000;j1++); //DELAY
INTCONbits.INT0IF=0;// RESET INT0
return;
}
/////////////////////////////////////////
void delay(int i)
{
int i1;
for (i1=0;i1<i;i1++);
}
void main(void)
{
TRISB=0x3f; //PORT B AS INPUT
TRISC=0X0; //PORT C AS OUTPUT
INTCONbits.INT0IE=1; //ENABLE INT0
INTCONbits.INT0IF=0; //reset INT0
INTCON3bits.INT1IP==1;
INTCON3bits.INT1IE==1;
INTCON3bits.INT1IF==0;
INTCON2bits.INTEDG0=1; //INTERRUP ON RISING //INTERRUP ON RISING
INTCON2bits.INTEDG1=1;
INTCONbits.PEIE=0; //ENABLE HIGH PERIORITY
INTCONbits.GIE=1; // ENABLE ALL INTERRUPT
while(1)
{
//////////////LEDS OPERATION/////////////////
if ((a&0x1)==0) //condition for led light direction
{
PORTCbits.RC0=1;
delay(0x3000);
PORTCbits.RC0=0;
delay(0x3000);
PORTCbits.RC1=1;
delay(0x3000);
PORTCbits.RC1=0;
delay(0x3000);
PORTCbits.RC5=1;
delay(0x3000);
PORTCbits.RC5=0;
delay(0x3000);
}
else
{
PORTCbits.RC5=1;
delay(0x3000);
PORTCbits.RC5=0;
delay(0x3000);
PORTCbits.RC1=1;
delay(0x3000);
PORTCbits.RC1=0;
delay(0x3000);
PORTCbits.RC0=1;
delay(0x3000);
PORTCbits.RC0=0;
delay(0x3000);
}
}
}
i know i should change the 'time' function for my case , but i first want that the INT1(switch number 1) interrupt will work.
uploading the picdemo board as it seen in proteus...
It might have something to do with the fact you copied and pasted the same code for sw and time without altering
Code:
INTCONbits.INT0IF=0;// RESET INT0
in the time section to
Code:
INTCONbits.INT1IF=0;// RESET INT1.
Also if I'm understanding what you're trying to do you can't give delay a cont value
Code:
PORTCbits.RC5=1;
delay(0x3000);
You need to make delay carry a value that's altered in the time function as desired.
Another issue is that you're declaring unsigned char a; globally and using it in two interrupt routines. If that's intended then ok but in case you weren't aware of the issues that it could raise I figured I'd bring your attention to it.
the delay function gets an 'int' variable so it is possible to send number,
the program works fine, but my problem that interrupt (INT1) is ignored
i am tracking it with breakpoint on the first 'if' condition. by pressing the RB0 button the program jump to 'void high_vector' , but if i turn on and off the switch that connected to RB1/INT1(can be seen in the picture.) the intrurrped is ignored and i don't see any break at the breakpoint.
**again i know i should change the time function for my purpose but for now i just want the the function will work.