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

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8817
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2559 times
Been thanked: 3715 times
Contact:

Using XC8 V2.00 or greater with Flowcode 8

Postby medelec35 » Tue Jun 04, 2019 12:09 pm

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.
These users thanked the author medelec35 for the post (total 4):
kersing (Tue Jun 04, 2019 9:55 pm) • Benj (Thu Jun 06, 2019 9:09 am) • DeeJayOne (Fri May 01, 2020 3:42 pm) • Dirk Bubley (Sun May 10, 2020 8:47 am)
Rating: 20%
 
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

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

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

Postby Benj » Thu Jun 06, 2019 9:10 am

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?
These users thanked the author Benj for the post:
medelec35 (Sun Apr 05, 2020 6:24 pm)
Rating: 5%
 

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8817
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2559 times
Been thanked: 3715 times
Contact:

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

Postby medelec35 » Sun Apr 05, 2020 6:34 pm

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.
These users thanked the author medelec35 for the post:
Benj (Mon Apr 06, 2020 9:49 pm)
Rating: 5%
 
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

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

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

Postby Benj » Mon Apr 06, 2020 9:51 pm

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.

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8817
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2559 times
Been thanked: 3715 times
Contact:

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

Postby medelec35 » Tue Apr 07, 2020 11:22 am

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.
These users thanked the author medelec35 for the post:
Benj (Thu Apr 09, 2020 3:31 pm)
Rating: 5%
 
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

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

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

Postby Dirk Bubley » Thu May 07, 2020 10:40 pm

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

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8817
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2559 times
Been thanked: 3715 times
Contact:

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

Postby medelec35 » Fri May 08, 2020 12:37 am

To change compiler to a later version.
1. Download compiler from Compiler can be downloaded from 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
Install dir.png (23.2 KiB) Viewed 816 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.
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 Filesyou 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
Compiler options.png (61.59 KiB) Viewed 816 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
Select batch file.png (46.59 KiB) Viewed 816 times
then open.
Finally Select OK,
You should now be able to compile with the latest XC8 compiler
These users thanked the author medelec35 for the post (total 3):
Steve (Fri May 08, 2020 9:45 am) • kersing (Sat May 09, 2020 8:58 am) • Dirk Bubley (Sun May 10, 2020 8:48 am)
Rating: 15%
 
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

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

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

Postby Dirk Bubley » Sun May 10, 2020 8:46 am

Many thanks Martin for the explanation. :D


BR

Dirk

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8817
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2559 times
Been thanked: 3715 times
Contact:

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

Postby medelec35 » Sun May 10, 2020 12:41 pm

Hi Dirk,
you're welcome.

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

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

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

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

Postby Dirk Bubley » Mon May 11, 2020 4:03 pm

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
These users thanked the author Dirk Bubley for the post:
medelec35 (Mon May 11, 2020 6:47 pm)
Rating: 5%
 

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8817
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2559 times
Been thanked: 3715 times
Contact:

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

Postby medelec35 » Mon May 11, 2020 6:47 pm

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

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

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

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

Postby Dirk Bubley » Mon May 11, 2020 8:00 pm

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

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8817
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2559 times
Been thanked: 3715 times
Contact:

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

Postby medelec35 » Mon May 11, 2020 8:21 pm

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

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

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

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

Postby Dirk Bubley » Sat May 30, 2020 8:51 am

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

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8817
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2559 times
Been thanked: 3715 times
Contact:

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

Postby medelec35 » Sat May 30, 2020 11:43 am

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

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

User avatar
Steve
Matrix Staff
Posts: 3148
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 104 times
Been thanked: 413 times
Contact:

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

Postby Steve » Mon Jun 01, 2020 8:55 am

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.
These users thanked the author Steve for the post:
medelec35 (Mon Jun 01, 2020 9:38 am)
Rating: 5%