Archive for the Books Category

PIC32 Interrupt Nesting (update)

The more recent versions of the MPLAB C32 compiler (v1.6 and later) have changed the way interrupt nesting is defined by default by making it automatically Enabled!
The effect of this change is that of making part of the “nesting.c” example (pages 97-98 of the PIC32 book) irrelevant if not a bit misleading.
Since nesting is always automatically enabled upon entry in an ISR, using the “asm( ei)” command (or commenting it out) produces always the same result: TMR3 interrupt preempts the TMR2 ISR (while(1) loop).

From this point though the simulation will not proceed as described at step 9 (page 97 and following) but the interrupt will keep occurring continuously preventing the execution to proceed through the next few instruction and up to the increment of the counter.

In fact the nested interrupt will fail to update the IPL register with the proper TMR3 interrupt priority level (IPL3 in our example), continuing to use the IPL1 value instead as defined in the __ISR macro.
This behavior could not be observed with the original compiler setting (nesting disabled by default) because the “EI” instruction was delayed until after the entire interrupt ISR prologue, giving the processor time to reach the breakpoint if only barely.

A new macro “__ISR_SINGLE()” has been introduced to handle properly such cases. At the cost of a slightly longer prologue, each ISR entry will now make sure to set the correct corresponding Interrupt Priority Level.

I posted this comment today in the Update section of the ExploringpPIC32 site and a note was made in the Errata list.Thanks to Jean, Bruce, Skyler and Geoff for point out the issue!

Real World Instrumentation with Python

 There is a new book on my nightstand, and it is one of the best I have read in years: it is called “Real World Instrumentation with Python” by J.M. Hughes, published by O’Reilly!Less than a month ago I was readying about Ruby. Then one thing got to another and I followed a friend’s suggestion to look into Python instead. Read a lot about it mostly online, then again, I strolling through a bookstore last Saturday and I stumbled onto a copy of this new book (published this past November 2010).  I am amazed by the amount of information packed in so few pages and how smooth and fast it reads. I am now a big Python fan, it’s official, but an even bigger fan of J.M. Hughes.

Learning Ruby

Browsing through those large book stores, of the kind and size you can find only in the US, is one of my favorite pastimes.

I can loose myself in there for entire afternoons just letting the eye fly (wink) over the shelves and picking out the catchiest titles. My favorite section is of course the technology and programming one, and my first pass is often spent looking for the red spine and Newnes logo, just to make sure they do have  copies of my books available. Too often they don’t, which I like to think is a sign of how successful my books are, they must literally fly (wink wink) off the shelves!

But for the last couple of years I have been attracted by books on Ruby, a very trendy programming language, although I never really ended up buying one or getting to dig deeper into the subject. I had this notion that Ruby was just for web site designers and there was little else for me there. Eventually, this Christmas I gave in and bought a copy of “Learning Ruby” written by Michael Fitzgerald and published by O’Reilly.

I choose it (among the many other Ruby’s books) because it promised to be very compact (about 200 pages) and based on a lot of practical examples, which is definitely my idea of the way books should be. Ok mine are thicker, but I promise, the next one will be shorter.

Fact is, I ended up liking this book a lot. I read it all in a single flight (from S. Francisco to Munich) and it gave me the sort of fever I sometimes get when something new gets my neurons all fired up at once!

Of course somebody has already started playing with the concept of porting Ruby to the embedded control world, with the RAD project (somehow it does not surprise me that this was done first on an Arduino platform, the A in RAD).

While I am not yet sure of the results and their application to the average embedded control project, I learned that “modern” interpreted languages are nothing like (bad) old MS-Basic. There are so many powerful concepts, such as reflections, duck typing, and multi-paradigm support to mention a few, that are worth exploring and considering carefully when trading performance (abundant in modern processors) with ease of development and code maintenance.

What is your opinion on interpreted vs. compiled in embedded control?

Merry Christmas and Happy Free RTOS

It is Christmas, again, not sure how this happened …

Of all my ambitious plans for  2009 only a few got done, but looking back I am pretty sure somebody must have stolen a couple of months from this years’ calendar. I will be more careful next year, won’t let it happen again.

I have been reading more about RTOSes recently, and specifically FreeRTOS:

freertos-book.GIF

My new year resolution: Learn to use (Free)RTOS to give better structure to my projects and practice the art of programming as the real pros!

Happy Holidays !!!

MicroC/OS II

I finally got my hands around “the book” on Real Time Operating Systems.

uC/OS ii

Read it all in a couple of days… I loved the clarity and completeness.

Highly, highly recommended! Definitely added to my “favorites” bookshelf !

|