new SystemConvert V1.40

Coding and general discussion relating to the compiler

Moderators: David Barker, Jerry Messina

Post Reply
Jerry Messina
Swordfish Developer
Posts: 1469
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

new SystemConvert V1.40

Post by Jerry Messina » Thu Jan 12, 2017 3:02 pm

I've updated SystemConvert V1.40 to add the option of generating register bit definition files.

If enabled, a new file will be generated with the name 'P18Fxxxx.bas' to match the corresponding device file.
The bit names are defined as a const matching the register bit number and are taken from the asm .inc file.

You can't use the names directly (ie INTCON.GIE) so you'd normally use them with the '.bits()' or '.booleans()' qualifiers like so:

Code: Select all

device=18F26K22

include "P18F26K22.bas"        // include the reg bit definition file

INTCON.bits(GIE) = 0
T0CON.booleans(TMR0ON) = true

// or in other statements like
error_mask = (1<<OERR) + (1<<FERR)
Some things to watch out for:
- There are a lot of duplicate bit names in the asm files and the program will only generate a definition for the first one it sees. It's a good idea to make sure it's the right bit number. Since they're just constants there's no way to check that the bitname is actually valid for the register... that's up to you!
- The bit names don't always match up very well with what's in the datasheet. You may want to generate the files one time and adjust it to match your liking.

There are far too many files/definitions for me to test so if you run across a file that causes problems or has errors please post it here so I can try to fix the generator. You may find names that clash with other common symbols or reserved words... who knows.

Jerry Messina
Swordfish Developer
Posts: 1469
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

Re: new SystemConvert V1.40

Post by Jerry Messina » Sat Apr 15, 2017 2:44 pm

I recently ran across another snag in using the bitname files.

I used the asm .inc files as the source of information for the SFR names and bits, and there are a lot of common names used in those files.
You may end up with conflicts for existing names.

For example, with the 18F45K50:

Code: Select all

device = 18F45K50

// include the bitname file
include "P18F45K50.bas"

// some configs that conflict
config
    BOREN = ON,
    CCP2MX = RB3,        // CCP2 is RB3
    T3CMX = RC0          // T3CKI is RC0 (default)
Will get you a number of "Invalid option" errors since the bitname file defines 'ON', 'RB3', and 'RC0'.

To work around this you can either:
- include the P18xxxxx.bas bitname file AFTER the config statements
or (probably better)
- put the config statements into their own module and just include that in your main program. That way the order isn't as important.

config.bas:

Code: Select all

module config_registers
config
    BOREN = ON,
    CCP2MX = RB3,        // CCP2 is RB3
    T3CMX = RC0          // T3CKI is RC0 (default)
end module
main program:

Code: Select all

device = 18F45K50

include "P18F45K50.bas"
include "config.bas"
The asm .inc files have a number of issues such as SFR and bit names that don't match what's in the datasheet.
I'm going to look around and see if there's a better source of the info in the mplabx files, but so far I haven't found any.

bitfogav
Registered User
Registered User
Posts: 169
Joined: Sat Oct 09, 2010 1:39 pm
Location: United Kingdom

Re: new SystemConvert V1.40

Post by bitfogav » Mon Apr 17, 2017 10:04 am

Thank you for the update and info Jerry.

Jerry Messina
Swordfish Developer
Posts: 1469
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

Re: new SystemConvert V1.40

Post by Jerry Messina » Mon Apr 17, 2017 10:27 am

There was a post I made yesterday that seems to have disappeared.

Anyway, just to recap from the now missing post, I found the source of mplabx device information. It's located in the java file mplab_ide\mplablibs\modules\ext\crownking.edc.jar.

In that file there's a folder \content\edc\18xxxx that contains .PIC files for the 18F series (which are really just .xml files).
These files have a ton of info... memory layout, config settings, SFR registers and bits, pinouts, etc. These seem to be the source of the asm .inc file definitions since they have some of the same "bogus" register and bit names as the asm files do.

It looks like the info is arranged better as it is appears to be sectioned off into "real names" that match the datasheet and "alias names" for legacy support. Still looking at it to try and figure out the structure.

Jerry Messina
Swordfish Developer
Posts: 1469
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

Re: new SystemConvert V1.40

Post by Jerry Messina » Wed Apr 19, 2017 12:41 am

In case anyone's interested, it seems the xml .PIC files used by mplabx are pretty similar to what was used for mplab.
The mplab .PIC files can be found in the various .zip files in the MPLAB IDE\Device folder.

MPLAB didn't use them directly... there was a python script 'pic2dev.py' that generated the .dev files used by mplab from the .PIC files.
Unfortunately, that python script doesn't seem to be available.

If it were you could generate .dev files from the mplabx .PIC files for use by tools like the UMCbuilder.

Jerry Messina
Swordfish Developer
Posts: 1469
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

Re: new SystemConvert V1.40

Post by Jerry Messina » Sun Apr 23, 2017 2:29 pm

I'm just posting this as FYI and so I can find it again...

After digging around a bit it seems that all of this info comes from the mplabx-sdk, which is available for download on the site http://www.opensource4pic.org

The database is in the "crownking" edc (from mchip - "edc" stands for essential device characteristics. It is an XML-based language for describing a Microchip devices).
The individual device files are stored with a .PIC file extension but they're really .xml files.
The sdk has some documentation on the edc and java tools for working with the database. Unfortunately there's also a number of references to python scripts and none of them seem to be available.

The mplabx files are just a copy of the sdk edc files, and they release a new sdk for each mplabx version.
Mplabx keeps all of the .PIC files inside of a java .jar container (mplab_ide\mplablibs\modules\ext\crownking.edc.jar), which you can view with most zip utilities like 7z

Post Reply