Compiler does not support 64-bit integers on target Architechture

169 views Asked by At

I am new to MPLAB XC8 compiler and don't know why this error is happening as I did not use any number that is of 64 bit in my code.

Code is as follow

#include <pic16f877a.h>
#pragma config FOSC = EXTRC 
#pragma config WDTE = ON 
#pragma config PWRTE = OFF 
#pragma config BOREN = ON 
#pragma config LVP = ON 
#pragma config CPD = OFF 
#pragma config WRT = OFF 
#pragma config CP = OFF 
#define _XTAL_FREQ 8000000
#include <xc.h>
void main(void) 
{
    TRISB=0x00;
    while(1)
    {
    PORTB = 0xFF;
    __delay_ms(500);
    PORTB = 0x00 ;
    __delay_ms(500);
    }
return;
}
1

There are 1 answers

0
David Grayson On

The XC8 user's guide documents the __delay_ms macro, and explains that:

An error will result if these macros are used without defining the oscillator frequency symbol, the delay period requested is too large...

Try using a much smaller delay, like 1 ms. You can wrap the delay in a loop that iterates 500 times if you need to. The compiler likely encountered some numbers that could not fit in a 32-bit integer when it tried to turn your long delays into machine code, and it's unfortunate that it didn't give a better error message.

Also, if I am right about this, it should serve as lesson in simplification. You could have solved this yourself by simplifying the program down to the point where there is only one line of code in main and it is calling __delay_ms(500). Then, to simplify further, you would have tried reducing the delay and noticed that the problem goes away. You would have figured it out yourself instead of having to wait 2 days for a StackOverflow answer. See How to create a Minimal, Reproducible Example.