SystemConvert
Intro
The Swordfish compiler has two requirements in order to generate code for a device - the device must be supported by the MPASMX assembler, and there must be a device *.bas include file (ie '18F26K22.bas') that contains a description of the various device parameters, such as memory and register addresses, supported peripherals, and configuration settings.
Adding support for new devices to Swordfish can be done using the InfoGen and SystemConvert utility programs.
These utilities require the MPLABX DFP (Device Family Pack) edc *.PIC files. The InfoGen utility will create the '8bit_device.info' database file required by the MPASMX assembler, and SystemConvert will use that file along with other information in the DFP .PIC files to create the Swordfish device .bas files.
Download SystemConvert V2.10 Tools (7z format)
Device Family Pack (DFP) files
If you've installed MPLABX, the MPLABX Device Family Pack files can be found in two locations on your computer: the System Packs Location which contains DFPs distributed/installed during the MPLAB X IDE installation, located at:
and the User Packs Location which contains all DFPs which have been installed through the MPLABX Pack Manager "Update" mechanism or manually installed by the user:
The User Packs location typically contains the most recent files. You can find more information about DFP files from the Microchip Developer Help site at https: //www.microchipdeveloper.com/xcc:introduction-to-dfps
InfoGen and SystemConvert can use DFP files from any of the following locations:
You can download and use the latest pack files without installing MPLABX. They are available from the Microchip packs repository currently located at https: //packs.download.microchip.com/ To create a custom folder you will need the following device family packs:
The pack download files have an '.atpack' extension and contain the pack name and version, for example 'Microchip.PIC18F-Q_DFP.1.21.411.atpack'. These are actually zip files and can be opened using a zip utility such as 7-zip (https: //www.7-zip.org/). Download the four required .atpack files and save them to a folder.
When you open the .atpack file with 7z you will see various files and folders. You will need the *.PIC files in the 'edc' folder to create the Swordfish files, so to save space you can extract just the 'edc' folder and its contents and ignore the others. Create a folder to hold the extracted edc folder/files (for example here I've used 'C:\mplabx_packs'), and under that folder add a 'Microchip' folder. Then, under that add folders for each of the four DFP packs and version. Using 7z drag each of the atpack 'edc' folders along with their *.PIC files, placing them under the DFP version folders.
You should end up with a directory structure similar to the following:
mplabx dfp folder structure
The DFP folder names and version numbers shown here were taken from each of the respective .atpack file names. You can have multiple versions under each DFP pack folder and the utility programs will automatically select the latest (highest version number) folder when it creates the required support files.
- mplabx_dfp_packs_09072024.7z - MPLABX v6.15 DFP files (current as of 13 SEPT 2024)
Installing the programs
Using 7z, extract the InfoGen and SystemConvert program .exe and .ini files into a folder of your choice. The programs will create the output files in this folder so you must have write access permissions.
Using InfoGen
InfoGen Utility
Now that you have all the required files, the next step is to use InfoGen to create the '8bit_device.info' file used by the MPASMX assembler. InfoGen will scan the DFP pack folders, and for each 18F *.PIC file found add the device to the .info database. The assembler executable file mpasmx.exe itself is never changed... it's the same exe file as that from MPLABX 5.35 (mpasmx 5.87), which was the last version of MPLABX to include MPASMX. InfoGen will create a customized version of '8bit_device.info' that has support for 18F devices only.
InfoGen.ini contains commands and settings that can be customized on an individual device basis if required. These settings fix several errors in the edc files to produce a version of the .info file for the PIC18F family that is compatible with mpasmx.exe. In most cases the standard settings in InfoGen.ini should be acceptable.
The ini file also contains some general entries that you may wish to change such as the MPASMX version, resource file version, output filename, etc. Version info can be set in the [program] section of the ini file under these two keys:
Run InfoGen.exe. Select the location of the MPLABX DFP pack files using the 'Change Folder...' button, and click 'Generate'. The program should run showing its progress in the output window. When completed you will get a message such as 'done. 0 error(s), 36 warning(s)'. There should be no errors, but it is typical to get a number of warnings as the program processes the settings in the .ini file and applies changes/fixes.
By default, InfoGen will create a 'Bin' folder in the installed directory and place the output files '8bit_device.info' and '_devices.txt' there. If the 'Create log file' checkbox is checked it will also create an infogen.log text file that contains the output window contents which you should review. If acceptable, copy the contents of the 'Bin' folder to the Swordfish 'Bin' folder.
InfoGen Generate screen
Using SystemConvert
SystemConvert Utility
To generate the device .bas files, SystemConvert will require the MPLABX DFP pack files, along with the updated MPASMX '8bit_device.info' file produced by InfoGen.
The program uses entries in SystemConvert.ini to allow adding or changing any additional settings for a device/family that may be required, such as adding a default config setting. There are four ini file sections that contain commands, and they are processed in the following order: a [global] section which applies to all devices, an optional [xv18] section that applies to all xv18 devices, an optional [device_family] wildcard section (ie '[18FxxK22]'), and a specific device section (ie '[18F26K22]') for each device in the ini file.
When generating files for a new device you should edit the ini file and add a [device] section for it. There are are at least two entries that should be added to the new [device] section... the ADC number of channels and resolution, as this information cannot be obtained automatically from the .PIC files.
For example, the ini file section for the 18F16Q41 contains the following:
[18F16Q41]
1="#const _adc = 17 // 17 ADC channels"
2="#const _adres = 12 // 12-bit ADC resolution"
3="config MVECEN = OFF"
Here, '#const _adc' sets the number of ADC channels, and '#const _adres' sets the number of bits/resolution. There is a config setting specified ('config MVECEN = OFF'), so that will be added to the device .bas file as well. When adding entries, the ini file key isn't important ('1=','2=',etc) as they will be processed in the order listed, but the key must be unique. The key value portion will be copied to the .bas file just as it appears in the .ini file, excluding the quote chars.
After modifying SystemConvert.ini to add the new device, run SystemConvert.exe Select the locations of the MPASMX .info and MPLABX DFP pack files using their respective 'Change Folder...' buttons Select the desired option checkboxes (typically you want them all checked)
Click 'Get Candidates'. This should search the folders specified above and populate the window with a list of the found devices. The status line will show the version of the MPASMX resource .info file and the number of potential devices.
Click 'Convert Files'. This will process the data and create the output device .bas and any other files specified. The files will be placed in sub-folder named 'Includes'
SystemConvert will generate the following folders/files in the 'Includes' program folder:
Copy the newly generated 'Includes' folder and its contents to the Swordfish 'Includes' folder
SystemConvert output