Programming 32-bit Microcontrollers in C

PIC32 Small Cover


The first step in almost every rehabilitation program is:

  • A- Acknowledge … your limitations.

So this is how I need to introduce this book, I will admit it:   I am an 8-bitter!

I have been programming 8-bit microcontrollers since I was in high school and for most of my professional career. And there is worse, while I am relatively fluent in several high level programming languages, I truly love assembly programming!
There, I said it!

I love that kick that I get when I know I used every single machine cycle in every microsecond my embedded applications run.

I am also obsessed with control: I like to know of every configuration bit in every peripheral I use.
So why would I write a book about 32-bit programming in C?

In fact I started what I should call my “rehabilitation program” a couple of years ago by approaching the programming of 16-bit microcontrollers first. The introduction of the PIC24 family of microcontrollers gave me the motivation to try and migrate to C programming with a new and exciting architecture. As a result of my experience, I wrote the first book: “Programming 16-bit microcontrollers in C. Learning to fly the PIC24”.

But by the time the book was published, rumors circulated in Microchip that a new 32-bit chip had just come out of the “ovens” and I had to have one!
I’ll spare you the details of how I got my hands around one of the very first test chips, but what you need to know is that in a matter of days I had most of the code, originally developed for the PIC24 book, ported and running on the PIC32 plugged in my old Explorer16 board.
Microchip marketing folks will tell you that the PIC32 architecture was specifically designed so to make the “migration” from 8-bit and 16-bit PIC architectures smooth and seamless, but I had to see it with my eyes to believe it.
So who better than an assembly-loving, control-obsessed, 8-bitter can tell you about the exploration of the PIC32? 

Who should read this book?

The PIC32 is a remarkably easy to use device, nonetheless this book can only offer a small glimpse into the vast world of 32-bit programming and in fact I call it a first exploration.
It is my strong belief that learning should be fun, and I hope you will have a good time with some of the playful exercises and projects I present throughout each chapter in the book.
However you will need quite some preparation and hard work in order to be able to digest the material I am presenting at a pace that will accelerate rapidly through the first few chapters.
This book is meant for programmers of a basic to intermediate level of experience, but not for “absolute” beginners; so don’t expect me to start with the basics of the binary numbers, the hexadecimal notation or the fundamentals of programming. Although, we will briefly review the basics of C programming as it relates to the applications for the latest generation of general-purpose 32-bit microcontrollers, before moving on to more challenging projects.

What this book is not!

Mind this is not a sequel to the Flying PIC24 book, but rather its alter ego in the 32-bit world. The book walks the reader through most of the same steps and exercises though everything looks similar and different at the same time… The underlying theme is the exploration of a new world and the final objective is that of learning gradually to trust a C compiler (MPLAB C32) and learn to use a new PIC with a brand new (MIPS) 32-bit core!

These are some of the questions I have tried to answer in the book:

  • Does the PIC322 look like a PIC?
  • Does it feel like a PIC?
  • How similar is the PIC32 to the PIC24, really?
  • How fast can you port code from one to the other?
  • Is it easier or harder to use?
  • And most importantly, how much faster does it really run?

You will learn about:

  • Programming in C using the MPLAB C32 compiler (GCC)
  • Basic timing and I/O operation
  • Debugging methods with the MPLAB SIM simulator and ICD tools
  • Multitasking using the PIC32 interrupts
  • New hardware peripherals
  • How to control LCD displays
  • Experimenting with the Explorer16 board and the PIC32 Starter Kit
  • Accessing mass-storage media
  • Generating audio
  • Generating video
  • and more..

Learn more about the AV16/32 PICTail Plus Board

Beside the fun of assembling the expansion board yourself, all you need is a little patience and a basic familiarity with a soldering iron. You will be able to try out all the advanced projects presented in chapter 12 and following of the book.