Wednesday, 11 September 2019

Code & Legibility...


So.. As part of working on the Pic chips, I’ve been working on code based on the info in the datasheet* ready for when the new programmer arrives.


Just a simple thing to get the basics for generating the signal for the Arcturus emitters.

Actually, just setting it up to generate a single pulse width modulated signal, and calculations aside,
it’s actually fairly straightforward to do.



I’ve also been doing the same thing with the Microchip Code Configurator** to compare the code.  And I’ll admit, that based on the experience with the code configurator that it’s easy to setup the various bits & bobs of the chip with it.


HOWEVER it does not generate particularly easy to read code – For example, setting up a Pulse width modulated signal –
Takes a couple dozen lines of code if you include  the initial chip setup commands. Easy enough to read and comment.
The code configurator generated 12 FILES with a little bit of code in each – 6 source files and 6 header files. An absolute nightmare to read and make sense of as it’s jumping around through files in what feels like a totally unnecessary manner.

 

For me, that’s a HUGE negative as pretty much the first thing that was hammered in when I started coding way back was to make the code as understandable and easy to read as possible. And There have been many times I’ve been into code that is just horrible. Bad comments or no comments even less documentation and generally just a nightmare to work with.

 

So yeah…. That’s a thing that happened. And given that I plan to release it open source, legibility and ease of understanding is far  more important that saving a little time by using a wizard.

 

 

* I swear for a microcontroller datasheet is a misnomer. 500 pages is a tad more than a sheet if you ask me…

** Microchip code configurator or MCC is essentially a wizard to generate ready to use code tailored for the chip and desired settings.

No comments:

Post a Comment