Archive for the PIC24 Category

Donate to Wikipedia

I am not ashamed to admit that I love and use a lot Wikipedia. It is fast, convenient and gets most of the technical stuff I typically look up right to the level I can understand and use it. But perhaps most importantly, it is one of the few places on the internet without advertising!

This is something I truly appreciate and I am willing to pay, so every year I do give a small contribution (just USD 10) to keep it like that!

Jimmy Wales wrote:

<<< Google might have close to a million servers. Yahoo has something like 13,000 staff. We have 679 servers and 95 staff.

Wikipedia is the #5 site on the web and serves 470 million different people every month – with billions of page views.

Commerce is fine. Advertising is not evil. But it doesn’t belong here. Not in Wikipedia. Wikipedia is something special. It is like a library or a public park. It is like a temple for the mind. It is a place we can all go to think, to learn, to share our knowledge with others. >>>

Donate!

Yoda Conditions, Egyptian brackets and more…

 Yoda Conditions

I just stumbled upon this excellent blog post.

Enjoy…

More Multimedia Boards

It’s about time for an update on the latest and greatest demo boards for the PIC24 and PIC32.

MikroElektronika has been busy in the last year cranking out new demo boards almost every quarter. While I was happily playing with their very first MultiMedia Board the PIC32MX4 based MMB,

MikroE MMB

they introduced a PIC32MX7 version (adding Ethernet connectivity)

PIC32MX7 MMB

and shortly after that a “microMMB” version with the MX4 processor:

PIC32MX4 uMMB

so small that it barely gives you room for four screws around the display to fix it to a panel.

These boards are great to experiment with the Microchip Application Library (MAL) and in particular with  all things graphics, touch, audio and USB. But they are also ready for being mounted in your embedded control application and to became it’s user interface if not the brain.

I wrote a lot of code for them and I intend to share it and document it gradually in the coming weeks to show you how to get the basic functionality (user interfaces) but also to show you things that many believe would only be possible with much more expensive and complex systems.

You can get a glimpse of it on the new page of the Exploring PIC32  web site dedicated to the Multimedia boards and the Multimedia demo projects.  I am so fond of them, that I have decided to   help MikroElektronika re-sell them and to provide documentation and support on this blog and on my two companion web sites.

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 !!!

Searching for a Pin in a Haystack

There is one problem I have with the current style used in the PIC24 and PIC32 datasheets, it has to do with the way the pin out of the device is presented. Since so many functions are multiplexed on each pin, I find myself constantly checking for potential conflicts when choosing carefully my GP I/Os. The pin-out table is designed to list alphabetically all the individual options and determine the pin number, but then how do you cross check for other functions with the same number?

As I did before for the PIC24, I have created a convenient Excel spreadsheet and filled it with the PIC32MX3xx pinout table info: PIC32MX3xx pinout

Now you can sort the pins by name, by pin number (in different packages) or by group/peripheral.

As an added bonus it was easy to include the information about the pin usage by the Explore16 board and the various PICTail boards available (including the AV16/32 of course).

I hope you’ll find it useful…

P.S. Should you find any error or omission, please make sure to report it to me…

Inexplicably Working Errata

A few days ago, I received an email from a reader who reported a new errata on page 123 (in the “Learning to fly the PIC24″ book) in the write() function, an example of redirecting the “stdout” output stream.

The function receives a pointer to a buffer containing characters that need to be forwarded to the output device of choice and a counter. A loop is performed to print sequentially the required number of characters, but (here is the bug) I apparently omitted to increment the buffer pointer.  To the reader’s greatest surprise the code example seems to work anyway! How is this possible?

Read the rest of this entry »

Back online, Excuses and the Blues Brothers

It has been almost three full months since my last posting and you might have been wondering what happened … I have only a few excuses, but good ones:

  1. I moved back to the old continent, I am now writing this from Munich, Germany
  2. I changed job (a bit), while still working for Microchip, I am now responsible for the marketing of 32-bit microcontrollers in Europe, Middle East and Africa. This of course requires quite a bit of traveling.
  3. But perhaps the most important one is my new “project”, my son Luca, who is now 10 months old and absorbing ALL that is left of my wake time.

In this last few months I have received tons of email, (I love emails from my readers) and tried to respond to most of them. Some of you have been reporting about typos in the books and/or issues with new versions of the compilers and libraries. Others have brought up interesting ideas and questions that I plan on using in the future postings. Slowly, I will try to cover all the backlog and get back live.

Stay tuned!

P.S.: For those among you who are old enough to remember the Blues Brothers movie, here is Jake’s (Jim Belushi) original list of excuses:

  1. I ran outta gas.
  2. I had a flat tire.
  3. I didn’t have enough money for cab fare.
  4. My tux didn’t come back from the cleaners.
  5. An old friend came in from outta town.
  6. Someone stole my car.
  7. There was an earthquake,
  8. … a terrible flood,
  9. …locust’s.
  10. It wasn’t my fault!!

Modifying and Testing the code for the new GA1 and GB1 families

I have received a lot of request recently from readers, future PIC24 pilots, concerning the possibility to port the code from the book to the the newest families of PIC24 microcontrollers. The differences are not that big, but I have to be honest, I spent a lot of time recently “playing” with the PIC32 and I just did not have the time to go through the painstaking process of modifying all the code examples and testing them on the new GA1 and GB1 families. I have always encouraged you (my readers) to share the code (in the book and CDROM) and to modify it freely in your applications, but I also encourage you to share any enhancement that could be useful to the community.

Wayne Duquaine, an experienced programmer I had corresponded with a few times in the last few months, has followed this suggestions and recently, after working with an AV16 kit for a few weeks, he has surprised me with a long email where he has listed the code and all the results of his extensive experimentations with the new GA1 and GB1 PIMs and the MPLAB C30 compiler v.3.02.

I decided to post his code and his “scorecard” on the PIC24 web site  in the main download page with a link to his email address (he has agreed to share) with the understanding that he will be willing to provide support answering your emails on a time permitting basis. Wayne is a busy professional that travels often abroad for extensive periods of time. So I am sure you will be patient and you will appreciate any (personal) time he will be willing to dedicate to you.

Thanks Wayne!

Now, has anybody been playing/modifying the code for the PIC24H families recently?

How about  the little guys: GA004 and GA002?

Chapter 5 Excercises

The exercises assigned in Chapter 5 are actually quite advanced and are mostly meant to give you ideas of the kind of powerful things you can do in C using interrupts (and simple state machines). The following chapters, in particular in the third part of the book, will cover several such examples. The NTSC composite video generator (Exercise 5.3) is well described in Chapter 12, but you will be able to find the solution to the other two exercises in other (perhaps unexpected) places.

Excercise 5.2 is perhaps my favourite as you will find an example of (interrupt based) radio receiving routines (for a very special protocol) in the code attached to application note AN745, available for download as part of the vast collection of application notes available on Microchip’s web site.

Check the “rxi.c” module in particular. The code was written to be compatible with the HiTech C  compiler and the CCS compiler for the PIC16  architecture, but you should find it easy to port for the PIC24 and compile it with MPLAB C30.

The solution to Exercise 5.1 is not going to be very dissimilar…

More on Chapter 5 Tips and Tricks and builtin functions

If after yesterday’s posting you though things were getting ugly (I agree), you will be pleased to learn that since the introduction of MPLAB C30 v3.02 things have improved considerably. After all, performing the unlock sequences should not be an “impossible” task in C requiring super advanced inline assembly programming skills!

Four new builtin functions of the compiler come to our rescue:

  • __builtin_write_RTCWEN( void)
  • __builtin_write_NVM( void);
  • __builtin_write_OSCCONL( unsigned char value);
  • __builtin_write_OSCCONH( unsigned char value);

[Note: a double underscore preceeds each function name]
They give us complete access to the RCFGCAL, NVM and OSCCON control registers by performing the proper unlock sequences.

You will find a complete (long) list of builtin functions well documented in Appendix B of the MPLAB C30 compiler.