Author Topic: Lint for checking microchip midrange config register banks?  (Read 1046 times)

0 Members and 1 Guest are viewing this topic.

Offline AussieBruceTopic starter

  • Regular Contributor
  • *
  • Posts: 67
  • Country: au
Lint for checking microchip midrange config register banks?
« on: November 25, 2024, 07:25:07 am »
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.
 

Offline Buriedcode

  • Super Contributor
  • ***
  • Posts: 1718
  • Country: gb
Re: Lint for checking microchip midrange config register banks?
« Reply #1 on: November 27, 2024, 05:29:40 pm »
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 exist :)

For 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.
 

Offline jpanhalt

  • Super Contributor
  • ***
  • Posts: 4011
  • Country: us
Re: Lint for checking microchip midrange config register banks?
« Reply #2 on: November 27, 2024, 05:51:16 pm »
From context, I believe the TS is referring to banksel as a macro with the IDE

I 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.
 

Offline Lindley

  • Regular Contributor
  • *
  • Posts: 211
  • Country: gb
Re: Lint for checking microchip midrange config register banks?
« Reply #3 on: November 27, 2024, 08:17:47 pm »
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

 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf