~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Firmware Update
- April 18, 2012
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
in this issue
-- Is (uint16_t) -1 Portable C Code?
-- The Future of Embedded Software Development
-- Final Days to Register for May 2012 Boot Camp
-- Reader Q&A - Mixing Mutexes and Interrupts
-- Industry News You Can Use

Firmware Update is a free newsletter by embedded guru Michael Barr. This issue is Copyright 2012 by Barr Group, but may be reprinted for non-commercial purposes. Please forward it to colleagues who may benefit from the information.


Is (uint16_t) -1 Portable C Code?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Twice, recently, I've run across third-party middleware that included a statement of the form:

uint16_t variable = (uint16_t) -1;

which I take as the author's clever way of coding:

0xFFFF

I'm not naturally inclined to like the obfuscation, but wondered if (uint16_t) -1 is even portable C code? And, supposing it is portable, is there some advantage I don't know about that suggests using that form over the hex literal? In the process of researching these issues, I learned a helpful fact or two worth sharing.

But first, is the result of "(uint16_t) -1″ guaranteed (by the ISO C standard) to be 0xFFFF?

Find out...


The Future of Embedded Software Development
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In many ways, the story of my career as an embedded software developer is intertwined with the history of the magazine Embedded Systems Design. Unfortunately, due to changes in the publishing industry, the last issue is being printed as I write this.

Reflecting back on the days when I first found a copy on a colleague's desk helps me see that a lot has changed about embedded software design in the past twenty years. And caused me to wonder what does the future hold for us? I see three big trends that will affect us all over those timeframes, each of which has already begun to unfold.

See into the future...


Final Days to Register for May 2012 Boot Camp
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In just a few weeks, Barr Group's popular one-week hands-on Embedded Software Boot Camp skills strengthening program is coming to Washington-Baltimore. For more details and to register, please visit our website. But do hurry because there are just four more spaces left in the room and only a few more early registration days as well.

Don't miss out...


Reader Q&A - Mixing Mutexes and Interrupts
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I recently received this question from Harshal:

I have a doubt in my mind since a long time regarding semaphore in interrupt handler in Linux. Can we use semaphore in interrupt handler? What if semaphore not available can handler block?

I believe you are asking about acquiring a mutex from within an ISR. To be certain we are on the same page about the type of semaphore, first read this: Mutexes and Semaphores Demystified.

On the assumption you are asking about mutex calls made within interrupt handlers, the answer is simple: NO. An ISR has no way to "block" to wait for the mutex to become available.

If you insist on sharing global data areas between an ISR and a task you will need to disable at least that interrupt in the associated task(s). But there are better ways of sharing such data, such as having the ISR put the new data into a message queue.

Submit your question...


Industry News You Can Use
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Many implanted medical devices are vulnerable to hacks that could threaten the lives of their wearers. BBC: http://t.co/EgN16sul

Fisker recalls electric cars again, due to a software glitch. Article: http://t.co/UxTRiL7Z

Why are you still using C? http://t.co/p9S3xzpV

Help VDC analyze the embedded, RTOS and tools market by taking their annual survey. Get $10. Link: http://t.co/a1W05QZL

How a felt-tipped pen saved the Apollo 11 mission. Fascinating: http://t.co/dUDZvnWl

Blind man "drives" Google's autonomous car. Video: http://t.co/e2OLIzIx #want

Seussification of Turing's proof of the undecidability of the halting problem. Fun: http://t.co/fKUW7sbf

PDF of the first issue (dated 1988) of Embedded Systems Programming magazine: http://t.co/uQUuGFKc Most ads are from vendors long gone.

More stuff like this...


Quick Links
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  • Embedded C Coding Standard
  • Embedded Systems Training in a Box
  • Free Embedded Systems Article Library
  • Blogs by Embedded Gurus


  • Contact Information
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    phone: 866.65.EMBED
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~