Using XC8 V2.00 or greater with Flowcode 8

Tips, Tricks and methods for programming, learn ways of making your programming life easier, and share your knowledge with others.

Moderators: Benj, Mods

Post Reply
medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Using XC8 V2.00 or greater with Flowcode 8

Post by medelec35 »

Note: Scroll down to my post dated Fri May 08, 2020 12:37 am.
It shows how to configure Flowcode to compile with latest version of XC8


Microchip have changed the way XC8 compiler works from V2.00
Pre V2.0 the default was to use C90 as standard.
From V2.0 the default is C99 as standard.
This will mean you will not get expected results if you start using XC8 V2.00 or above, especially if using pro version of compiler.
One typical example, Compiled a large flowchart with target = 18F47K40 & pro version XC8 V1.45 (default Flowcode V8 Compiler) I was getting 78% used (in V1.45 there is a bug which means the used value is a few % higher than it should be)
Tried with V2.05 (only changing path and not parameters) I was getting 93.2 % used. :(

After contacting microchip support, A new batch file was created for me and I thought I would share it for anyone who wants to use XC8 V2.0 or above:

Code: Select all

@REM $(chip) "$(outdir)" "$(target)"
@PUSHD %~2
"C:\Program Files (x86)\Microchip\xc8\v2.00\bin\xc8-cc.exe" -mcpu=%~1 "%~3.c" -w=359,1273,1388 -fshort-float -fshort-double -std=c90 -Os
@POPD
@IF %ERRORLEVEL% NEQ 0 GOTO Error
@ECHO.
@ECHO Compilation successful!
@EXIT 0
:Error
@ECHO.
@ECHO Error returned from [xc8.exe]
@EXIT 1


Note:Batch file can be use with XC8 Standard or pro versions.

After compiling with new batch file, the result is 73% used, much better than 93.2 used!
The batch files can be found within 64 bit windows:

Code: Select all

C:\Program Files (x86)\Flowcode\Compilers\pic\batch\
32 bit windows:

Code: Select all

C:\Program Files\Flowcode\Compilers\pic\batch\
I would recommend keeping original batch files and just create a new batch file for each compiler version.
Martin

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Using XC8 V2.00 or greater with Flowcode 8

Post by Benj »

Thanks Martin,

Some good info there! wow that memory usage jumped a lot. Not too up on the C standards so I wonder what C99 brings to the table that C90 cannot do?

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Using XC8 V2.00 or greater with Flowcode 8

Post by medelec35 »

Hi Ben,
This is the full information from micorochip:
Martin,

So, today I installed flowcode on my machine and created a sample project. And Now I understood the situation.

I think there is no real issue of PRO vs Free compiler here. Your license is working fine and it is evident from xclm -status.

The issue it that , with xc8 v2.00, we had major changes , we have introduced XC8-CC drivers which act as wrapper for XC8 , we have also introduced AVR devices with XC8.

So, to stream line process , compiler option were also changed. So any warning about " option didn't recognised" relate to this.

Second thing , XC8v2.00 default compiles with C99 standard . C99 do not allow to use custom keyword to use. so instead 'interrupt' you need to use '__interrupt()'.

However , you can switch back to C90 standard.


Given all these, I want you use my attached .bat file and compile the project with XC8v2.0.

Also, I believe flowcode ( Matrix ) should also note about this and update their code base , if you can inform them it will be great.

Let me know if it works.


Regards,

Parth
Left the name in case more information was required.
If it is then I can PM you the case number?
As you can see, Matrix is mentioned.
Martin

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Using XC8 V2.00 or greater with Flowcode 8

Post by Benj »

HI Martin,

The __interrupt change shouldn't be too much of a pain. We can always do this as a simple search and replace across the definition files if needed though it is a potential pain moving back and forth between versions.

Did they suggest why you were getting such an inflated use of ROM moving to the new compiler?
So any warning about " option didn't recognised" relate to this.
Do you know which options are producing warnings? Maybe it's something to do with this?

It might be interesting moving AVR compiler over to XC8 too? Though I'm not sure we would want to do this knowing what the free version of XC8 is known to do to low level code.

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Using XC8 V2.00 or greater with Flowcode 8

Post by medelec35 »

Benj wrote:The __interrupt change shouldn't be too much of a pain.
Is the interrupt change even required?
I have a large flowchart that uses Timer & RX interrupts, SPI and I2C (both hardware modes).
I can switch from XC8 v1.45 to XC8 v2.05 with no issues at all and don't need to modify Flowchart to do it.
Just need to change default batch file within compiler options.
Martin

Dirk Bubley
Posts: 99
Joined: Fri Feb 02, 2007 3:54 pm
Location: Germany
Has thanked: 14 times
Been thanked: 12 times
Contact:

Re: Using XC8 V2.00 or greater with Flowcode 8

Post by Dirk Bubley »

Hello together,
Hello Martin,

many thanks for the reply. Since my Pic8 Compiler Version is 1.45 it seems that first this needs to get updated.

Is there any discription how to install Version 2.xx Compiler?

Changing the Batch files is clear to me.

THX
Dirk

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Using XC8 V2.00 or greater with Flowcode 8

Post by medelec35 »

To change compiler to a later version.
1. Download compiler from microchip found here
In this case at the time of writing it's v2.20.
Install free version and make a note of the install directory:
Install dir.png
(23.2 KiB) Downloaded 945 times
I just leave all at the default settings.
Copy all within code code block below:

Code: Select all

@REM $(chip) "$(outdir)" "$(target)"
@PUSHD %~2
"C:\Program Files (x86)\Microchip\xc8\v2.00\bin\xc8-cc.exe" -mcpu=%~1 "%~3.c" -w=359,1273,1388 -fshort-float -fshort-double -std=c90 -Os
@POPD
@IF %ERRORLEVEL% NEQ 0 GOTO Error
@ECHO.
@ECHO Compilation successful!
@EXIT 0
:Error
@ECHO.
@ECHO Error returned from [xc8.exe]
@EXIT 1
You can save the batch file anywhere on you pc, so long as it's on the same drive as Flowcode installation.
Will save mine in C:\Flowcode Batch Files.
To do that create a new folder on root of C drive called Flowcode Batch Files.
Within C:\Flowcode Batch Files, right click and select New Text Document
I will assume you have the default setting of Hide know Extension Types
Double click to open new text document.
As you have already copied all the contents within the code block, paste all contents within the text document.

Change the path of "C:\Program Files (x86)\Microchip\xc8\v2.00\bin\xc8-cc.exe" -mcpu=%~1 "%~3.c" -w=359,1273,1388 -fshort-float -fshort-double -std=c90 -Os
To the version of xc8 you are installing.
In this case the whole line should be "C:\Program Files\Microchip\xc8\v2.20\bin\xc8-cc.exe" -mcpu=%~1 "%~3.c" -w=359,1273,1388 -fshort-float -fshort-double -std=c90 -Os
Select File, Save As then change Save as type: from Text Documents to All Files (*.*)
The file name should be something that ties up the the version of XC8 compiler and ends in .bat
Make sure you start and end with double quotes.
E.g "XC8 v2.20.bat"
Within the C:\Flowcode Batch Files you will see two files. A batch file with the name you have chosen and a text file.
You can delete the text file.

To change the default compiler within Flowcode.
Within Flowcode, Select Build, Compiler Options
Make sure PIC Default is highlighted.
Click on the save icon that's within Compiler options window.
A new window will appear, again enter a relevant name within the Setting Name: box, e.g XC8 v2.20
Select OK.
You should see:
Compiler options.png
(61.59 KiB) Downloaded 945 times
Ignore the PICkit3 lol
Select The new settings so its highlighted.
Select Default compiler for the platform C for PIC.
With the Compiler Tab selected, click on Browse and change the Executable Files (*.exe) to Batch Files (*.bat)
Select the new created batch file:
Select batch file.png
(46.58 KiB) Downloaded 945 times
then open.
Finally Select OK,
You should now be able to compile with the latest XC8 compiler
saved on the same drive as Flowcode installation.
Martin

Dirk Bubley
Posts: 99
Joined: Fri Feb 02, 2007 3:54 pm
Location: Germany
Has thanked: 14 times
Been thanked: 12 times
Contact:

Re: Using XC8 V2.00 or greater with Flowcode 8

Post by Dirk Bubley »

Many thanks Martin for the explanation. :D


BR

Dirk

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Using XC8 V2.00 or greater with Flowcode 8

Post by medelec35 »

Hi Dirk,
you're welcome.

Would you mind letting us know if successfully compiling with the latest version of XC8 or not?
Martin

Dirk Bubley
Posts: 99
Joined: Fri Feb 02, 2007 3:54 pm
Location: Germany
Has thanked: 14 times
Been thanked: 12 times
Contact:

Re: Using XC8 V2.00 or greater with Flowcode 8

Post by Dirk Bubley »

Hi Martin,

I followed your Installation procedure and FC8 compiling is running.

Below a result with the new XC8 Version 2.2 and the old Version 1.45.

I picked this fully over 100% loaded old FC8 source just to compare.

XC8 Compiler Version 2.20

Memory Summary:
Program space used 6F2Dh ( 28461) of 8000h bytes ( 86.9%)
Data space used 1CBh ( 459) of 600h bytes ( 29.9%)
Configuration bits used 7h ( 7) of 7h words (100.0%)
EEPROM space used 0h ( 0) of 100h bytes ( 0.0%)
ID Location space used 0h ( 0) of 8h bytes ( 0.0%)



XC8 Compiler Version 1.45

Memory Summary:
Program space used 7AA4h ( 31396) of 7A00h bytes (100.5%)
Data space used 1F8h ( 504) of 5FFh bytes ( 32.8%)
Configuration bits used 7h ( 7) of 7h words (100.0%)
EEPROM space used 0h ( 0) of 100h bytes ( 0.0%)
ID Location space used 0h ( 0) of 8h bytes ( 0.0%)
Data stack space used 0h ( 0) of 3E4h bytes ( 0.0%)


In the next time I will do some practical HEX downloads and run test at my devices in order to see if nothing has changed.

Many thanks

BR

Dirk

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Using XC8 V2.00 or greater with Flowcode 8

Post by medelec35 »

Thanks for that Dirk.
Although Looks like V2.20 is more efficient with Flowcode then V1.45, I believe they are the same
V1.45 has a memory reporting bug.
For example V1.45 verses 2.20:
1.45 reports Program space used 7AA4h ( 31396) of 7A00h bytes (100.5%)
Note 7A00h and you cant fill more than 100%!

2.20 reports Program space used 6F2Dh ( 28461) of 8000h bytes ( 86.9%)
I believe the 8000h is the correct amount.
Martin

Dirk Bubley
Posts: 99
Joined: Fri Feb 02, 2007 3:54 pm
Location: Germany
Has thanked: 14 times
Been thanked: 12 times
Contact:

Re: Using XC8 V2.00 or greater with Flowcode 8

Post by Dirk Bubley »

Hello Martin,

yes i can confirm the 100% mark bug.

At 1.45 I had already a message saying 100.8% and I was able to prog the device with the hex file without any problems.

Plus everything was running fine.

If you look at the progging tool, in my case it is a old Pic Kit-2 you see that Version 2.2 is using less lines.

BR

Dirk

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Using XC8 V2.00 or greater with Flowcode 8

Post by medelec35 »

Hi Dirk.
Thanks for the update.
Dirk Bubley wrote:If you look at the progging tool, in my case it is a old Pic Kit-2 you see that Version 2.2 is using less lines.
Yes that is a great way to determine efficiency.
So with the current settings V2.20 is more efficient than V1.45
Martin

Dirk Bubley
Posts: 99
Joined: Fri Feb 02, 2007 3:54 pm
Location: Germany
Has thanked: 14 times
Been thanked: 12 times
Contact:

Re: Using XC8 V2.00 or greater with Flowcode 8

Post by Dirk Bubley »

Hello Martin,
Hello together,

today I belive I found a Problem with this Compiler upgrade to 2.0 or greater.

I have a program wit a UART Interrupt routine at a PIC18F6722. It Looks that the Interrupt ist not activated inside the chip anymore.
Also going down to Compiler 1.45 does not solve the Problem.

Only a HEX File compiled before my upgrade to compiler version 2 is running without any Problems.

Any ideas how to solve this Problem??

BR

Dirk

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Using XC8 V2.00 or greater with Flowcode 8

Post by medelec35 »

Hi Dirk,
Dirk Bubley wrote:I have a program wit a UART Interrupt routine at a PIC18F6722. It Looks that the Interrupt ist not activated inside the chip anymore.
Also going down to Compiler 1.45 does not solve the Problem.
So that is not
Dirk Bubley wrote:Problem with this Compiler upgrade to 2.0 or greater
Dirk Bubley wrote:Any ideas how to solve this Problem??
You have not attached a flowchart so unable to help.
If you attach flowchart then I can look, but it maybe only matrix staff can help you?
Martin

User avatar
Steve
Matrix Staff
Posts: 3418
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Re: Using XC8 V2.00 or greater with Flowcode 8

Post by Steve »

Hi Dirk,

This sounds like a strange problem, and Martin's right that it may not be to do with the upgrade to (and back from) v2.0.

Do you have the original project where the interrupt works? It would help to see the C code this generates and to compare this with the C code for the project that does not work. If these are effectively the same then there has been a problem with the upgrade/downgrade and I suggest reinstalling Flowcode and the PIC toolchain. But if they are different in a significant way, then it will help show which aspect of the program is at fault (e.g. it could be the FCD chip definition file or a component has changed).

Please post these C code files if you have them and I will have a look to see if I can determine the problem.

Regards,
Steve.

Dirk Bubley
Posts: 99
Joined: Fri Feb 02, 2007 3:54 pm
Location: Germany
Has thanked: 14 times
Been thanked: 12 times
Contact:

Re: Using XC8 V2.00 or greater with Flowcode 8

Post by Dirk Bubley »

Hello Martin,

Hello Steve,

yes in between I could Isolate the Problem. My program with the interrupt was created with FC6.

But I have use FC8 and compiled with V2.00 and the Problem came up

I used a differnt PC with FC8 and 1.45 Compiler and the Problem was present too.

So indeed my Problem is not related to the different Compiler Version.


I wrote the program completley new in FC8 and it compiled and it is running perfectly inside the chip.

THX for you support and help!!

BR

Dirk

User avatar
Steve
Matrix Staff
Posts: 3418
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Re: Using XC8 V2.00 or greater with Flowcode 8

Post by Steve »

Great news, Dirk. Thanks for letting us know.

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Using XC8 V2.00 or greater with Flowcode 8

Post by medelec35 »

Thanks Dirk.
Is everything working with both v1.45 & v2 of XC8?
Martin

User avatar
Bruno
Posts: 67
Joined: Thu Jan 18, 2018 2:11 pm
Been thanked: 21 times
Contact:

Re: Using XC8 V2.00 or greater with Flowcode 8

Post by Bruno »

Hello Martin
I followed your instructions to install XC8-V2.20 and I think this is more efficient than V1.45
I compiled the same program with the two versions:

V1.45
Memory Summary:
Program space used 37CEh (14286) of 3D00h bytes (91.5%)
Data space used 129h (297) of 2FFh bytes (38.7%)
Configuration bits used 7h (7) of 7h words (100.0%)
EEPROM space used 8h (8) of 100h bytes (3.1%)
ID Location space used 0h (0) of 8h bytes (0.0%)
Data stack space used 0h (0) of 1C1h bytes (0.0%)

V2.20
Memory Summary:
Program space used 2C70h (11376) of 4000h bytes (69.4%)
Data space used 107h (263) of 300h bytes (34.2%)
Configuration bits used 7h (7) of 7h words (100.0%)
EEPROM space used 8h (8) of 100h bytes (3.1%)
ID Location space used 0h (0) of 8h bytes (0.0%)

Although version 1.45 has a bug, I still believe V2.20
be better.

Thanks
best regards

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Using XC8 V2.00 or greater with Flowcode 8

Post by medelec35 »

Hi, Bruno.
You could be right!

I have created a batch file that can be saved in the same location as the other batch files i.e with 64 bit windows:
C:\Program Files (x86)\Flowcode\Common\Compilers\picv2\batch
This is the batch file:

Code: Select all

@REM $(chip) "$(outdir)" "$(target)"
@PUSHD %~2
%~dp0..\bin\xc8-cc.exe -mcpu=%~1  "%~3.c" -w=359,1273,1388 -fshort-float -fshort-double -std=c90 -Os
@POPD
@IF %ERRORLEVEL% NEQ 0 GOTO Error
@ECHO.
@ECHO Compilation successful!
@EXIT 0
:Error
@ECHO.
@ECHO Error returned from [xc8.exe]
@EXIT 1
Out of curiosity, have you compared the batch file for V2.x with the default batch file for 2.x?
Martin

User avatar
Bruno
Posts: 67
Joined: Thu Jan 18, 2018 2:11 pm
Been thanked: 21 times
Contact:

Re: Using XC8 V2.00 or greater with Flowcode 8

Post by Bruno »

Hi Martin
I have installed xc8-V2.20 in:
C: \ Program Files \ Microchip \ xc8 \ v2.20
and, following your instructions, I created the batch file:

@REM $(chip) "$(outdir)" "$(target)"
@PUSHD %~2
"C:\Program Files\Microchip\xc8\v2.20\bin\xc8-cc.exe" -mcpu=%~1 "%~3.c" -w=359,1273,1388 -fshort-float -fshort-double -std=c90 -Os
@POPD
@IF %ERRORLEVEL% NEQ 0 GOTO Error
@ECHO.
@ECHO Compilation successful!
@EXIT 0
:Error
@ECHO.
@ECHO Error returned from [xc8.exe]
@EXIT 1

This is from FC8:

@REM $(chip) "$(outdir)" "$(target)"
@PUSHD %~2
%~dp0..\bin\xc8.exe --chip=%~1 "%~3.c" --MSGDISABLE=359,1273,1388 --FLOAT=32 --DOUBLE=32
@POPD
@IF %ERRORLEVEL% NEQ 0 GOTO Error
@ECHO.
@ECHO Compilation successful!
@EXIT 0
:Error
@ECHO.
@ECHO Error returned from [xc8.exe]
@EXIT 1

I hope I was helpful

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Using XC8 V2.00 or greater with Flowcode 8

Post by medelec35 »

Ah sorry,
Just realised,
The code I posted is assuming you have downloaded the PIC compiler from the Flwocode.co.uk site as that uses V2.10 8bit PIC
Toolchain.
It was a while ago when I looked in tot it all.
Martin

User avatar
Bruno
Posts: 67
Joined: Thu Jan 18, 2018 2:11 pm
Been thanked: 21 times
Contact:

Re: Using XC8 V2.00 or greater with Flowcode 8

Post by Bruno »

Ah!! Ok
Sorry, but for xc16, can I install V1.6?
Thank you
Bruno

Post Reply