Search code examples
cpicmplabpic18xc8

MPLAB XC8 compiler error:" no identifier in declaration "


I wrote a program that is using a Timer0 Interruption.

I can't seem to compile my code, I have an error on line 14 which is no identifier in declaration.

Here is the whole code:

#include<xc.h>
#define _XTAL_FREQ 4000000
#define param_1=0b10001000;
#define param_2=0b10101010;

int counter=0;

void interrupt f1() { 
    if(TMR0IE && TMR0IF) {
        counter++;
        INTCONbits.TMR0IF=0;
    }

int volatile param_1=0, param_2=0;

void int_tmr0(int conf_int, int conf_T0) {
    conf(param_1,param_2);
}
void conf(int p1, int p2) {
    T0CON= T0CON || p1;
    INTCON= INTCON||p2;
}

int main() {
    WDTCONbits.ADSHR=1;
    MEMCONbits.EBDIS=1;
    TRISD=0x0;
    INTCONbits.GIE=1;
    INTCONbits.TMR0IE=0;
    while(1){
        LATD=counter;
    }
}

Solution

  • Defining constants param_1 and param_2, lose the = and the ;:

    #define param_1 0b10001000
    #define param_2 0b10101010
    

    You seem to be missing a closing bracket in the function void interrupt f1(), This would be easier to detect if you indented your code correctly.

    Also, the standard for constans names is uppercase.