Should you notice a
conflict between my narration and the official Microchip documentation, ALWAYS refer to
the latter. However please send me an email if a conflict arises. I will publish any correction and useful hint I will receive on
this web site, your help is appreciated!
1- When I try to execute the example code from chapter 1 thru 3 on the Explorer16 board I notice that not all the LEDs are working properly. Do I have a defective demonstration board?
Most probably there is nothing wrong with your board. In MPLAB check the configuration bits settings and make sure that they match those recommended in the Pilot Checklist "Device Configuration for the Explorer16 demonstration board". In particular look out for the JTAG port option to be "Disabled" (this should be MPLAB default setting anyway). When enabled, the JTAG port takes control of 4 pins of PORTA (RA5, RA4, RA1, RA0) effectively depriving you of half the string of LEDs.
2- I just finished reading chapter 13 and I am comparing the listing present in the book with the corresponding code in the included CDROM. It appears that the function readSECTOR() has changed. Which version should I use?
Don't worry, both versions are fully functional and correct. As soon as you will reach chapter 15 the differences will be explained. The rule wants that only in the last chapter the identity of the killer is revealed!
ERRATA
Page 62: replace
bits 3, 4 and 5 of the status register (SR)
with:
bits 5, 6 and 7 of the status register (SR)
Page 100 and page 101: inside function iReadNVM() and iWriteNVM() the while loop waiting for any work in progress to be completed is checking the content of the memory SR register bits WEN and WIP, but only WIP matters (in fact WEP will be set only later and only in the write function). Replace:
while ( ReadSR() & 0x3) ; // check the two LSb WEN and WIP
with:
while ( ReadSR() & 0x1); // check WIP
Page 111: at the bottom of the page a tab is missing, the last define should read:
#define TRTS TRISFbits.TRISF13 // Tris control for RTS pin
Page 114: at the top of the page inside the function getU2(), the RTS signal is de-asserted after the function return, making the code un-reacheable. The last two lines must be swapped as in:
...
RTS = 1; // de-assert RTS
return U2RXREG; // read the character from the receive buffer
} // getU2
Page 145: in step 4 of the readAD() function example the conversion is started by setting the DONE bit. This is incorrect (old PIC habit) as in the PIC24 the conversion is started by clearing the SAMP bit. Use instead:
AD1CON1bits.SAMP = 0; // 4. Start the conversion
Page 183 and following: the Polling I/O method is described as using the RG15 input pin for the PS2 data line. This code has eventually been modified to use pin RG13 instead to simplify the development of the AV16 board. Note that the Tips and Tricks section (page 198) makes already reference to the new and correct pin selection.
Page 271: at the top of the page inside the function initMedia() both in part 4. and part 5. when de-selecting the SD card after each command (RESET and INIT) replace SDCS = 1; with the macro disableSD() previously defined (page 269), example:
r = sendSDCmd( RESET, 0); disableSD();
This has been already corrected in the code available on the CDROM.
Page 279: the following lines of code:
// verify each block content
if ( !memcmp( data, buffer, B_SIZE))
should read:
// verify each block content
if ( memcmp( data, buffer, B_SIZE))
otherwise a mismatch would be reported incorrectly when in fact a perfect match is found.
MPLAB C30 v3.00 MIGRATION
With the release of the new version 3.00 of the MPLAB C30 compiler I am receiving reports from various readers of a few migration issues being identified. Some of these issues are due to enhancements to the compiler and new features being added, other are related to an update of the device specific include files (p24fj128ga010.h).
With your help, I will try to document them and offer available work arounds/fixes.
Chapter 5: The _IP bit field, part of the SR register, has been renamed _IPL.
In file "interrupt.c" replace line 53:
_IP = 0; // this is the default value anyway
With:_IPL = 0; // this is the default value anyway
Or comment the line out (0 is the default value at power on)
Also a warning related to the "auto_psw" attribute of the interrupt service routine is now being generated by the compiler. You will learn more about the PSV reading chapter6.
You can safely ignore the warning for now as the default compiler behaviour is safe.
Chapter 9: The PMPEN register has been renamed PMAEN.
This was done to elminate a naming conflict with the PMPEN bit defined within the PMCON register. The name change will hopefully be reflected in the next revision of datasheet.
In file "liquid.c" replace:
PMPEN = 0x0001; // PMA0 enabled
With:
PMAEN = 0x0001; // PMA0 enabled