Forum: Mikrocontroller und Digitale Elektronik XC32 Compiler Problem


von PABA (Gast)


Lesenswert?

Hallo Community

Ich habe ein Problem mit dem XC32 Compiler in MPLABX. In meinem Projekt 
wechsle ich den Mikrokontroller und benutze neu den PIC32MX534F064H 
anstatt den PIC32MX220F064D. Da ich den Code für den neuen PIC etwas 
abändern werde aber das alte Projekt für die bestehende Hardware 
behalten möchte, habe ich in MPLAB ein neues Projekt für den neuen 
Mikrokontroller aufgesetzt. Ich habe als erstes mal ein leeres main.c 
file aufgesetzt das wie folgt aussieht:
1
#include <xc.h> /* Defines special funciton registers, CP0 regs */
2
#include <plib.h> /* Include to use PIC32 peripheral libraries */
3
#include <stdint.h> /* For uint32_t definition */
4
#include <stdbool.h> /* For true/false definition */
5
6
/******************************************************************************/
7
/* Global Variable Declaration */
8
/******************************************************************************/
9
10
11
/******************************************************************************/
12
/* Main Program */
13
/******************************************************************************/
14
15
int32_t main(void)
16
{
17
    /*Refer to the C32 peripheral library documentation for more
18
    information on the SYTEMConfig function.
19
20
    This function sets the PB divider, the Flash Wait States, and the DRM
21
    /wait states to the optimum value. It also enables the cacheability for
22
    the K0 segment. It could has side effects of possibly alter the pre-fetch
23
    buffer and cache. It sets the RAM wait states to 0. Other than
24
    the SYS_FREQ, this takes these parameters. The top 3 may be '|'ed
25
    together:
26
27
    SYS_CFG_WAIT_STATES (configures flash wait states from system clock)
28
    SYS_CFG_PB_BUS (configures the PB bus from the system clock)
29
    SYS_CFG_PCACHE (configures the pCache if used)
30
    SYS_CFG_ALL (configures the flash wait states, PB bus, and pCache)*/
31
32
    /* User clock/system configuration */
33
 //SYSTEMConfig(SYS_FREQ, SYS_CFG_WAIT_STATES | SYS_CFG_PCACHE);
34
35
 /* Configure the target for maximum performance at 80MHz */
36
 SYSTEMConfigPerformance(80000000UL);
37
38
 /* Power checks */
39
 if(RCONbits.SWR) RCONbits.SWR = 0; // Clear Software Reset bit after Power Down mode
40
41
    while(1)
42
    {}
43
}

Wenn ich das Projekt nun kompilliere, erhalte ich folgende 
Fehlermeldungen:

p32mx220f032d.h:73:3: error: conflicting types for '__WDTCONbits_t'
p32mx534f064h.h:73:3: note: previous declaration of '__WDTCONbits_t' was 
here
...

Die Fehler erhalte ich erst dann, wenn ich die Peripherie Library des 
compilers hinzufüge mit #include <plib.h>. Wie es scheint, includiert 
der Compiler das h-File für beide Prozessoren weshalb er mir nun meldet, 
er habe die Konfigurations-Register zweimal deklariert.
Ich habe das Problem bereits im Forum von Microchip deponiert, jedoch 
konnte mir da bisher niemand helfen. Ich habe die Hoffnung dass mir hier 
vielleicht jemand einen Hinweis liefern kann.

von Frank K. (fchk)


Lesenswert?

xc.h sieht ja so aus (hier für XC16)
1
/*
2
 *  xc.h 
3
 *
4
 *  Generic include file for XC16
5
 *
6
 *  Copyright 2012 Microchip Technology
7
 */
8
9
#if defined(__PIC24EP128GP202__)
10
#include <p24EP128GP202.h>
11
#endif
12
13
#if defined(__PIC24EP128GP204__)
14
#include <p24EP128GP204.h>
15
#endif
16
17
#if defined(__PIC24EP128GP206__)
18
#include <p24EP128GP206.h>
19
#endif
20
21
#if defined(__PIC24EP128MC202__)
22
#include <p24EP128MC202.h>
23
#endif 
24
25
...

Irgendwo in Deinen Projektdateien sind also zwei Prozessoren definiert. 
Schau auch ins nbproject Verzeichnis rein, da sind die generierten 
Projektdateien.

von PABA (Gast)


Lesenswert?

Ich habe das Projekt jetzt nochmals komplett neu aufgesetzt. Nochmals 
ein main.c File erstellt, das nur folgenden Inhalt hat:
1
int main(void)
2
{
3
  while(1)
4
  {}
5
}

So kompiliert das Projekt wunderbar. Füge ich folgenden Inhalt ins 
main.c ein:
1
#include <xc.h>
2
3
int main(void)
4
{
5
  while(1)
6
  {}
7
}

erscheinen wieder all die schönen Error Meldungen. Ich habe mir xc.h 
angeschaut. MPLABX hebt mir ja die Precompiler Anweisungen die 
ausgeführt werden schön farbig hervor. Die #include 
<proc/p32mx220f032d.h> bleibt ausgegraut, so wie es sein soll, während 
#include <proc/p32mx534f064h.h> eingefügt wird.

Wenn ich mir die Files im Ordner nbproject anschaue, scheint ebenfalls 
alles richtig zu sein. Im configurations.xml ist einzig der 
PIC32MX534F064H als targetDevice konfiguriert.

von PABA (Gast)


Lesenswert?

Eine Neuinstallation des Compilers hat mein Problem behoben. Das kommt 
mir aber doch noch reichlich spanisch vor. Also ich wäre nach wie vor an 
einer Erklärung interessiert falls jemand einen Hinweis hat.

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.