Possible to build/compile from command line ?

Possible to build/compile from command line ?

Postby PriB » Wed Apr 26, 2017 1:45 pm

Hello,
I have a verry simple programm that is trying to write some data into UART 3 :
Code: Select all
/********************************
Dependencies:   xc.h, stdio.h
Processor:      PIC32MX795F512L
Complier:       XC32 v1.32
Debugger:       Simulator
********************************/
#include <xc.h>
#include <stdio.h>
void _mon_putc (char c)
 {
    while (U3STAbits.UTXBF); //Wait till transmission is complete
       U3TXREG = c;
 }

 int main (void)
 {
   U3MODEbits.UARTEN = 0x01; //Enable UART module
   U3STAbits.UTXEN = 0x01;// Enable UART transmission
   printf("Hello World");
   while(1);
   return 0;
 }


I took it from the wiki, it is verry simple and builds fine on MPLAB X, but I can't find a way to build this from the terminal...
I simply type
xc32-gcc main.c
and get folowing error :
main.c: In function '_mon_putc':
main.c:13:12: error: 'U3STAbits' undeclared (first use in this function)
while (U3STAbits.UTXBF); //Wait till transmission is complete
^
main.c:13:12: note: each undeclared identifier is reported only once for each function it appears in
main.c:14:8: error: 'U3TXREG' undeclared (first use in this function)
U3TXREG = c;
^
main.c: In function 'main':
main.c:21:4: error: 'U3MODEbits' undeclared (first use in this function)
U3MODEbits.UARTEN = 0x01; //Enable UART module
^
main.c:22:4: error: 'U3STAbits' undeclared (first use in this function)
U3STAbits.UTXEN = 0x01;// Enable UART transmission


Can anyone tell me a bit more about the buildsystem of MPLAB X? If you have a tip or a workaround it would be helpfull !
PriB
 
Posts: 2
Joined: Wed Apr 26, 2017 1:34 pm

Re: Possible to build/compile from command line ?

Postby AussieSusan » Thu Apr 27, 2017 3:53 am

The IDE tells the compiler which processor to build for using a command line 'pre-processor' symbol definition. I can't remember the exact symbol but if you g=build with the IDE and look at the generated command line then you will see the device that you selected for the project somewhere in that command line.
The <xc.h> include file uses that symbol to select the correct device specific include fie that contains all of the appropriate register definitions etc..
Susan
AussieSusan
Verified identity
 
Posts: 173
Joined: Mon Jun 16, 2014 4:45 am
PIC experience: Experienced Hobbyist

Re: Possible to build/compile from command line ?

Postby PriB » Thu Apr 27, 2017 9:16 am

Thanks verry much @AussiSusan,
I cleaned build and dist folders from my project and ran the
Code: Select all
make -f (...) SUBPROJECTS= .build-conf
normally ran by the IDE and was able to catch the xc32-gcc command called by redirecting the output.
And the command is so huge, impossible to guess :
Code: Select all
"C:\Program Files (x86)\Microchip\xc32\v1.43\bin\xc32-gcc.exe" -g -x c -c -mprocessor=32MX795F512L -MMD -MF build/default/production/main.o.d -o build/default/production/main.o main.c -DXPRJ_default=default -legacy-libc


Anyway problem now I can go back to my work, by the way is there a way to "export" a varible as it was possible in MPLAB ? Because this would be verry usefull too and I saw on the official forum that this feature "should be introduced in a future release" since 2013 http://www.microchip.com/forums/m712360.aspx and I can't find the address specified for my variable in the watch window in the data memory...
PriB
 
Posts: 2
Joined: Wed Apr 26, 2017 1:34 pm


Return to MPLAB X IDE

Who is online

Users browsing this forum: No registered users and 7 guests

cron