News:

;) This forum is the property of Proton software developers

Main Menu

Need a Bit Name (BNF file) - you can probably find what you want here.

Started by Stephen Moss, May 29, 2022, 03:34 PM

Previous topic - Next topic

Stephen Moss

Hello everyone,
a few years ago I wrote a program to generate some BNF files for devices that did not have any using the files available with Microchips' MPLAB IDE.
I recently had to make changes to my software when looking to produce BNF files for newer devices supported by Positron as only the MPLABX IDE had files for newer devices and the file formats were different to those previously used.
Unfortunately, there does not appear to be any standard in regard to what information is placed where in the source files used and so whether or not register names or BitNames have descriptions is rather random, with most only having BitNames, but no BitName descriptions.
I did consider tyring to re-write it along the lines of that produced by Harm, using the device datasheets as a source for both the bit names and descriptions, but it looked like it would take a lot of time, plus the style of the datasheets appears to have changed (I find the new style harder to read) which would complicate things.

There are some differences between my BNF files and those few that supplied with Positron, although the diffence to not appear to affect the BNF viewers in either the Mechanique or Positron Studio IDE which appear to show the BitNams as expected. The diffenreces are as follows...
1) File Header
Original File Header: ***BitNames***
My File Header: 'DeviceName, Size in bits, i.e. 16F73, 8
Reason: Anyone writing a BFN viewer could use the size to determine if the viewer needs to configure itself for an 8 or 16 bit display and maybe use the device name as a heading.

2) Register Header:
Original File: No Header
My Files: 'RegisterName, Description (if any), size in registers
Reason: RegisterName and description could be used as a header, size determines how many row/tabs of data need to be displayed. Usually the size would be 1, but where joined registers (as Microchip files refer to them) are concered it could be 2 (for 16 or 32 Bit registers) or 3 (for 24 or 48 bit registers)

If you are not sure what is meant by a joined register then consider a timer register that can be configured as either 8 or 16 bit. When used as an 8 bit register it only used a single register, i.e. TMR1L, but when configured as 16 bit it uses two 8bit regisers joined together, i.e. TMR1L & TMR1H.
In this example my BNF files would contain 3 registers for TMR1...
TMR1 - this is the joined register, address is the same as TMR1L and would presumably be used for reading/writing 16bit data.
TMR1L - this contains the entire data if configured as 8bit or the Low byte if configured as 16 bits and used for reading/writing the low byte only.
TMR1H - this contains the High byte when configured as 16bit adn used for reading/writing the high byte only.

In my BFN files the order for joined registers is always...
Joined Register
Low Byte/Word register
High Byte/Word register
Upper Byte/Word register, for 24/48 bit joined register, i.e TMR1U

Note: The BitNames for joined registers are likely to be RegisterName.0, RegisterName.1 and so on, thus if writing a BNF viewer you are likely to get more information by retrieving the BitName data from the individual registers as on 24/48 bit registers not all bits are used and that is often more apparent if retrieving the BitNames from the individual registers.

3) Active Low bits:
For active low bits the BNF files supplied with Positron use NOT as a prefix, as in NOT_PD, my files retains the Microchip format of a lowercase N ("n") as in nPD to match the datasheet and appends "(n, 0 = True)" to the bit description as a reminder.

4) Clashes with Keywords:
Where Bitnames have the same name as Positron Keywords they have been appended with an underscore to stop the compiler throwing errors, i.e. TO becomes TO_

You can download them from here, as you will see they have been broken down to several zip files for different device stem names so that you don't have to download all 1000+ of them unless you really want to.

No Further Updates:
It us highly unlikely that I will produce any futher BNF updates for two reasons...
1) It would mean having to keep the thousends of files of MPLABX is comprised clogging up my hard drive, which is wasteful as I do not use MPLABX for anything.
2) There were/are plans for Positron Studio to obtain the BitNames from the device files already suppled with Positron. That seems a more elegant solution to me as you would not need to keep an lot of BNF files and more importantly everytime as new device is supported the register BitNames would be instantly available, no waiting around for someone to generate a BNF file.   

JohnB

At present Positron Studio recognises the bit names as defined in the .def files for each MPU. The bit name viewer needs to be updated to use these bit names. The drawback is that the .def files do not carry any descriptive text but as Stephen says they will automatically updated with compiler updates.

I will try and get the bitname viewer updated for the next release which will also include a serial communicator supporting both ASCII and hex modes.
JohnB

Peter Truman

OMG! - looking at the BNF file for the 18F2525 (which is very similar to the 18F25K22 - but not the same)

It's bewildering! I thought it might be useful to copy this BNF then work through the differences but, since I don't really know what I'm doing I can see I would just get into all sorts of trouble.

Can I ask if the compiler uses the BNF file or is it only for guidance in the IDE? If that were the case It might still be worth copying, with a note reminding me to check the datasheet each time I refer to it?


RGV250

Hi Peter,
It is purely for guidance and if the file exists I beleive you can enter the bit into your code directly from the tool. I used to use it when I first started out but as you say, the issue is maintaining it unless you had some sort of tool as Stephen wrote which still appears to be a lot of work. If like me you only use a few devices you will get along fine without it, just have a beer and look through the datasheet which is more fun.

Bob

Stephen Moss

Quote from: Peter Truman on Jun 19, 2023, 11:14 PMIt's bewildering! I thought it might be useful to copy this BNF then work through the differences but, since I don't really know what I'm doing I can see I would just get into all sorts of trouble.
The format is is quite simple, i.e.
'ANSELC (PORTC analog select bits) bit definitions:, 1  = Register Name & Description defining start of register data (you can ignore everything after the colon that is for possible viewer usage)
ANSC2=ANSELC.2,"RC2 analog select "                     = Data for each register bit which brakes down as follows...
|     |         |_ Bit Name description, can be helpful in the viewer if you want to identify specific bits to add rather then the entire register but is optional
|     |_ RegisterName and bit number within the register that the associate Bit Name refers to
|_ The BitName Alias used for the register bit, and subsequently within you code when you want to read/write it. Theoretically you can use any name you want but it is will probably be better and less confusing to stick with that from the datasheet. 

So once added to your code Bit 2 of register ANSELC can then be refer to as ANSC2.

Whereas register that just contain data, such as Timers and ADC result rather then bit that perform specific functions can either be ignored only need a description, i.e...
'TMR1H bit definitions:, 1
TMR1H="TMR1 High Byte bits (see datasheet)"


And you do not need to alter the entire file if you do not want to, just those bits/registers you want to use. Just don't forget to make a backup of any file new file you make/alterations to existing files in case it gets overwritten/deleted at some point.