#include <xc.h>
#include <stdio.h>
#define_XTAL_FREQ 16000000__CONFIG(FOSC_XT & WDTE_OFF & CP_OFF & LVP_OFF);
void main(void) {
ANSEL=0;
ANSELH=0;
TRISB=0;
TRISA=255;
PORTA=0;
PORTB=0;
while(1)
{
if(RA0==1)
RB0=1;
else
RB0=0;
if(RA1==1)
RB1=1;
else
RB1=0;
if(RA2==1)
RB2=1;
else
RB2=0;
}
}
CLEAN SUCCESSFUL (total time: 187ms)
make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
make[1]: Entering directory 'C:/Users/yamil/Desktop/PIC18f46k20/pruebas.X'
make -f nbproject/Makefile-default.mk dist/default/production/pruebas.X.production.hex
make[2]: Entering directory 'C:/Users/yamil/Desktop/PIC18f46k20/pruebas.X'
"C:\Program Files\Microchip\xc8\v1.32\bin\xc8.exe" --pass1 --chip=18F46K20 -Q -G --double=24 --float=24 --emi=wordwrite --opt=default,+asm,+asmfile,-speed,+space,-debug --addrqual=ignore --mode=free -P -N255 --warn=0 --asmlist --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/pruebas.p1 pruebas.c
C:\Program Files\Microchip\xc8\v1.32\include\xlcd.h:76: warning: (111) redefining preprocessor macro "PARAM_SCLASS" (C:\Program Files\Microchip\xc8\v1.32\include\plib\can2510.h: 409)
C:\Program Files\Microchip\xc8\v1.32\include\xlcd.h:77: warning: (111) redefining preprocessor macro "MEM_MODEL" (C:\Program Files\Microchip\xc8\v1.32\include\plib\usart.h: 90)
pruebas.c:11: warning: (107) illegal # directive "define_XTAL_FREQ"
(908) exit status = 1
make[2]: *** [build/default/production/pruebas.p1] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
C:\Program Files\Microchip\xc8\v1.32\include\xlcd.h:82: error: (267) bad storage class
nbproject/Makefile-default.mk:91: recipe for target 'build/default/production/pruebas.p1' failed
make[2]: Leaving directory 'C:/Users/yamil/Desktop/PIC18f46k20/pruebas.X'
nbproject/Makefile-default.mk:75: recipe for target '.build-conf' failed
make[1]: Leaving directory 'C:/Users/yamil/Desktop/PIC18f46k20/pruebas.X'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
BUILD FAILED (exit value 2, total time: 2s)El error que te da es en esta línea:Código: C
#define_XTAL_FREQ 16000000__CONFIG(FOSC_XT & WDTE_OFF & CP_OFF & LVP_OFF);
faltan espacios, debería ser así:Código: C
#define _XTAL_FREQ 16000000UL __CONFIG(FOSC_XT & WDTE_OFF & CP_OFF & LVP_OFF);
CLEAN SUCCESSFUL (total time: 125ms)
make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
make[1]: Entering directory 'C:/Users/yamil/Desktop/PIC18f46k20/pruebas.X'
make -f nbproject/Makefile-default.mk dist/default/production/pruebas.X.production.hex
make[2]: Entering directory 'C:/Users/yamil/Desktop/PIC18f46k20/pruebas.X'
"C:\Program Files\Microchip\xc8\v1.32\bin\xc8.exe" --pass1 --chip=18F46K20 -Q -G --double=24 --float=24 --emi=wordwrite --opt=default,+asm,+asmfile,-speed,+space,-debug --addrqual=ignore --mode=free -P -N255 --warn=0 --asmlist --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/pruebas.p1 pruebas.c
C:\Program Files\Microchip\xc8\v1.32\include\xlcd.h:76: warning: (111) redefining preprocessor macro "PARAM_SCLASS" (C:\Program Files\Microchip\xc8\v1.32\include\plib\can2510.h: 409)
C:\Program Files\Microchip\xc8\v1.32\include\xlcd.h:77: warning: (111) redefining preprocessor macro "MEM_MODEL" (C:\Program Files\Microchip\xc8\v1.32\include\plib\usart.h: 90)
C:\Program Files\Microchip\xc8\v1.32\include\xlcd.h:82: error: (267) bad storage class
(908) exit status = 1
nbproject/Makefile-default.mk:91: recipe for target 'build/default/production/pruebas.p1' failed
make[2]: *** [build/default/production/pruebas.p1] Error 1
make[2]: Leaving directory 'C:/Users/yamil/Desktop/PIC18f46k20/pruebas.X'
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
nbproject/Makefile-default.mk:75: recipe for target '.build-conf' failed
make[1]: Leaving directory 'C:/Users/yamil/Desktop/PIC18f46k20/pruebas.X'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
BUILD FAILED (exit value 2, total time: 1s)
C:\Program Files\Microchip\xc8\v1.32\include\xlcd.h:82: error: (267) bad storage class
estos son los fuses de ese pic, sacado del mplabXCódigo: C
// PIC18F46K20 Configuration Bit Settings // 'C' source line config statements #include <xc.h> // #pragma config statements should precede project file includes. // Use project enums instead of #define for ON and OFF. // CONFIG1H #pragma config FOSC = RCIO6 // Oscillator Selection bits (External RC oscillator, port function on RA6) #pragma config FCMEN = OFF // Fail-Safe Clock Monitor Enable bit (Fail-Safe Clock Monitor disabled) #pragma config IESO = OFF // Internal/External Oscillator Switchover bit (Oscillator Switchover mode disabled) // CONFIG2L #pragma config PWRT = OFF // Power-up Timer Enable bit (PWRT disabled) #pragma config BOREN = SBORDIS // Brown-out Reset Enable bits (Brown-out Reset enabled in hardware only (SBOREN is disabled)) #pragma config BORV = 18 // Brown Out Reset Voltage bits (VBOR set to 1.8 V nominal) // CONFIG2H #pragma config WDTEN = ON // Watchdog Timer Enable bit (WDT is always enabled. SWDTEN bit has no effect) #pragma config WDTPS = 32768 // Watchdog Timer Postscale Select bits (1:32768) // CONFIG3H #pragma config CCP2MX = PORTC // CCP2 MUX bit (CCP2 input/output is multiplexed with RC1) #pragma config PBADEN = ON // PORTB A/D Enable bit (PORTB<4:0> pins are configured as analog input channels on Reset) #pragma config LPT1OSC = OFF // Low-Power Timer1 Oscillator Enable bit (Timer1 configured for higher power operation) #pragma config HFOFST = ON // HFINTOSC Fast Start-up (HFINTOSC starts clocking the CPU without waiting for the oscillator to stablize.) #pragma config MCLRE = ON // MCLR Pin Enable bit (MCLR pin enabled; RE3 input pin disabled) // CONFIG4L #pragma config STVREN = ON // Stack Full/Underflow Reset Enable bit (Stack full/underflow will cause Reset) #pragma config LVP = ON // Single-Supply ICSP Enable bit (Single-Supply ICSP enabled) #pragma config XINST = OFF // Extended Instruction Set Enable bit (Instruction set extension and Indexed Addressing mode disabled (Legacy mode)) // CONFIG5L #pragma config CP0 = OFF // Code Protection Block 0 (Block 0 (000800-003FFFh) not code-protected) #pragma config CP1 = OFF // Code Protection Block 1 (Block 1 (004000-007FFFh) not code-protected) #pragma config CP2 = OFF // Code Protection Block 2 (Block 2 (008000-00BFFFh) not code-protected) #pragma config CP3 = OFF // Code Protection Block 3 (Block 3 (00C000-00FFFFh) not code-protected) // CONFIG5H #pragma config CPB = OFF // Boot Block Code Protection bit (Boot block (000000-0007FFh) not code-protected) #pragma config CPD = OFF // Data EEPROM Code Protection bit (Data EEPROM not code-protected) // CONFIG6L #pragma config WRT0 = OFF // Write Protection Block 0 (Block 0 (000800-003FFFh) not write-protected) #pragma config WRT1 = OFF // Write Protection Block 1 (Block 1 (004000-007FFFh) not write-protected) #pragma config WRT2 = OFF // Write Protection Block 2 (Block 2 (008000-00BFFFh) not write-protected) #pragma config WRT3 = OFF // Write Protection Block 3 (Block 3 (00C000h-00FFFFh) 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-0007FFh) 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 Block 0 (Block 0 (000800-003FFFh) not protected from table reads executed in other blocks) #pragma config EBTR1 = OFF // Table Read Protection Block 1 (Block 1 (004000-007FFFh) not protected from table reads executed in other blocks) #pragma config EBTR2 = OFF // Table Read Protection Block 2 (Block 2 (008000-00BFFFh) not protected from table reads executed in other blocks) #pragma config EBTR3 = OFF // Table Read Protection Block 3 (Block 3 (00C000-00FFFFh) not protected from table reads executed in other blocks) // CONFIG7H #pragma config EBTRB = OFF // Boot Block Table Read Protection bit (Boot Block (000000-0007FFh) not protected from table reads executed in other blocks)
Yo nunca he usado ese pic. Debes ver el datasheet para corroborar como configurar los fuses, creo que ese pic no tiene el fuse CP_OFFF
También te está dando un error en el archivo de cabecera xlcd.hCódigo: [Seleccionar]C:\Program Files\Microchip\xc8\v1.32\include\xlcd.h:82: error: (267) bad storage class
No se a que se debe ese error