FAQs
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
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!Page 43: In the little snippet of code at the top of the page, I used the hexadecimal notation:
i = 0x1234; j = 0x5678;
but later on, you will notice in the disassembly listing, I used the decimal notation instead:
i = 1234; j = 5678;
that explains the literal values #0x4d2 and #0x162e found in the following lines.
Page 55: The first paragraph refers to Table 5-1a and Table 5-1b.
Refer to Table 5-1 (on page 56) and Table 5-2 (on page 57) instead.
Page 58: If you are using the MPLAB C compiler for PIC24 v3.00 or later, refer to the Updates page to read about changes to the PIC24 library that require a small change in the code examples of chapter 5.
Page 95: Figure 7-7 caption should read:
Figure 7-7. The complete Read Data command timing sequence.
the picture should probably be moved to page 99 where the Data Read command is discussed
Page 123: In the function write(), replace the line:
putU2( *(char*)buffer);
with
putU2( *(char*)buffer++);
Page 133: If you are using the MPLAB C compiler for PIC24 v3.00 or later, refer to the Updates page to read about changes to the PIC24 library that require a small change in the code example.
Page 143: The definition of AINPUTS, the analog configuration mask, is incorrect:
#define AINPUTS 0xffef
should be replaced with:
#define AINPUTS 0xffcf
so that both POT and TEMP inputs can be sensed.
Page 179: The PS2STOP case listing (at the top of the page) should read:
case PS2STOP:
if ( PS2DAT) // verify stop bit
{
KBDCode = KBDBuf; // save the key code in mail box
KBDReady = 1; // set flag, key code available
}
PS2State = PS2START;
break;
The code included in the book CDROM is correct.
Page 216: In function synchV(), replace the line:
while ( VCount != 1);
with
while ( VState != 1);
Page 268: In function sendSDCmd(), replace the line:
writeSPI( ( unsigned char) a>>24); // msb of the address
with
writeSPI( a>>24); // msb of the address
The code included in the book CDROM is correct.
Page 279: In the code segment at the top of the page replace:
{ // mismatch
PORTA = 0xff;
with
{ // mismatch
PORTA = 0x55;
The code contained in the book CDROM is correct.
Page 332: Figure 15-4: incorrectly represents the Input Compare register contents. Please refer to Register 13-1 found on page 117 of the PIC24 Family Reference manual (DS39747D)
The following Errata have already been corrected in the second print
(March 2007):
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();
Also in the following line:
if ( r) break;
should read instead:
if ( !r) break;
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.