PDA

View Full Version : Could any pro out there help me to solve it? really appreciates



rookie
- 23rd March 2007, 02:56
Hi,
i have this problem on my program. I tried calling the interrupt routine but it just won't be called. For this case, i need to press the SW3(button) and there will be an interrupt but the interrupt just wont be activated and hence the routine won't be called. Can anyone help me with this? Any help will be appreciated.My source code is as below:


#include<p18f4620.h> //for special function register declarations
#include<portb.h> //for the RB0/INT0 interrupt
//#include<adc.h>
//#include<stdlib.h>
//#include<delays.h>


void Record (void);
#pragma code InterruptVectorHigh = 0x08
void InterruptVectorHigh(void)
{
_asm
goto Record
_endasm
}
#pragma code //allow the linker to locate the remaining code

#pragma interrupt Record
void Record(void)
{
PORTDbits.RD6=0;
PORTDbits.RD7=0;
PORTCbits.RC2=0;
INTCONbits.INT0IF=0; //clear flag to avoid another interrupt
}

void EnableHighInterrupts(void)
{
RCONbits.IPEN =1; //enable interrupt priority levels
INTCONbits.GIEH=1; //enable all high priority interrupts
}

void WaitForRecord(void)
{
//INTCONbits.RBIF=0;
while(1); //wait for the SW3 button to be pressed
}

void main(void)
{
/*Port, TRIS and LAT initialisation*/
//TRISA = 0x8F; //RA<3:0> as inputs, this value will change after
//checking PORT A
//PORTAbits.RA4=1;
//PORTAbits.RA5=1; //it showed HIGH on hardware but not at the
//watch view
ADCON1 = 0x0F;
TRISB = 0x07; //RB<2:0> as inputs
//RB<5:3> as outputs
//RB<7:6> as inputs
LATB = 0x00;
//PORTB=0x00;
//PORTBbits.RB3=1;
//PORTBbits.RB4=1;
//PORTBbits.RB5=1;

//TRISC = 0x20; //RC5 as inputs
//RC<7:6>, RC<4:0> as outputs
//PORTCbits.RC0=1;
//PORTCbits.RC1=1;
//PORTCbits.RC2=1;
//PORTCbits.RC3=1;
//PORTCbits.RC4=1;

//TRISD = 0x00; //RD<7:0> as outputs

//PORTDbits.RD6=1;
//PORTDbits.RD7=1;

//TRISE = 0xB0; //RE<2:0> as outputs, this value will change after
//checking PORT E
//ADCON1 = 0x0A;//Configure A/D for digital inputs for PORT E
//PORTEbits.RE0=1;
//PORTEbits.RE1=1;
//PORTEbits.RE2=1;


EnableHighInterrupts();

OpenRB0INT(PORTB_CHANGE_INT_ON & //enable the RB0/INT0 interrupt
PORTB_PULLUPS_ON & //configure the RB0 pin for input
FALLING_EDGE_INT); //trigger interrupt upon SW3 button
//depression
WaitForRecord();
}

skimask
- 23rd March 2007, 03:11
And yet again...look at the top of the web page...and tell me what you see.
I'd bet anything you'd see something relating to PicBasic.
I'd bet twice anything you don't see anything relating to C.
I could be wrong....