ConfigGenerator
The ConfigGen utility can be used as an aid in setting the device configuration register settings.
The utility is installed as an IDE plugin (IDE menu Plugin | ConfigGenerator), but can also be run as a standalone program outside the IDE (Swordfish Plugin\ConfigGen\ConfigGen.exe).
Config Generator Software
The software uses the MPASMX '8bit_device.info' file as the source of its information.
The first time you run the program make sure the MPASMX folder setting is pointing to the Swordfish\Bin folder. This should default to the Swordfish installation directory found in the system registry, ie 'Swordfish\bin'. If it is not, use the Change Folder... button to point to the location of the Swordfish copy of the MPASMX '8bit_device.info' file. Click the Load File button. This will open the .info file and build a list of all PIC18 devices contained in it.
Select your desired device from the Device dropdown list and it should display all of the config entries and their default settings.
Clicking the Setting column for a config entry will show a drop-down list with all of the valid selections for that function.
When all config settings have been made, click the Generate button and the program will generate source code with all of your selections (unchecking the Comments box will remove the descriptions and just leave the settings, if desired).
Controls
- Export...
Opens a file select box to save the output window contents to a .bas file, which you can later import or edit.
- Copy to Clipboard
This will copy the output window contents into the Windows clipboard, which you can then paste into your main program file using a text editor or the Swordfish IDE using Edit | Paste (or Ctrl-V).
- Import...
Opens a file select box to allow you to read in the contents of an existing .bas or .txt file. The file will be searched for 'config' statements, and the current Settings will be changed to match. If the file contains a 'device=' statement then the Device selection will be changed to match.
- Import Hex...
Allows you to read the config section from an existing .hex file and updates the Settings to match.
- Set Defaults
This will change all config settings back to default, which will depend on the state of the Use .info Defaults checkbox. If Use .info Defaults is checked then the default settings are taken directly from the '8bit_device.info' file, and if not checked then Set Defaults will use the default values from the ConfigGen.ini file.
Some default settings in the .info file are not compatible with Swordfish, such as XINST=ON and MVECEN=ON. ConfigGen.ini allows you to change these defaults, and typically contains the same settings as used by the SystemConvert device file generator. There are multiple sections in the .ini file, [global] and individual [device] sections. Settings in the [global] section will be applied first (if they are applicatable to your device), after which the individual device section will be processed. When adding support for new devices to ConfigGen you can copy the sections from SystemConvert.ini.
You should place the config section at the beginning of your main program before any 'include' statements, or place the config settings in their own module and 'include' that one first in your main program. That way, the defaults set in the config section can be overridden by any modules included after it... config entries are processed such that the last config setting seen is the one used. Note that this may also override any defaults setup in the device .bas file, so you should check the resulting .asm file output after you compile to ensure your settings are correct (the CONFIG section is at the very end), or use the 'Import Hex...' button to load the hex file. This will also allow you to see if any settings were overridden by other include files, such as intosc.bas.
Importing Config settings from an existing hex file
The Import Hex feature allows you to extract the config settings from a .hex file. Since the hex file does not contain any device information you should first select the appropriate device from the Device dropdown list prior to importing the file.
Using Import Hex..., browse to the hex file and click Open. The hex file data will be processed, a summary of the file will be shown in the output window, and the Settings will be updated to match the config data found in the file. Note that settings in the MPASMX .info database may not cover every value so not all data may produce a valid result. Such is the case where a 'don't care' setting value exists, in which event the default setting will be applied and a warning message issued identifying the setting in question. Setting the ConfigGen.ini entry 'create_log=1' will generate a ConfigGen.log file in the same folder as the application showing all the .info file config data settings for a device.
Here's an example of a hex file imported for an 18F26Q71 device:
loading hex file: E:\_sfmodules\all_devices\all_devices.hex program data (0x0000) size: 58 config data (0x300000) size: 11 config data: 8C FF 75 FF 9F FF FF FF FF FF FF eeprom data (0x380000) size: 8 eeprom data: 10 20 30 40 50 60 70 80 processing config data from hex file... config 300000 FEXTOSC = OFF RSTOSC = HFINTOSC_64MHZ config 300001 CLKOUTEN = OFF PR1WAY = ON BBEN = OFF CSWEN = ON FCMEN = ON FCMENP = ON FCMENS = ON config 300002 MCLRE = EXTMCLR PWRTS = PWRT_64 MVECEN = OFF IVT1WAY = ON LPBOREN = OFF BOREN = ON config 300003 BORV = VBOR_1P9 ZCD = OFF PPS1WAY = ON STVREN = ON LVP = ON DEBUG = OFF XINST = OFF config 300004 WDTCPS = WDTCPS_31 WDTE = OFF config 300005 WDTCWS = WDTCWS_7 WDTCCS = SC config 300006 BBSIZE **no match found for config data setting: 0xFF BBSIZE = BBSIZE_16384 **default setting applied: 0x7F config 300007 SAFSZ = SAFSZ_NONE config 300008 WRTB = OFF WRTC = OFF WRTD = OFF WRTSAF = OFF WRTAPP = OFF config 300009 CPD = OFF config 30000A CP = OFF ** WARNING: 1 value(s) not found... default used