Hallo,
ich plage mich zurzeit mit den plibs in MPLABX herum und brauche von
daher eure Hilfe... Im Voraus schon mal Danke.
Also ich habe mir vor einigen Tagen auf dem Notebook die neue
MPLAB X IDE v3.30, den xc8 v1.37 und die plibs v2.0 installiert.
Ich habe dann vergeblich versucht ein altes Projekt zu kompilieren. Der
Compiler hat die #include <usart.h> nicht gefunden. Um das zu fixen hab
ich den .../include/plib Pfad zu den "Include directories" hinzugefügt.
Nun hat hat der Linker ein Problem und ich weiß nicht mehr weiter.
Mein minimal Code (aus der plib doc):
1 #pragma config FOSC = INTIO67, PLLCFG = OFF, IESO = OFF
2 #pragma config BOREN = OFF, BORV = 250
3 #pragma config WDTEN = OFF, WDTPS = 1
4 #pragma config MCLRE = EXTMCLR MCLR, HFOFST = OFF, PBADEN = OFF
5 #pragma config CCP2MX = PORTB3, STVREN = OFF, LVP = OFF, XINST = OFF, DEBUG = OFF
6 #pragma config CP0 = OFF, CP1 = OFF, CP2 = OFF, CP3 = OFF
7 #pragma config CPB = OFF, CPD = OFF
8 #pragma config EBTR0 = OFF
9 #pragma config EBTR1 = OFF
10 #pragma config EBTR2 = OFF
11 #pragma config EBTR3 = OFF
12
13 #define _XTAL_FREQ 8000000
14 #define USE_OR_MASKS
15
16 #include <xc.h>
17 #include <usart.h>
18
19 void main ( void ) {
20
21 unsigned char Txdata [] = "MICROCHIP_USART" ;
22 unsigned char config = 0 , spbrg = 0 , baudconfig = 0 , i = 0 ;
23
24 OSCCONbits . IRCF2 = 1 ;
25 OSCCONbits . IRCF1 = 1 ; // 8MHz
26 OSCCONbits . IRCF0 = 0 ;
27
28 ANSELC = 0x00 ; // enable digital input buffers
29 TRISCbits . TRISC6 = 0 ; // Tx
30 TRISCbits . TRISC7 = 1 ; // Rx
31
32
33 Close1USART ();
34 config = USART_TX_INT_OFF | USART_RX_INT_OFF | USART_ASYNCH_MODE | USART_EIGHT_BIT | USART_CONT_RX | USART_BRGH_LOW ;
35 spbrg = 51 ; //At 8Mhz of oscillator frequency & baud rate of 2400.
36 Open1USART ( config , spbrg );
37 baudconfig = BAUD_8_BIT_RATE | BAUD_AUTO_OFF ;
38 baud1USART ( baudconfig );
39
40 //------USART Transmission ----
41 while ( Busy1USART ());
42 puts1USART (( char * ) Txdata );
43
44
45 while ( 1 );
46 }
Die Fehlermeldung: 1 :: warning : ( 1273 ) Omniscient Code Generation not available in Free mode
2 : 0 : error : ( 500 ) undefined symbols :
3 _baud1USART ( dist / default / production / USARTconfig . X . production . obj ) _Open1USART ( dist / default / production / USARTconfig . X . production . obj ) _puts1USART ( dist / default / production / USARTconfig . X . production . obj )
4 ( 908 ) exit status = 1
5 nbproject / Makefile - default . mk : 125 : recipe for target ' dist / default / production / USARTconfig . X . production . hex ' failed
6 make [ 2 ] : Leaving directory ' / home / alexander / projects / MPLABXprojects / USARTconfig . X '
7 nbproject / Makefile - default . mk : 84 : recipe for target ' . build - conf ' failed
8 make [ 1 ] : Leaving directory ' / home / alexander / projects / MPLABXprojects / USARTconfig . X '
9 nbproject / Makefile - impl . mk : 39 : recipe for target ' . build - impl ' failed
10 make [ 2 ] : *** [ dist / default / production / USARTconfig . X . production . hex ] Error 1
11 make [ 1 ] : *** [. build - conf ] Error 2
12 make : *** [. build - impl ] Error 2
13
14 BUILD FAILED ( exit value 2 , total time : 3 s )
Ich verwende Gentoo Linux, sollte aber nicht von Belang sei, da ich es
auch unter win10 getestet habe.
Ich wäre euch sehr dankbar, wenn Ihr mir weiterhelfen könntet.
Ich habe es zwar nicht selber ausprobiert, aber vielleicht klappts es
nach der Anleitung von Nico:
http://pic-projekte.de/wordpress/?p=292#Compiler_Libraries
07.06.2016 21:51 :
Bearbeitet durch User
Wenn man nach der Anleitung von Nico vorgeht, wird das Programm
übersetzbar. Zusätzlich muss noch die Einbindung der plib aktiviert
werden, s. Bild.
Die Funktionen sind in der usart.h definiert: CloseUSART, OpenUSART usw.
ohne die 1 im Namen.
Vielen Dank wit für deine schnelle Antwort :)
Habs getestet, aber der Linker ist immer noch nicht zufrieden.
Code:
1 #pragma config FOSC = INTIO67, PLLCFG = OFF, IESO = OFF
2 #pragma config BOREN = OFF, BORV = 250
3 #pragma config WDTEN = OFF, WDTPS = 1
4 #pragma config MCLRE = EXTMCLR MCLR, HFOFST = OFF, PBADEN = OFF
5 #pragma config CCP2MX = PORTB3, STVREN = OFF, LVP = OFF, XINST = OFF, DEBUG = OFF
6 #pragma config CP0 = OFF, CP1 = OFF, CP2 = OFF, CP3 = OFF
7 #pragma config CPB = OFF, CPD = OFF
8 #pragma config EBTR0 = OFF
9 #pragma config EBTR1 = OFF
10 #pragma config EBTR2 = OFF
11 #pragma config EBTR3 = OFF
12
13 #define _XTAL_FREQ 8000000
14 #define USE_OR_MASKS
15 #define EAUSART_V11 // pic18f46k22
16
17 #include <xc.h>
18 #include <plib.h>
19
20 void INIT_uC ( void );
21
22 void main ( void ) {
23
24 unsigned char Txdata [] = "MICROCHIP_USART" ;
25 unsigned char config = 0 , baudconfig = 0 , i = 0 ;
26 unsigned int spbrg = 0 ;
27
28 OSCCONbits . IRCF2 = 1 ;
29 OSCCONbits . IRCF1 = 1 ; // 8MHz
30 OSCCONbits . IRCF0 = 0 ;
31
32 ANSELC = 0x00 ; // enable digital input buffers
33 TRISCbits . TRISC6 = 0 ; // Tx
34 TRISCbits . TRISC7 = 1 ; // Rx
35
36 Close1USART ();
37 config = USART_TX_INT_OFF | USART_RX_INT_OFF | USART_ASYNCH_MODE | USART_EIGHT_BIT | USART_CONT_RX | USART_BRGH_LOW ;
38 spbrg = 51 ; //At 8Mhz of oscillator frequency & baud rate of 2400.
39 Open1USART ( config , spbrg );
40 baudconfig = BAUD_8_BIT_RATE | BAUD_AUTO_OFF ;
41 baud1USART ( baudconfig );
42
43 //------USART Transmission ----
44 while ( Busy1USART ());
45 puts1USART (( char * ) Txdata );
46
47 while ( 1 );
48 }
Fehlerlmeldung: 1 :: warning : ( 1273 ) Omniscient Code Generation not available in Free mode
2 : 0 : error : ( 500 ) undefined symbols :
3 _baud1USART ( dist / default / production / USARTconfig . X . production . obj ) _Open1USART ( dist / default / production / USARTconfig . X . production . obj ) _puts1USART ( dist / default / production / USARTconfig . X . production . obj )
4 ( 908 ) exit status = 1
5 nbproject / Makefile - default . mk : 125 : recipe for target ' dist / default / production / USARTconfig . X . production . hex ' failed
6 make [ 2 ] : Leaving directory ' / home / alexander / projects / MPLABXprojects / USARTconfig . X '
7 nbproject / Makefile - default . mk : 84 : recipe for target ' . build - conf ' failed
8 make [ 1 ] : Leaving directory ' / home / alexander / projects / MPLABXprojects / USARTconfig . X '
9 nbproject / Makefile - impl . mk : 39 : recipe for target ' . build - impl ' failed
10 make [ 2 ] : *** [ dist / default / production / USARTconfig . X . production . hex ] Error 1
11 make [ 1 ] : *** [. build - conf ] Error 2
12 make : *** [. build - impl ] Error 2
13
14 BUILD FAILED ( exit value 2 , total time : 3 s )
Hat jemand ein Beispielprojekt, wo eine der plibs verwendet wird (xc8)?
Wäre sehr hilfreich.
Vielen Dank für jegliche Hilfe!
Bei mir lässt sich dein Quellcode problemlos compilieren.
Ist das Häckchen bei "Link in Peripheral Library" gesetzt? (s. mein
letzter Post)
Ups hab deinen vorletzten Post gar nicht gesehen.
Das Häkchen bei "Link in Peripheral Library" hatte ich nicht gesetzt...
Jetzt passts :-)
Vielen Dank Witkatz für deine Hilfe und Geduld!
09.06.2016 09:10 :
Bearbeitet durch User
Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.