-1

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;
    }
}
maximus383
  • 584
  • 8
  • 25
  • 1
    What steps did you try to solve this problem? Did you search for this error message on Stack Overflow (there are already questions and answers about this error). Did you try to create a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example)? Furthermore, this page explaining [how to ask a question](https://stackoverflow.com/help/how-to-ask) might help you improving the question in order to get a good answer. Good luck with it. – wovano Jan 15 '20 at 09:34
  • your `#define param_1...` doesn't look right, same for param 2 – Colin Jan 15 '20 at 11:36
  • 2
    What does your compiler consider to be line 11 in that poorly formatted code? – underscore_d Jan 15 '20 at 11:36
  • 1
    Please format your code. -- Preprocessor and compiler are separated beasts. Do some research and, please, learn the basic stuff. – the busybee Jan 15 '20 at 12:23

1 Answers1

2

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.

anastaciu
  • 23,467
  • 7
  • 28
  • 53