16F877 interrupt c code error PICmicro C compiler

Status
Not open for further replies.

aeon782

Newbie level 2
Joined
Nov 22, 2012
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,296
Hi,

Can you please help me with this programming error. I am getting a compiler error "incomplete type is not allowed" for the following interrupt service routine code while compiling with PICmicro C compiler for a program running on PIC16F877:

char channB = 0;
int num = 0;
void interrupt isr(void) //incomplete type is not allowed
{
if(RBIF == 1)
{
num++;
channB = PORTB;
RBIF = 0;​
}​
}
 

Are you using mikroC. If yes

Try this code

Code:
char channB = 0;
int num = 0;
void interrupt() //incomplete type is not allowed
{
if(RBIF == 1)
{
num++;
channB = PORTB;
RBIF = 0;
}
}
 

Use this:
Code:
char channB = 0;
int num = 0;

void interrupt (void) //incomplete type is not allowed
{
if(RBIF_bit == 1)
{
num++;
channB = PORTB;
RBIF_bit = 0;
}
}

You don't need to write isr for the ISR.
Just use
Code:
void interrupt(void){

}

When writing/reading bits, you must write _bit at the end.

RBIF is a constant in mikroC which is equal to 0.

So, this condition:
Code:
if(RBIF == 1)

is always false.

To check the RBIF bit, you need to use
Code:
 if(RBIF_bit == 1)

The following line will generate an error, since you're trying to write to a constant.
Code:
RBIF = 0;

So, change
Code:
RBIF = 0;
to
Code:
RBIF_bit = 0;

I have made these necessary corrections in the complete code above.

Hope this helps.
Tahmid.
 

@Tahmid and internetuser2k12
Thanks for your help. I am not using mikroC compiler. But I have found the solution:

char channB = 0;
int num = 0;
#pragma vector = 0x04
__interrupt void isr(void) //incomplete type is not allowed
{
if(RBIF == 1)
{
num++;
channB = PORTB;
RBIF = 0;​
}​
}
 

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…