Recently, I found myself in a bit of a tiz-woz, up to my armpits in alligators fighting fires without a paddle, as it were (I never metaphor I didn’t like).
For reasons too convoluted to delve into here, I find myself in charge of maintaining and enhancing code whose function I am not at liberty to discuss for a project whose purpose I may not disclose for a company whose name must remain unspoken … but I fear I’ve said too much.
Just for giggles and grins, this code is presented in assembly language targeted at PIC microcontrollers from Microchip Technology. There are many great things to be said about PICs, including the fact that they are low-cost, low-power, and they come in a tremendous variety of shapes and sizes with myriad combinations of internal resources, such as counters, timers, capture/compare and pulse-width modulation (PWM) modules, analog-to-digital converters (ADCs), interface functions, and… the list goes on.
Then there’s the fact that Microchip offers these microcontrollers in both DIL (dual in-line) – also known as dual in-line package (DIP) – and SMT (surface-mount technology) packages, and they continue to support devices from years gone by. They also offer a rich collection of tools and resources, all of which explains why they’ve sold countless billions of these little rascals.
On the bright side, I’ve worked with a variety of assembly languages over the years. On the downside, I’ve never had the joy of working with PICs. Happily, the guys and gals at Microchip love documenting things, so I just got back from a trip to my local Staples where they kindly printed and bound the 279-page PDF of the data book associated with one of the devices I am to support.
With respect to the assembly source files I’ve inherited; these little scamps were originally crafted deep in the mists of time by someone using Microchip’s MPLAB integrated development environment (IDE) in conjunction with the MPASM assembler.
In the case of MPLAB, I’m assuming that “MP” stands for “Microchip PIC” and “LAB” stands for “Laboratory,” but I’m not 100% sure. I found one reference that says MPLAB is short for “Make Programs Like A Boss,” but I’m guessing that’s a joke (if you know anything about this, I’d love to hear about it).
You can only imagine my surprise and delight to discover that both the MPLAB IDE and MPASM have been discontinued and replaced with new versions that are bigger, better, and brighter, and that also keep your teeth clean and help you to sleep at night. From what I can glean from the interweb, the final release of the MPLAB IDE was version 8.92 in 2013. This was eventually replaced with the MPLAB X IDE, whose latest version, 6.0, hit the streets on 3 January 2022, which is just a couple of months ago as I pen these words. (I read somewhere that the ‘X’ stands for “eXperimental,” which sends a little shiver down my spine, but this may well be a joke also.)
The person who bequeathed this code to me (a.k.a. dumped this code on me) told me that when the MPASM assembler was discontinued (I subsequently discovered that support for MPASM was removed in MPLAB X 5.40), it was replaced with a new assembler called ASPIC. The last thing he said to me before he scampered out of the door was, “I have no idea if my MPASM source code assembles properly under ASPIC and have no desire to find out.” I think this might have been followed by a fading mad cackle (generally speaking, a fading mad cackle is much to be preferred over one that is getting louder, which would imply the cackler is approaching). Alternatively, I may have been hearing a future echo of myself.
As I’ve mentioned before on numerous occasions, I’m a hardware design engineer by trade, so I can easily end up baffled and bewildered by the esoteric practices of sneaky software developers. Thus, once I’d dried my tears, I reached out to the chaps and chapesses at Microchip with a plaintive plea for help.
What can I say? These masters of the mystic arts responded to my plea with the offer of a video conference call to sort everything out. It turns out they have archives of every development tool they ever created since the dawn of time.
It didn’t take long for them to track down and have me install MPLAB X IDE v5.20, which comes equipped with MPASM. Then I shared my screen, and they walked me through the process of assembling one of my assembly source files to prove everything worked.
It’s amazing how much easier it is to wrap your brain around this sort of thing when you have someone looking over your shoulder (or staring out of your computer screen at you, as the case may be).
All I can say is that I now regard the team at Microchip as being like the brothers I never had (of course I do have a brother, Andrew, and I love him dearly, but he’s a lawyer and of no use whatsoever when it comes to topics of a technical nature — the guys at Microchip are the like brothers I don’t have, if you see what I mean).
I hope you are being paid a significant amount!
I will agree that Microchip have one of the better tech support departments in the industry. But having said that, I find the early PIC processors (PIC 16CXX) difficult to work with. Admittedly I come from a CISC processor background, but after 4 projects, I swore off Microchip processors and it even extended to the different architecture 17FXXX devices.
one project was implemented with a device (I think it was the PIC 16C73 (today it is a 16F73) ) with 4K of PROM and 192 bytes of RAM and programmed in assembler using MPLAB. (The PIC is a 14 bit processor.) About 2 years later the customer added features and asked for the same program to be extended. That needed an expanded processor with 8K of PROM and 368 bytes of RAM. Even though I had written the program I found it very difficult to understand my code. Neither the RAM or the PROM is a linear space. There are multiple banks of RAM and multiple pages of PROM and it was really complicated to work the additional memory requirements into the existing code. Debugging a second time was a nightmare, between all the bank/page switching and trying the decipher the code (and I believe my code was reasonably commented).
i never managed to figure out the instruction testing the carry bit. I simply put the a test of the bit and the stepped through the code to see if it matched my intention, and if it didn’t I changed the code.
Although Microchip has been very good in continuing production of old devices, that is not the case with their In Circuit Emulators, which I found went obsolete fairly quickly. I had to develop code to cater for a 10MHz processor, because of limitations of the ICE and then modify it for 20MH z operation.
Hi Aubrey — learning these little scamps does seem to be a bit of a task, but once you’ve done so, it’s amazing what you can do with them. I will have more to talk on this shortly…
I have a vague recollection of doing some PIC Assembly language programming many years ago. You have my condolences.
On the other hand, it’s good to know that Microchip provides such good support.
I am tremendously impressed with the folks at Microchip — I just wish my poor old brain were 40 years younger 🙂
“I just wish my poor old brain were 40 years younger https://s.w.org/images/core/emoji/13.1.0/svg/1f642.svg”
Aye, there’s the rub! I have just as many ideas as when I was younger, just bringing them to fruition is that much harder…. 😪
I have been to one Microchip seminar and was very impressed with their products and support. Microchip look after AVR as well now I think?
That’s right — AVR microcontrollers were developed by Atmel starting in 1996, they were used in the first Arduinos (Nano, Uno, Mega…) starting circa 2005, and Atmel was acquired by Microchip in 2016.
Please ask your friends at microchip to reduce prices on the 8bit offerings.It has gone through the stratosphere. I am porting many of my products to other micro famiglias. I hope they are not doing what Philips/NXP/(whatever they call themselves) did to move 8051 users to ARM7.
Actually, I have a call scheduled with the for this coming week so I will ask them then — but with the countless billions of PICs they’ve sold and the countless billions to come, I doubt they are trying to push their customers to ARM — Max