On reference code - Embedded.com

On reference code

Frequent correspondent Charles Manning sent a link to a question on Nordic Semiconductor’s site. The entire question, verbatim, is “What BLE profile would suit a ECG signal best and is there any example code for ADC in to that profile? Have searched for a while and cant (sic) find any.”

Charles – and I – were stunned. Someone is building a critical bit of medical equipment with what appears to be limited knowledge of the communications protocol they’ll use. He is also planning to build this upon vendor-supplied reference code.

It’s probably unfair to read too much into this question, despite the possibly-chilling repercussions for users. I don’t want to knock the forums; they are a great way of sharing knowledge. Pre-Internet we all pretty much had to figure things out on our own, which was terribly inefficient. I can remember flying to vendors’ facilities to talk to chip designers to get the inside scoop on some poorly-documented or broken bit of functionality.

And, believe me, I’m all for reuse, and think it’s really our only hope of salvation as systems get bigger and more complex.

But reference code is notoriously-buggy and incomplete. It’s usually meant to show a developer how to use chip features. Most experienced developers have scars from episodes of figuring out just why some of this code doesn’t work. Some of it is simply ghastly. Charles uses a Nordic part and claims their code is a cut above the rest but is still just reference code.

The person who phrased this question may be an extremely competent developer who will analyze the code before using it. But this is a symptom of two problems with the industry today.

The first is the aforementioned often-crummy quality of vendor-supplied code. In some cases it’s so bad a semiconductor company will put a large team of their own engineers into a customer site to help get a product to market. Of course, this only happens for those buying enormous numbers of chips so the little folks, or even those buying hundreds of thousands, are stuck.

In some cases I know that the work these engineers do never makes it back into the reference code supplied to everyone else. There’s never time to address any issue other than the immediate crisis, so doing an update is out of the question.

One has to have some sympathy for the vendors; after all, their mission is to sell chips. Reference code is free and therefore perceived as a loss leader. The stuff has to exist to push silicon out the door, but never gets the attention it needs. Modern MCUs are really complex. Even the bus fabric can baffle. Peripherals run in innumerable modes. Hundreds or even thousands of registers have to be set exactly right. Datasheets run 500, 1000 or more pages today. Reference software really can’t address every mode and configuration. The cost to develop this stuff is enormous, the price is zero.

The second problem is the perennial issue of time to market. Customers simply don’t have the time to figure out the nuances of handling all of these peripherals so rightly want solid code they can drop their applications on top of. Reusable reference code is a solution. If this were a perfect world, reuse would be at the object code level, all of the reused code would be qualified, and customers would have complete confidence in the code.

One wonders with the explosion of IoT devices coming our way if this problem will only get worse.

Unfortunately, there’s a subtle meta-problem as well. Suppose a semiconductor vendor builds reference code that is absolutely perfect. No bugs, brilliantly documented and a testament to fine software engineering practices. Who would believe them? Decades of problems has create a general distrust. How would a vendor convince the skeptical that, now, for sure, they have produced what we really want?

When it comes to reuse it pays to think about the pyramids. They were built on incredibly strong foundations. In the firmware world, all too often that’s inverted.

What is your experience with reference code?

Jack G. Ganssle is a lecturer and consultant on embedded developmentissues. He conducts seminars on embedded systems and helps companieswith their embedded challenges, and works as an expert witness onembedded issues. Contact him at . His website is.

Join over 2,000 technical professionals and embedded systems hardware, software, and firmware developers at ESC Boston May 6-7, 2015, and learn about the latest techniques and tips for reducing time, cost, and complexity in the development process.

Passes for the ESC Boston 2015 Technical Conference are available at the conference's official site, with discounted advance pricing until May 1, 2015. Make sure to follow updates about ESC Boston's other talks, programs, and announcements via the Destination ESC blog on Embedded.com and social media accounts Twitter, Facebook, LinkedIn, and Google+.

The Embedded Systems Conference, EE Times, and Embedded.com are owned by UBM Canon.

13 thoughts on “On reference code

  1. “At least reference code is open source and you can fix it. What I really hate are closed source blobs from vendors. Several times now I have found bugs in these that vendor doesn't want to fix. That is just an awful position to be in – the vendor doesn't

    Log in to Reply
  2. “Jack;nn”Unfortunately, thereu2019s a subtle meta-problem as well. Suppose a semiconductor vendor builds reference code that is absolutely perfect. No bugs, brilliantly documented and a testament to fine software engineering practices. Who would believ

    Log in to Reply
  3. “Don't assume the reference code is open source. They have different licenses and actually using it in a production application can be banned in their terms. Because you have the source does not mean it is open source.nI have seen some WiFi chip code that

    Log in to Reply
  4. “Related to reference code are the fancy GUI programs for configuring peripherals “with a few cicks of the mouse”. Personally, I feel that such programs are suitable only for college students. It is worth the time to dig in the manual to *understand* e

    Log in to Reply
  5. “Reference/demo code can certainly be so appalling as to qualify as a source of humor… A sick sort of humor, granted, but comedy nonetheless.nnWorse perhaps are the pre-supplied libraries, which are often ludicrously inefficient; the “convenience”

    Log in to Reply
  6. “”What BLE profile would suit a ECG signal best and is there any example code for ADC in to that profile?”nnThis question would probably not be shocking if it were posted on an internal message board viewed only by employees of the same engineering gro

    Log in to Reply
  7. “It isn't mentioned above, but Nordic's nRF51822 has a 10-bit ADC which isn't very useful for ECG due to low resolution. In our work with clients to develop similar products we used an external 12-bit ADC. So you may be led to believe that the person has l

    Log in to Reply
  8. “It is not uncommon for “traditional” companies in India to seek design files (including the gerbers AND firmware) from semiconductor companies as well as distributors by offering 50,000x or more products to be produced, and then go to market with that!

    Log in to Reply
  9. “I could have written this article in a couple of sentences:nnGood firmware costs a lot of money. It's an inescapable fact.”

    Log in to Reply
  10. “Unless you are born with all information pre-loaded in your head, or learn through osmosis by placing information under your pillow at night there is a process by which you learn, isn't there? From the article it appears that this question is TOO much un-

    Log in to Reply
  11. “Is Embedded.com moderated? I have constantly seen abuse by spammers. Blocking URL posting from recently registered users could help, though I am not sure it is feasible (in a simple way, I mean).”

    Log in to Reply
  12. “This doesn't seem to be spam for me, it is most likely a targeted message by the corrupted corporate psychopaths. nnI am recording all these messages as I am getting targeted by the brutal corporate psychopaths for the last decade. nnMy sincere reques

    Log in to Reply

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.