Cos'è ElectroYou | Login Iscriviti

ElectroYou - la comunità dei professionisti del mondo elettrico

Problemi compilazione base_pierin

Raccolta di codici sorgenti

Moderatore: Foto UtentePaolino

1
voti

[1] Problemi compilazione base_pierin

Messaggioda Foto Utenteemacar » 7 giu 2014, 12:59

Buongiorno a tutti.
Ho appena spacchettato il mio Pierin! Ho testato che la scheda funzionasse come dovuto ed è tutto ok. Il prossimo passo è stato provare a compilare il progetto base_Pierin e qui ho avuto qualche difficoltà.
Come IDE ho usato MPLAB-X e non MPLAB-IDE ed il primo problema è stato che il progetto non si apriva col doppio click sul file, ma poco male: ho seguito la procedura di importazione e sono riuscito ad aprirlo.
Successivamente ho compilato il progetto ed ho ricevuto una serie di warning ed error penso dovuti, questa volta, alla scelta del compilatore: infatti mentre il base_pierin dovrebbe essere stato fatto per C18, io ho installato XC8. Ovviamente potrei anche installare ed usare anche il C18, ma essendo il primo più recente penso sia meglio iniziare fin da subito con esso.
Ovviamente ho già visto qualcosa su internet, ad esempio a quanto pare non c'è bisogno di utilizzare la direttiva pragma e qualche errore potrebbe essere dovuto a questo. Non essendomi però ancora arrivato il pickit 3, ci vado con i piedi di piombo perché se carico qualcosa di sbagliato sul PIC, non vorrei non riuscire più ad utilizzare il boot tramite USB e restare bloccato. Pertanto mi sarebbe d'aiuto qualche consiglio prima di fare cavolate. Di seguito ho postato l'output del compilatore.

Codice: Seleziona tutto
make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
make[1]: Entering directory `D:/Emanuele/ProgettiPIC/base_pierin/base.X'
make  -f nbproject/Makefile-default.mk dist/default/production/base.X.production.hex
make[2]: Entering directory `D:/Emanuele/ProgettiPIC/base_pierin/base.X'
"C:\Program Files (x86)\Microchip\xc8\v1.31\bin\xc8.exe" --pass1  --chip=18F47J53 -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 --stack=compiled "--errformat=%%f:%%l: error: (%%n) %%s" "--warnformat=%%f:%%l: warning: (%%n) %%s" "--msgformat=%%f:%%l: advisory: (%%n) %%s"    -obuild/default/production/_ext/1472/main.p1  ../main.c
../mappa_int.h:24: warning: (335) unknown pragma "code"
../mappa_int.h:27: error: (195) expression syntax
../mappa_int.h:28: error: (312) ";" expected
../mappa_int.h:31: warning: (335) unknown pragma "code"
../mappa_int.h:34: error: (195) expression syntax
../mappa_int.h:35: error: (312) ";" expected
../mappa_int.h:37: warning: (335) unknown pragma "code"
../mappa_int.h:40: error: (195) expression syntax
../mappa_int.h:41: error: (312) ";" expected
../mappa_int.h:61: warning: (335) unknown pragma "code"
../mappa_int.h:64: error: (195) expression syntax
../mappa_int.h:65: error: (312) ";" expected
../mappa_int.h:66: warning: (335) unknown pragma "code"
../mappa_int.h:69: error: (195) expression syntax
../mappa_int.h:70: error: (312) ";" expected
../main.c:17: warning: (335) unknown pragma "udata"
../main.c:23: warning: (335) unknown pragma "code"
../main.c:24: warning: (335) unknown pragma "interrupt"
../main.c:36: warning: (335) unknown pragma "interruptlow"
../main.c:49: warning: (335) unknown pragma "code"
../main.c:55: warning: (335) unknown pragma "code"
make[2]: Leaving directory `D:/Emanuele/ProgettiPIC/base_pierin/base.X'
make[1]: Leaving directory `D:/Emanuele/ProgettiPIC/base_pierin/base.X'
(908) exit status = 1
make[2]: *** [build/default/production/_ext/1472/main.p1] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2

BUILD FAILED (exit value 2, total time: 950ms)
Avatar utente
Foto Utenteemacar
156 6
Frequentatore
Frequentatore
 
Messaggi: 145
Iscritto il: 3 dic 2013, 11:02

1
voti

[2] Re: Problemi compilazione base_pierin

Messaggioda Foto Utenteemacar » 8 giu 2014, 10:43

Io intanto mi rispondo solo :D
Questo è il codice originario del file "mappa_int.h":
Codice: Seleziona tutto
//******************************************************************************
// Sezione per la mappatura delle interrupt.
// Questo file di configurazione serve per edirezionare opportunamente
// Le interrupt sia nei casi in cui si usa il bootloader o meno.
// QUESTA PARTE DEL FILE NON DEVE ESSERE MODIFICATA!
//******************************************************************************
// Interrupt function prototypes
void highPriorityInterrupt();
void lowPriorityInterrupt();

   
#if defined(USE_HID_BOOTLOADER)
   #define REMAPPED_RESET_VECTOR_ADDRESS         0x1000
   #define REMAPPED_HIGH_INT_VECTOR_ADDRESS   0x1008
   #define REMAPPED_LOW_INT_VECTOR_ADDRESS   0x1018
#else   
   #define REMAPPED_RESET_VECTOR_ADDRESS         0x00
   #define REMAPPED_HIGH_INT_VECTOR_ADDRESS   0x08
   #define REMAPPED_LOW_INT_VECTOR_ADDRESS   0x18
#endif

#if defined(USE_HID_BOOTLOADER)
  extern void _startup (void);        // See c018i.c in your C18 compiler dir
  #pragma code REMAPPED_RESET_VECTOR = REMAPPED_RESET_VECTOR_ADDRESS
  void _reset (void)
  {
    _asm goto _startup _endasm
  }
#endif

#pragma code REMAPPED_HIGH_INT_VECTOR = REMAPPED_HIGH_INT_VECTOR_ADDRESS
void Remapped_High_ISR (void)
{
  _asm goto highPriorityInterrupt _endasm
}

#pragma code REMAPPED_LOW_INT_VECTOR = REMAPPED_LOW_INT_VECTOR_ADDRESS
void Remapped_Low_ISR (void)
{
   _asm goto lowPriorityInterrupt _endasm
}

#if defined(USE_HID_BOOTLOADER)
//Note: If this project is built while one of the bootloaders has
//been defined, but then the output hex file is not programmed with
//the bootloader, addresses 0x08 and 0x18 would end up programmed with 0xFFFF.
//As a result, if an actual interrupt was enabled and occured, the PC would jump
//to 0x08 (or 0x18) and would begin executing "0xFFFF" (unprogrammed space).  This
//executes as nop instructions, but the PC would eventually reach the REMAPPED_RESET_VECTOR_ADDRESS
//(0x1000 or 0x800, depending upon bootloader), and would execute the "goto _startup".  This
//would effective reset the application.

//To fix this situation, we should always deliberately place a
//"goto REMAPPED_HIGH_INT_VECTOR_ADDRESS" at address 0x08, and a
//"goto REMAPPED_LOW_INT_VECTOR_ADDRESS" at address 0x18.  When the output
//hex file of this project is programmed with the bootloader, these sections do not
//get bootloaded (as they overlap the bootloader space).  If the output hex file is not
//programmed using the bootloader, then the below goto instructions do get programmed,
//and the hex file still works like normal.  The below section is only required to fix this
//scenario.
#pragma code HIGH_INTERRUPT_VECTOR = 0x08
void High_ISR (void)
{
  _asm goto REMAPPED_HIGH_INT_VECTOR_ADDRESS _endasm
}
#pragma code LOW_INTERRUPT_VECTOR = 0x18
void Low_ISR (void)
{
  _asm goto REMAPPED_LOW_INT_VECTOR_ADDRESS _endasm
}
#endif   //end of "#if defined(PROGRAMMABLE_WITH_USB_HID_BOOTLOADER)"


Questo invece l'ho modificato io per adattarlo a XC8 ed ho eliminato tutti i warning. Farò la stessa cosa con il file main ma vorrei avere conforto, in particolare da Foto UtenteTardoFreak per assicurarmi di non aver fatto cavolate.
Se riesco a fare tutto senza errori, si potrebbe anche aggiornare l'articolo sul Pierin o crearne uno nuovo per aiutare chi lo userà con XC8..

Codice: Seleziona tutto
//******************************************************************************
// Sezione per la mappatura delle interrupt.
// Questo file di configurazione serve per edirezionare opportunamente
// Le interrupt sia nei casi in cui si usa il bootloader o meno.
// QUESTA PARTE DEL FILE NON DEVE ESSERE MODIFICATA!
//******************************************************************************
// Interrupt function prototypes
void highPriorityInterrupt();
void lowPriorityInterrupt();

   
#if defined(USE_HID_BOOTLOADER)
   #define REMAPPED_RESET_VECTOR_ADDRESS         0x1000
   #define REMAPPED_HIGH_INT_VECTOR_ADDRESS   0x1008
   #define REMAPPED_LOW_INT_VECTOR_ADDRESS   0x1018
#else   
   #define REMAPPED_RESET_VECTOR_ADDRESS         0x00
   #define REMAPPED_HIGH_INT_VECTOR_ADDRESS   0x08
   #define REMAPPED_LOW_INT_VECTOR_ADDRESS   0x18
#endif

#if defined(USE_HID_BOOTLOADER)
  extern void _startup (void);        // See c018i.c in your C18 compiler dir

  void _reset (void) @ REMAPPED_RESET_VECTOR_ADDRESS
  {
    #asm goto _startup
    #endasm
  }

#endif


void Remapped_High_ISR (void) @ REMAPPED_HIGH_INT_VECTOR_ADDRESS
{
    #asm    goto highPriorityInterrupt
    #endasm
}


void Remapped_Low_ISR (void) @  REMAPPED_LOW_INT_VECTOR_ADDRESS
{
    #asm goto lowPriorityInterrupt
    #endasm
}

#if defined(USE_HID_BOOTLOADER)
//Note: If this project is built while one of the bootloaders has
//been defined, but then the output hex file is not programmed with
//the bootloader, addresses 0x08 and 0x18 would end up programmed with 0xFFFF.
//As a result, if an actual interrupt was enabled and occured, the PC would jump
//to 0x08 (or 0x18) and would begin executing "0xFFFF" (unprogrammed space).  This
//executes as nop instructions, but the PC would eventually reach the REMAPPED_RESET_VECTOR_ADDRESS
//(0x1000 or 0x800, depending upon bootloader), and would execute the "goto _startup".  This
//would effective reset the application.

//To fix this situation, we should always deliberately place a
//"goto REMAPPED_HIGH_INT_VECTOR_ADDRESS" at address 0x08, and a
//"goto REMAPPED_LOW_INT_VECTOR_ADDRESS" at address 0x18.  When the output
//hex file of this project is programmed with the bootloader, these sections do not
//get bootloaded (as they overlap the bootloader space).  If the output hex file is not
//programmed using the bootloader, then the below goto instructions do get programmed,
//and the hex file still works like normal.  The below section is only required to fix this
//scenario.

void High_ISR (void) @ 0x08
{
    #asm goto REMAPPED_HIGH_INT_VECTOR_ADDRESS
    #endasm
}

void Low_ISR (void) @ 0x18
{
    #asm goto REMAPPED_LOW_INT_VECTOR_ADDRESS
    #endasm
}
#endif   //end of "#if defined(PROGRAMMABLE_WITH_USB_HID_BOOTLOADER)"
Avatar utente
Foto Utenteemacar
156 6
Frequentatore
Frequentatore
 
Messaggi: 145
Iscritto il: 3 dic 2013, 11:02

0
voti

[3] Re: Problemi compilazione base_pierin

Messaggioda Foto UtenteTardoFreak » 8 giu 2014, 11:55

Purtroppo non uso MPLAB-X e quindi non saprei cosa dire. :(

A dire il vero non uso neanche molto Microchip per motivi di tempo (che manca). L' ho preso in mano ieri per tirare giù la base per la seriale virtuale.
Per lavoro uso gli ARM che sono tutt' altra cosa.
"La follia sta nel fare sempre la stessa cosa aspettandosi risultati diversi".
"Parla soltanto quando sei sicuro che quello che dirai è più bello del silenzio".
Rispondere è cortesia, ma lasciare l'ultima parola ai cretini è arte.
Avatar utente
Foto UtenteTardoFreak
73,9k 8 12 13
-EY Legend-
-EY Legend-
 
Messaggi: 15754
Iscritto il: 16 dic 2009, 11:10
Località: Torino - 3° pianeta del Sistema Solare


Torna a Firmware e programmazione

Chi c’è in linea

Visitano il forum: Nessuno e 11 ospiti