Lint for checking microchip midrange config register banks? - Page 1
Forum section: electronics / general

author: AussieBruce
author_rank: Regular Contributor
timestamp: November 25, 2024, 07:25:07 am
content: Maybe surprisingly, I'm still developing applications using PIC midrange, in assembler. Yes, I could choose one of the hundreds of other options around, but there are reasons for my choice. Anyway, managing the bank assignments for the config registers is a real pain, and the IDE is no help at all. Whenever you reference a config register anywhere in your code, you need to check whether the current bank assignment aligns with it, and if not insert a BANKSEL statement that will set the bank access flags accordingly. If there is a mismatch, your code simply behaves incorrectly. Is anyone aware of a utility that you can feed your source file to, which will parse for assignment errors? Before I write my own, which shouldn't be too hard.Or is this a function that has appeared in very recent versions of the Microchip IDE? I switched back to a relatively old, 'golden' version after a newer one proved troublesome for me and many other people.

author: Buriedcode
author_rank: Super Contributor
timestamp: November 27, 2024, 05:29:40 pm
content: Are you talking about using the banksel macro? Or a utility that will insert the bank switching into your code when required?I think manually doing this is par for the course for assembly, it's one of the many reasons C compilers existFor the few times I've used assembly - I just explicity select the bank the following register requires, regardless of the current selected bank, and then if I require fast code, optimise it later by going through and removing the ones that are unecessary. For the most part you end up remembering what registers are in what bank after a while so you don't need to keep referring to the datasheet.I have to say I do not miss those days at all.

author: jpanhalt
author_rank: Super Contributor
timestamp: November 27, 2024, 05:51:16 pm
content: From context, I believe the TS is referring to banksel as a macro with the IDEI also do Assembly, and when I see code with almost every register reference preceded by banksel, I think someone is either lazy or using a disassembly or decompile from C. I use 80 columns and put the bank address, e.g., "; <space or comment>|B0" at the end of the line whenever it might be relevant. That is, not Bank0 in long sections of code. I sometimes use use banksel and still add that comment as a help to anyone who is crazy enough to read my code. Otherwise, I use movlb.Needless to say, you soon know where the most frequently used regusters are, but I keep a cheat sheet handy. Since PORT, TRIS and LAT all have the same offset but are in different banks (enhanced midrange), someone on the Microchip PIC forum commented about changing the bank but not the name as being useful. I thought that would be a vane attempt to confuse, but you could do it.

author: Lindley
author_rank: Regular Contributor
timestamp: November 27, 2024, 08:17:47 pm
content: Assume you are refering to the older mid range Pics where the SFRegisters are spread over several memory Banks.Have you considered looking for a suitable chip from the Pic18F range or the newer Pic16F chips which have a better memory layout, basically all the SFR in one dedicated Bank and a lot more usable GPR before you need to change Banks