Autor Tema: pic18F46K20 XC8 no logro compilar en mplab X ide  (Leído 4105 veces)

0 Usuarios y 3 Visitantes están viendo este tema.

Desconectado yamilongiano

  • PIC10
  • *
  • Mensajes: 37
pic18F46K20 XC8 no logro compilar en mplab X ide
« en: 27 de Agosto de 2014, 14:17:14 »
Hola a todos les cuento me compre unos juguetitos nuevos que vendian.

el asunto para mi sorpresa es que el microcontrolador  me confunde un poco.

de partida creo que su oscilador interno es de minimo 16Mhz y no se como configurarlo, si me dan una ayuda con los fuses tambien en xc8.

le spongo el codigo a ver si me pueden ayudar ya que estava acostumbrado al pic16f628A.

datasheet pic18F46K20

Código: [Seleccionar]
#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;

    }

}

el codigo no presenta problemas pero me salen 2 errores  que no logro identificar, o no se como interpretarlos si me podrian explicar como  y donde salen los errores o como leerlos.

errores(output):

Código: [Seleccionar]
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)

ojala pueda compilar para poder jugar un ratito en el proteus. ya que viene con una placa para practicar. y aun no se como usarla estoy aprendiendo a usar el entrenador.(lamentablemente no viene con manual de uso pero me entretendre aprendiendo a usarlo).


aqui les dejo el pdf que encontre en su pagina y que espero me ayude a disfrutar mas de la electronica.

pdf de la placa de entenamiento.


ojala me puedan ayudar muchas gracias.

.

Desconectado pablomanieri

  • Colaborador
  • PIC24F
  • *****
  • Mensajes: 639
Re: pic18F46K20 XC8 no logro compilar en mplab X ide
« Respuesta #1 en: 27 de Agosto de 2014, 14:28:04 »
El error que te da es en esta línea:
Código: C
  1. #define_XTAL_FREQ 16000000__CONFIG(FOSC_XT & WDTE_OFF & CP_OFF & LVP_OFF);

faltan espacios, debería ser así:

Código: C
  1. #define _XTAL_FREQ 16000000UL
  2. __CONFIG(FOSC_XT & WDTE_OFF & CP_OFF & LVP_OFF);

Desconectado yamilongiano

  • PIC10
  • *
  • Mensajes: 37
Re: pic18F46K20 XC8 no logro compilar en mplab X ide
« Respuesta #2 en: 27 de Agosto de 2014, 15:49:16 »
El error que te da es en esta línea:
Código: C
  1. #define_XTAL_FREQ 16000000__CONFIG(FOSC_XT & WDTE_OFF & CP_OFF & LVP_OFF);

faltan espacios, debería ser así:

Código: C
  1. #define _XTAL_FREQ 16000000UL
  2. __CONFIG(FOSC_XT & WDTE_OFF & CP_OFF & LVP_OFF);


hola gracias por responder mira lo hago de las dos maneras y aun sigue sin compilar.



de otra manera sin errores tampoco compila.




output:

Código: [Seleccionar]
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)

Desconectado pablomanieri

  • Colaborador
  • PIC24F
  • *****
  • Mensajes: 639
Re: pic18F46K20 XC8 no logro compilar en mplab X ide
« Respuesta #3 en: 27 de Agosto de 2014, 16:14:03 »
estos son los fuses de ese pic, sacado del mplabX

Código: C
  1. // PIC18F46K20 Configuration Bit Settings
  2.  
  3. // 'C' source line config statements
  4.  
  5. #include <xc.h>
  6.  
  7. // #pragma config statements should precede project file includes.
  8. // Use project enums instead of #define for ON and OFF.
  9.  
  10. // CONFIG1H
  11. #pragma config FOSC = RCIO6     // Oscillator Selection bits (External RC oscillator, port function on RA6)
  12. #pragma config FCMEN = OFF      // Fail-Safe Clock Monitor Enable bit (Fail-Safe Clock Monitor disabled)
  13. #pragma config IESO = OFF       // Internal/External Oscillator Switchover bit (Oscillator Switchover mode disabled)
  14.  
  15. // CONFIG2L
  16. #pragma config PWRT = OFF       // Power-up Timer Enable bit (PWRT disabled)
  17. #pragma config BOREN = SBORDIS  // Brown-out Reset Enable bits (Brown-out Reset enabled in hardware only (SBOREN is disabled))
  18. #pragma config BORV = 18        // Brown Out Reset Voltage bits (VBOR set to 1.8 V nominal)
  19.  
  20. // CONFIG2H
  21. #pragma config WDTEN = ON       // Watchdog Timer Enable bit (WDT is always enabled. SWDTEN bit has no effect)
  22. #pragma config WDTPS = 32768    // Watchdog Timer Postscale Select bits (1:32768)
  23.  
  24. // CONFIG3H
  25. #pragma config CCP2MX = PORTC   // CCP2 MUX bit (CCP2 input/output is multiplexed with RC1)
  26. #pragma config PBADEN = ON      // PORTB A/D Enable bit (PORTB<4:0> pins are configured as analog input channels on Reset)
  27. #pragma config LPT1OSC = OFF    // Low-Power Timer1 Oscillator Enable bit (Timer1 configured for higher power operation)
  28. #pragma config HFOFST = ON      // HFINTOSC Fast Start-up (HFINTOSC starts clocking the CPU without waiting for the oscillator to stablize.)
  29. #pragma config MCLRE = ON       // MCLR Pin Enable bit (MCLR pin enabled; RE3 input pin disabled)
  30.  
  31. // CONFIG4L
  32. #pragma config STVREN = ON      // Stack Full/Underflow Reset Enable bit (Stack full/underflow will cause Reset)
  33. #pragma config LVP = ON         // Single-Supply ICSP Enable bit (Single-Supply ICSP enabled)
  34. #pragma config XINST = OFF      // Extended Instruction Set Enable bit (Instruction set extension and Indexed Addressing mode disabled (Legacy mode))
  35.  
  36. // CONFIG5L
  37. #pragma config CP0 = OFF        // Code Protection Block 0 (Block 0 (000800-003FFFh) not code-protected)
  38. #pragma config CP1 = OFF        // Code Protection Block 1 (Block 1 (004000-007FFFh) not code-protected)
  39. #pragma config CP2 = OFF        // Code Protection Block 2 (Block 2 (008000-00BFFFh) not code-protected)
  40. #pragma config CP3 = OFF        // Code Protection Block 3 (Block 3 (00C000-00FFFFh) not code-protected)
  41.  
  42. // CONFIG5H
  43. #pragma config CPB = OFF        // Boot Block Code Protection bit (Boot block (000000-0007FFh) not code-protected)
  44. #pragma config CPD = OFF        // Data EEPROM Code Protection bit (Data EEPROM not code-protected)
  45.  
  46. // CONFIG6L
  47. #pragma config WRT0 = OFF       // Write Protection Block 0 (Block 0 (000800-003FFFh) not write-protected)
  48. #pragma config WRT1 = OFF       // Write Protection Block 1 (Block 1 (004000-007FFFh) not write-protected)
  49. #pragma config WRT2 = OFF       // Write Protection Block 2 (Block 2 (008000-00BFFFh) not write-protected)
  50. #pragma config WRT3 = OFF       // Write Protection Block 3 (Block 3 (00C000h-00FFFFh) not write-protected)
  51.  
  52. // CONFIG6H
  53. #pragma config WRTC = OFF       // Configuration Register Write Protection bit (Configuration registers (300000-3000FFh) not write-protected)
  54. #pragma config WRTB = OFF       // Boot Block Write Protection bit (Boot Block (000000-0007FFh) not write-protected)
  55. #pragma config WRTD = OFF       // Data EEPROM Write Protection bit (Data EEPROM not write-protected)
  56.  
  57. // CONFIG7L
  58. #pragma config EBTR0 = OFF      // Table Read Protection Block 0 (Block 0 (000800-003FFFh) not protected from table reads executed in other blocks)
  59. #pragma config EBTR1 = OFF      // Table Read Protection Block 1 (Block 1 (004000-007FFFh) not protected from table reads executed in other blocks)
  60. #pragma config EBTR2 = OFF      // Table Read Protection Block 2 (Block 2 (008000-00BFFFh) not protected from table reads executed in other blocks)
  61. #pragma config EBTR3 = OFF      // Table Read Protection Block 3 (Block 3 (00C000-00FFFFh) not protected from table reads executed in other blocks)
  62.  
  63. // CONFIG7H
  64. #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.h
Có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

Desconectado yamilongiano

  • PIC10
  • *
  • Mensajes: 37
Re: pic18F46K20 XC8 no logro compilar en mplab X ide
« Respuesta #4 en: 27 de Agosto de 2014, 18:22:32 »
estos son los fuses de ese pic, sacado del mplabX

Código: C
  1. // PIC18F46K20 Configuration Bit Settings
  2.  
  3. // 'C' source line config statements
  4.  
  5. #include <xc.h>
  6.  
  7. // #pragma config statements should precede project file includes.
  8. // Use project enums instead of #define for ON and OFF.
  9.  
  10. // CONFIG1H
  11. #pragma config FOSC = RCIO6     // Oscillator Selection bits (External RC oscillator, port function on RA6)
  12. #pragma config FCMEN = OFF      // Fail-Safe Clock Monitor Enable bit (Fail-Safe Clock Monitor disabled)
  13. #pragma config IESO = OFF       // Internal/External Oscillator Switchover bit (Oscillator Switchover mode disabled)
  14.  
  15. // CONFIG2L
  16. #pragma config PWRT = OFF       // Power-up Timer Enable bit (PWRT disabled)
  17. #pragma config BOREN = SBORDIS  // Brown-out Reset Enable bits (Brown-out Reset enabled in hardware only (SBOREN is disabled))
  18. #pragma config BORV = 18        // Brown Out Reset Voltage bits (VBOR set to 1.8 V nominal)
  19.  
  20. // CONFIG2H
  21. #pragma config WDTEN = ON       // Watchdog Timer Enable bit (WDT is always enabled. SWDTEN bit has no effect)
  22. #pragma config WDTPS = 32768    // Watchdog Timer Postscale Select bits (1:32768)
  23.  
  24. // CONFIG3H
  25. #pragma config CCP2MX = PORTC   // CCP2 MUX bit (CCP2 input/output is multiplexed with RC1)
  26. #pragma config PBADEN = ON      // PORTB A/D Enable bit (PORTB<4:0> pins are configured as analog input channels on Reset)
  27. #pragma config LPT1OSC = OFF    // Low-Power Timer1 Oscillator Enable bit (Timer1 configured for higher power operation)
  28. #pragma config HFOFST = ON      // HFINTOSC Fast Start-up (HFINTOSC starts clocking the CPU without waiting for the oscillator to stablize.)
  29. #pragma config MCLRE = ON       // MCLR Pin Enable bit (MCLR pin enabled; RE3 input pin disabled)
  30.  
  31. // CONFIG4L
  32. #pragma config STVREN = ON      // Stack Full/Underflow Reset Enable bit (Stack full/underflow will cause Reset)
  33. #pragma config LVP = ON         // Single-Supply ICSP Enable bit (Single-Supply ICSP enabled)
  34. #pragma config XINST = OFF      // Extended Instruction Set Enable bit (Instruction set extension and Indexed Addressing mode disabled (Legacy mode))
  35.  
  36. // CONFIG5L
  37. #pragma config CP0 = OFF        // Code Protection Block 0 (Block 0 (000800-003FFFh) not code-protected)
  38. #pragma config CP1 = OFF        // Code Protection Block 1 (Block 1 (004000-007FFFh) not code-protected)
  39. #pragma config CP2 = OFF        // Code Protection Block 2 (Block 2 (008000-00BFFFh) not code-protected)
  40. #pragma config CP3 = OFF        // Code Protection Block 3 (Block 3 (00C000-00FFFFh) not code-protected)
  41.  
  42. // CONFIG5H
  43. #pragma config CPB = OFF        // Boot Block Code Protection bit (Boot block (000000-0007FFh) not code-protected)
  44. #pragma config CPD = OFF        // Data EEPROM Code Protection bit (Data EEPROM not code-protected)
  45.  
  46. // CONFIG6L
  47. #pragma config WRT0 = OFF       // Write Protection Block 0 (Block 0 (000800-003FFFh) not write-protected)
  48. #pragma config WRT1 = OFF       // Write Protection Block 1 (Block 1 (004000-007FFFh) not write-protected)
  49. #pragma config WRT2 = OFF       // Write Protection Block 2 (Block 2 (008000-00BFFFh) not write-protected)
  50. #pragma config WRT3 = OFF       // Write Protection Block 3 (Block 3 (00C000h-00FFFFh) not write-protected)
  51.  
  52. // CONFIG6H
  53. #pragma config WRTC = OFF       // Configuration Register Write Protection bit (Configuration registers (300000-3000FFh) not write-protected)
  54. #pragma config WRTB = OFF       // Boot Block Write Protection bit (Boot Block (000000-0007FFh) not write-protected)
  55. #pragma config WRTD = OFF       // Data EEPROM Write Protection bit (Data EEPROM not write-protected)
  56.  
  57. // CONFIG7L
  58. #pragma config EBTR0 = OFF      // Table Read Protection Block 0 (Block 0 (000800-003FFFh) not protected from table reads executed in other blocks)
  59. #pragma config EBTR1 = OFF      // Table Read Protection Block 1 (Block 1 (004000-007FFFh) not protected from table reads executed in other blocks)
  60. #pragma config EBTR2 = OFF      // Table Read Protection Block 2 (Block 2 (008000-00BFFFh) not protected from table reads executed in other blocks)
  61. #pragma config EBTR3 = OFF      // Table Read Protection Block 3 (Block 3 (00C000-00FFFFh) not protected from table reads executed in other blocks)
  62.  
  63. // CONFIG7H
  64. #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.h
Có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

muchas muchas gracias por su ayuda, he dado con el problema con tu ayuda. resulta que el libro que me compre me hace modificar el xlcd para microcontroladores de pic16xxx

entonces contengo dos xlcd.h una para pic16 y uno para pic18. aun que no estava usando  nada que tenga que ver con el lcd. al parecer llama de igual manera a ese archivo por lo tanto no compilaba he vuelto a poner el que viene en las librerias de xc8 y se a solucionado el problema.

muchas gracias por lo fuses del chip me sirvieron mucho.