Jump to content

Recommended Posts

I am starting to use CCS and C more, Energia less.  Currently I'm taking a TI workshop that tends to use driverlib rather than more more direct access to the registers.  I notice that a lot (most I guess) code on 43oh accesses the registers directly.  TI touts readability as the reason to use driverlib.  It is bound to add some overhead.  It is supposed to aid portability among TI products.


I'm trying to develop good programming habits.  How do others feel about using driverlib?

Link to post
Share on other sites

The more complicated the peripheral the more likely it is that I use driverlib.


On MSP430 I don't use it all for I/O. In my opinion the upside is also very marginal for timer, SPI, UART and other basic peripherals. To make sense of the driverlib API, I usually have to look at the registers in the datasheet (or rather the very readable user's guide) anyways, at which point I just as well twiddle the few bits myself. Clock configuration and USB are my main uses for driverlib on MSP430 so far.


ARM is a whole other story, as setting up even basic peripherals, including I/O, commonly requires multiple steps, even more so when interrupts are involved. I.e. reading the datasheet takes more time than figuring out the driverlib API. It also helps that ARM systems are usually not as memory constrained, so fiddling with bits to save a few bytes is rarerly worth the effort.



Link to post
Share on other sites

I think that you should go into the driverlib. I mean, it's faster to develop, some errors are avoided, easier to read, some portability (well, the registers are pretty much the same on the MSP430s).

Note that I am more of an ARM fan. I always use driver libs, As it was said, there is a ton of memory and power even in the lowest end ARM-Ms. So why bother with registers most of the time? As an ARM user I usually don't recommend, even discourage register programming - you have to know how to handle yourself with the registers when needed of course.

Now of course don't lose notion of the lower level, it's important to get a better code, to know how to later search and apply missing features on the driverlib. And sometimes you just need some extra performance.

Also, as @@chicken, I check the datasheet register from time to time to make sense of some things. Of course the descriptions on the datasheet also refer to the registers. But that is just when the API documentation is lacking some info.

Link to post
Share on other sites

I believe it's a trade-off and does depend on your application.


On the MSP430 Series I've never used driverlib. Frankly the peripherals are easy enough to understand and use with a few direct accesses to memory mapped IO.

But I have used it on the MSP432 and some PIC32/PIC24 projects. It can speedup development, if it's well documented and you understand the benefits and limitations.


driverlib will generally create more readable code. But does come with an overhead on small MCUs for example toggling a pin on an arduino using digitalWrite( !digitalRead(PIN)) yeilds terrible performance. (orders of magnitude slower than direct access.) But does that matter for you? Again, depends on the application.


The lines are blurred when moving to more powerful processors (ARM). Where the CPU is separated from the IO via buses, directly modifying a memory mapped IO is not as fast. and typically driverlib make use of bit-banded memory areas which if you were to use directly would make for some really unreadable/non-portable code.



For any new project now I would use driverlib, identify possible areas that may casue performance limitations. (eg SW UART/SPI/I2C bit-banged lib) and alter then to use direct IO.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...