• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Where is the device files for xc8

Status
Not open for further replies.

be80be

Well-Known Member
I cant get the naming right for some reason
Code:
#include <xc.h>
#define _XTAL_FREQ 800000   //Used by the compiler for the delay_ms(x) macro
#define __delay_ms(x) _delay((unsigned long)((x)*(_XTAL_FREQ/4000.0)))
void main(void) {
  
  
    OSCCON = 0b01110110;            //8mhz clock speed based on internal oscillator block
    ADCON1 = 0b01111111;
    TRISBbits.RB0 = 0;           //using pin as output
    LATBbits.LATB0 =1;
        __delay_ms(1000) //
        LATBbits.LATB0 = LATBbits.LATB0 ^ 1;        //toggle the LED
        __delay_ms(1000);               //reassign since it has been decremented to 0 from the delay loop
      
  
  
}
it give me this error
Code:
"C:\Program Files\Microchip\xc8\v1.42\bin\xc8.exe" --pass1  --chip=18F1220 -Q -G  --double=24 --float=24 --emi=wordwrite --opt=+asm,+asmfile,-speed,+space,-debug,-local --addrqual=ignore --mode=free -P -N255 --warn=-3 --asmlist -DXPRJ_default=default  --summary=default,-psect,-class,+mem,-hex,-file --output=default,-inhx032 --runtime=default,+clear,+init,-keep,-no_startup,-download,+config,+clib,-plib   --output=-mcof,+elf:multilocs --stack=compiled:auto:auto:auto "--errformat=%f:%l: error: (%n) %s" "--warnformat=%f:%l: warning: (%n) %s" "--msgformat=%f:%l: advisory: (%n) %s"    -obuild/default/production/newxc32_newfile.p1  newxc32_newfile.c
newxc32_newfile.c:59: error: (195) expression syntax
make[2]: *** [build/default/production/newxc32_newfile.p1] Error 1
make[1]: *** [.build-conf] Error 2
(908) exit status = 1
nbproject/Makefile-default.mk:106: recipe for target 'build/default/production/newxc32_newfile.p1' failed
make[2]: Leaving directory 'C:/Users/USER/Desktop/test1220/tes1220.X'
nbproject/Makefile-default.mk:90: recipe for target '.build-conf' failed
make[1]: Leaving directory 'C:/Users/USER/Desktop/test1220/tes1220.X'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
make: *** [.build-impl] Error 2

BUILD FAILED (exit value 2, total time: 784ms)
 
Last edited:

Pommie

Well-Known Member
Most Helpful Member
Where is _delay() defined? The normal macros are __delay_ms() or __delay_us(). Note single and double underscores.

Mike.
 

be80be

Well-Known Member
whatsThedeal.png The dang thing shows the error at the LATBbits.LATB0 = LATBbits.LATB0 ^ 1;
But that should work I'm looking at the delay
 
Last edited:

be80be

Well-Known Member
I redid my code still no joy
Code:
#pragma config OSC = INTIO2     // Oscillator Selection bits (Internal RC oscillator, port function on RA6 and port function on RA7)
#pragma config FSCM = ON        // Fail-Safe Clock Monitor Enable bit (Fail-Safe Clock Monitor enabled)
#pragma config IESO = ON        // Internal External Switchover bit (Internal External Switchover mode enabled)

// CONFIG2L
#pragma config PWRT = OFF       // Power-up Timer Enable bit (PWRT disabled)
#pragma config BOR = ON         // Brown-out Reset Enable bit (Brown-out Reset enabled)
// BORV = No Setting

// CONFIG2H
#pragma config WDT = ON         // Watchdog Timer Enable bit (WDT enabled)
#pragma config WDTPS = 32768    // Watchdog Timer Postscale Select bits (1:32768)

// CONFIG3H
#pragma config MCLRE = ON       // MCLR Pin Enable bit (MCLR pin enabled, RA5 input pin disabled)

// CONFIG4L
#pragma config STVR = ON        // Stack Full/Underflow Reset Enable bit (Stack full/underflow will cause Reset)
#pragma config LVP = OFF        // Low-Voltage ICSP Enable bit (Low-Voltage ICSP disabled)

// CONFIG5L
#pragma config CP0 = OFF        // Code Protection bit (Block 0 (00200-0007FFh) not code-protected)
#pragma config CP1 = OFF        // Code Protection bit (Block 1 (000800-000FFFh) not code-protected)

// CONFIG5H
#pragma config CPB = OFF        // Boot Block Code Protection bit (Boot Block (000000-0001FFh) not code-protected)
#pragma config CPD = OFF        // Data EEPROM Code Protection bit (Data EEPROM not code-protected)

// CONFIG6L
#pragma config WRT0 = OFF       // Write Protection bit (Block 0 (00200-0007FFh) not write-protected)
#pragma config WRT1 = OFF       // Write Protection bit (Block 1 (000800-000FFFh) not write-protected)

// CONFIG6H
#pragma config WRTC = OFF       // Configuration Register Write Protection bit (Configuration registers (300000-3000FFh) not write-protected)
#pragma config WRTB = OFF       // Boot Block Write Protection bit (Boot Block (000000-0001FFh) not write-protected)
#pragma config WRTD = OFF       // Data EEPROM Write Protection bit (Data EEPROM not write-protected)

// CONFIG7L
#pragma config EBTR0 = OFF      // Table Read Protection bit (Block 0 (00200-0007FFh) not protected from table reads executed in other blocks)
#pragma config EBTR1 = OFF      // Table Read Protection bit (Block 1 (000800-000FFFh) not protected from table reads executed in other blocks)

// CONFIG7H
#pragma config EBTRB = OFF      // Boot Block Table Read Protection bit (Boot Block (000000-0001FFh) not protected from table reads executed in other blocks)

// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.

#include <xc.h>
#include <stdint.h>
#include <stdbool.h>
#define _XTAL_FREQ 800000   //Used by the compiler for the delay_ms(x) macro

void main(void) {
   OSCCON = 0b01110110;            //8mhz clock speed based on internal oscillator block
    ADCON1 = 0b01111111;
    TRISBbits.RB0 = 0;           //using pin as output
    LATBbits.LATB0 =0;
 
     while (1)
    {
        __delay_ms(1000); //
        LATBbits.LATB0 = LATBbits.LATB0 ^ 1;        //toggle the LED
        __delay_ms(1000);               //
     
     }
 
}
/**
 End of File
*/
Found it it was a dang ; missing above latbits
 
Last edited:

be80be

Well-Known Member
I'm trying to get the hang of xc8 and up the MCC helps a lot but it don't work on all the chips.
I like AVR Atmelstudio it's cool but I still like the pic chips redid some code to work with the attiny2313 kind of fun.
don't think I'll ever get good at this but it passes the time.
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top