The AV16/32 Expansion Boards are temporarily out of stock!

The fun part of writing a book on a brand new product is that it is never finished. A new product is just like a living organism. It keeps moving, changing and growing under our eyes. Since I started writing the book in April 2007 many things have changed in the PIC32, its libraries and the tools that support it.

In the following I will try to keep track of the changes that affect the code examples and in general the content of the book so that you will be able to continue using the material presented even when using new versions of the MPLAB IDE, MPLAB C32 compiler and tools.


80 MHz operation!

The first shocking you will have when reading the new Microchip literature (and web site) is that the PIC32 is now rated for 80MHz operation. A 10%+ increase in performance over what was originally announced and above what I used as a reference in all examples in the book.  You are free to modify the configuration bit settings to take advantage of the increased performance available, but remember that some exercises will require additional adjustments to the timings to keep things working.

Example of configuration bit settings for 80MHz operation:


#pragma config POSCMOD=XT, FNOSC=PRIPLL
#pragma config FPLLIDIV=DIV_2, FPLLMUL=MUL_20, FPLLODIV=DIV_1
#pragma config FPBDIV=DIV_2, FWDTEN=OFF, CP=OFF, BWP=OFF


80MHz Peripheral Bus

The second surprise will come when you will realize that now the peripheral bus is allowed to operate at 80MHz as well. This has a profound impact in on the performance of all peripherals. For example the UART modules can now operate at up to 20M baud, and toggling an I/O pin you could actually produce a 40MHz square wave (not that I would recommend it).
As a side effect though, the system.h library has changed behavior with regards to what is now considered the best performance setting! When you invoke the SYSTEMConfigPerformance( FCY) function passing a parameter >40MHz (as we do in the explore.c library used in many examples in the book) the Peripheral Bus divider is now set to 1:1 (whereas previously it was limited to 1:2) modifying the default setting provided by the Configuration Bit settings. In other words, all the peripherals will now be running at twice the speed we originally planned on!
There are several possible alternative fixes:
  • Make sure to restore the OSC_PB_DIV setting immediately after the SYSTEMConfigPerformance() call:
...
SYSTEMConfigPerformance( FCY);
mOSCSetPBDIV( OSC_PB_DIV_2 );
...

  • Use the new SYSTEMConfig( ) function that updates only the features you "approve" and specify in the second parameter:
SYSTEMConfig( FCY, SYS_CFG_WAIT_STATES | SYS_CFG_PCACHE);

  • Create your own custom configuration function using any or all of the steps indicated in the examples of chapter 7. As a side benefit, you get to choose the name of the function! Please submit your ideas, I will publish the most entertaining ones...
  • Modify the examples code to take advantage of the increased Peripheral Bus frequency.
In any case remember to update the FPB and FCY constants defined in explore.h to match your choices.
For example, in the example code of chapter 7, you will need to modify the constant used to scale the timer results to consider the increased bus speed:

...
// read the timer count
t = ReadTimer45();
f = t/80E6;
...

New DMA libraries

Since version 1.03 of the MPLAB C32 compiler, the DMA library has changed a little to improve the interface consistency with the other libraries/modules.
Two modifications are required to keep the examples in the book (chapters 12 and following) working:
  • The parameter DMA_OPEN_NORM, used in the DmaChnOpen() function is renamed  DMA_OPEN_DEFAULT instead
  • The function DmaChnWriteControlFlags() is renamed
    DmaChnSetControlFlags() instead