2
\$\begingroup\$

I am programming a pic18f4550. When I try to compile the project I get two errors.

According to what the console indicates, they are caused by the following function.

void interrupt interupciones()
{
   //do something.
}

The errors are the following:

control.c: 126: 6: error: variable has incomplete type 'void' void interrupt interrupts ()

control.c: 126: 15: error: expected ';' after top level declarator void interrupt interrupts ()

I have tried the following but the error persists.

void __interrupt my_interr(void)
{
  //do something.
}

If I remove the interrupt from the function then the project compiles correctly.

But doing the simulation doesn't work.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ the error messages don't match your code; please actually post your code, at least from the names. \$\endgroup\$ Commented Apr 12, 2020 at 19:22
  • 1
    \$\begingroup\$ @MarcusMüller I'm guessing the OP ran the question through a translator and used the actual code, since "interupciones" means "interrupts". I think this is the actual code, just a translated question. \$\endgroup\$
    – Ron Beyer
    Commented Apr 12, 2020 at 19:48

1 Answer 1

4
\$\begingroup\$

In XC8, you need to define interrupts this way (the myISR can be changed to whatever you want):

void __interrupt() myISR(void)
{
    //Do something
}

Provided you are compiling against C99. The old void interrupt myISR(void) syntax is from XC8 2.00 or lower. They changed the way interrupts are defined after that. If you are not compiling against C99, you can also try void interrupt() myISR(void) { ... }.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.