Literally Bits

The new version of the MPLAB C32 (v1.05) compiler is out and is filled with new features and a new (as in additional) DSP library designed for compatibility with the dsPIC standard DSP lib. But for me the most exciting piece of news is that “binary” is back.

One of the simplest extensions to the ANSI C standard  offered on all previous Microchip compilers was the ability to define and use binary literals using the “0b” prefix. Example:

int x = 0b000100011;     // instead of 0x23

Now you can use the binary notation with the MPLAB C32 compiler too.

I have to admit, when you are working with 32-bit  long literals, binary could get a bit … tyring, but if you are like me, with a ton of PIC18 and PIC24 code to use and re-use, it sure comes handy…

Posted in PIC32, Tips and Tricks | Comments Off on Literally Bits

Using the 32-bit Core Timer

One of the features of the PIC32 that I have so far somewhat left out in my “explorations” is the 32-bit Core Timer. This is in fact a piece of the MIPS M4K core itself and is common to all MIPS processors. This makes it a very popular item in typical MIPS literature, but from the PIC32 perspective (and in particular my 8-bitter perspective) this is an odd element that I decided not to focus on. And I don’t mean “odd” in a bad way, it just does not find an equivalent in the traditional Microchip architectures, where all timers are numbered and there is a long legacy and compatibility trail for each one of them. The Core Timer is in fact pretty useful and here I would like to illustrate the most obvious use we have for it… Continue reading

Posted in PIC32, Tips and Tricks | Comments Off on Using the 32-bit Core Timer

Testing the PIC32 I/O Speed

In the last several months I have seen a couple of postings on the PIC32 forum about users testing the speed of the PIC32 I/O. It is quite normal and healthy for a community of Embedded Control designers to worry about the actual I/O performance of a microcontroller, and even more so when the microcontroller in question claims to be able to operate all its peripherals (I/O pins included) at the same (top) speed of the core: 80MHz!

With such capability and thanks to the special Atomic I/O operations (PORTINV), the theory says that a PIC32 could produce a 40MHz output square wave!

This performance is quite unique among competing microcontrollers (they typically achieve 1/2 the processor top speed), but we have to admit it can be tricky to prove. Here is what I recommend you do to get as close to the theoretical limit as possible… Continue reading

Posted in PIC32, Tips and Tricks | 2 Comments

UNISON – A POSIX compliant RTOS for the PIC32

Recently I get a lot of questions about Linux on the PIC32….

No, Linux is not available. The main problem is the lack of a true MMU (Memory Management Unit, the PIC32 has only an FMT, fixed mapping table), and most importantly there is not enough memory. Even the tiniest of the tiny (micro/nano…) Linux kernels is 600k bytes compressed. Decompress it first in a couple of megabytes of RAM, than add a couple more to give it room to work, and … game over!

The good news is that most of the requests are coming from developers that are really interested in re-using Open Source code more than running a true Linux system in miniature. Besides, most of them are looking for real time operation, something Linux was never meant to deliver.

As I mentioned in the previous posts, the open source code re-use is actually the easy part, using the MPLAB C32 compiler (a derivative of the GNU gcc) we have inherited a solid GNU compatible set of C libraries. If the project you want to use does not require calls to the OS kernel, and most embedded code would not,  then 90% of the problem is already solved. Just download the project, include all the source files in MPLAB and hit F10 (Make).

But sometimes we need a little more help. Sometimes it would be really nice to have a complete RTOS, and a POSIX compliant one, so that we can re-use code that does rely on “some” Linux kernel calls. In those cases they tell me, you might want to take a look at UNISON from the guys at ROWEBOTS.

UNISON

The Unison SoC RTOS is available for the PIC32 providing a feature set based on Linux and POSIX in a tiny tiny space… Check it out and let me know!

Posted in PIC32 | Tagged , | Comments Off on UNISON – A POSIX compliant RTOS for the PIC32

Tremor

Xiph.Org

The Xiph.Org Foundation offers an open source alternative to the omni-present MP3 audio compression: it is called Ogg Vorbis and promises same if not better performance but it is royalty-free and license free. From their web site, like in all open source project you can download the full C source code for all the tools you need to convert and play back Ogg Vorbis files/streams on most operating systems

Like most open source projects, the code is based on the assumption that you will use the classic GNU Toolchain: gcc compiler, linker, standard GNU libraries, to compile and link your application. Now as you might know the PIC32 toolchain happens to be GNU compatible … Continue reading

Posted in PIC32 | Tagged , | Comments Off on Tremor

Merry Christmas and Happy New Year

I guess we all wait for the Christmas holidays to recover from a long year of hard work, enjoy some more time with family and friends and prepare for the new year at the doors. As I am writing this, it’s real cold and snowy outside, just like in the typical Christmas stories, and I find that this is just the perfect time (after dinner and when the kids are in bed) to … write some fun embedded applications!

I had meant for a while to post some additional projects for those of you who have read the books and tried out (prototyped) the projects using the published schematics or assembling  the AV16/32 kits, but I never got to it.

So, finally ..here they are!  I have just added a new page to the PIC32 explorers’ web site dedicated to the first six new projects.

New Projects

More will be coming shortly… hope you’ll have fun!

Posted in AV16/32, PIC32, Tips and Tricks | Comments Off on Merry Christmas and Happy New Year

Bending the laws of physics

As a reader pointed out today, when preparing one of the pictures in Chapter 3,  I did use a little trick, I had almost forgotten…

hello.GIF

I did reduce the DELAY constants by a factor of 100 to … speed things up … so to speak. Otherwise the Logic Analyzer window would not be able to contain all the samples required to produce the complete “Hello” message.

I do these things quite a bit when I use the Simulator … Continue reading

Posted in Tips and Tricks | Comments Off on Bending the laws of physics

Electronica 2008

This is the week of the Electronica 2008 in Munich (Germany) and I am available at the Microchip booth (A4-560) all week to talk about 16 and 32-bit programming but especially about flying!

If you are a PIC24 or a PIC32 pilot, don’t forget to pass by and say hello!

No secret handshakes required, just ask of Lucio…

Posted in PIC32 | Tagged | Comments Off on Electronica 2008

Deep Blue PIC32

An email from Tim O. this week made me think about the possibility of computers conversing with humans, or rather the impossibility of it, as Turing once proposed it as the ultimate test of the machine intelligence.  This in turn made me think about another story that made the news a few years ago (1997) when IBMs Deep Blue computer won a historical match against the (back then) world chess champion Garry Kasparov.

Continue reading

Posted in PIC32 | Comments Off on Deep Blue PIC32

MIPS DSP Libraries

With the latest release of MPLAB C32 compiler v.1.04, Microchip has added a complete set of DSP functions for the PIC32 to complement the standard math libraries. Among them you will find a number of vector processing functions and as expected several different types of FFT functions. You will remember that in Chapter 7, in order to give the PIC32 some work to do while we were playing wit the cache and pre-fetch mechanism to find the optimal performance tuning, we used a FFT function. That was a simple “schoolbook” implementation of the basic algorithm in C.

If you try the new DSP library, don’t be too surprised if you discover that the speed of execution is increased by orders of magnitude. In fact the libraries are written for fractional numbers (16 and 32-bit fixed point numbers)  as most DSP algorithms do, and were hand optimized (large portions were written in assembly) by MIPS experts to obtain the maximum performance from the PIC32 instruction set.

Posted in PIC32, Tools | 2 Comments