Enabling the PIC24 library collection from Mississippi State Uni and Reese Micro for the new PIC24HJ256GP610A PIM

For those that use the Explorer 16 board and have in the last 12 or so months purchased the PIC24HJ256GP610 PIM from Microchip (part number MA240012) may have noticed it’s got a different chip on it. It now uses the PIC24HJ256GP610A which has some issues when using the library included with the book Microcontrollers: From Assembly Language to C Using the PIC24 Family.

This article shows how I modified the library (12 Apr 2011 version) from http://www.ece.msstate.edu/courses/ece3724/main_pic24/labs/files/pic24_code_examples.zip

In lib\common\pic24_configbits.c at about line 261 fine the line that contains

#if defined(EXPLORER16_100P) && defined(__PIC24HJ256GP610__)

and change it to

#if defined(EXPLORER16_100P) && (defined(__PIC24HJ256GP610__) || defined(__PIC24HJ256GP610A__))

In lib\include\pic24_ports.h at about line 700 you will find the following:

00700 #elif defined(__PIC24HJ256GP610__)
00701
00702 #include "devices/pic24hj256gp610_ports.h"

Change line 700 to:

#elif defined((__PIC24HJ256GP610__) || defined(__PIC24HJ256GP610A__))

The above uses the same .h file for the 610A as for the 610 on the assumption the two are pin compatible in every way. I have not yet found they are not, or any other reason to use a seperate ports file for the chip.

In lib\include\pic24_chip.h at aprox line 336 you will find the following little block of code:

#ifdef __PIC24HJ256GP610__
#define DEV_ID 0x00007B
#define DEV_ID_STR "PIC24HJ256GP610"
#endif

#if (defined(__PIC24HJ64GP206__) || defined(__PIC24HJ64GP210__) || defined(__PIC24HJ64GP506__)
|| defined(__PIC24HJ64GP510__)\
|| defined(__PIC24HJ128GP206__) || defined(__PIC24HJ128GP210__) || defined(__PIC24HJ128GP306__)\
|| defined(__PIC24HJ128GP310__) || defined(__PIC24HJ128GP506__)|| defined(__PIC24HJ128GP510__)\
|| defined(__PIC24HJ256GP206__) || defined(__PIC24HJ256GP210__)|| defined(__PIC24HJ256GP610__))

#define EXPECTED_REVISION1 0x003002
#define EXPECTED_REVISION1_STR "A2"
#define EXPECTED_REVISION2 0x003004
#define EXPECTED_REVISION2_STR "A3"
#define EXPECTED_REVISION3 0x003040
#define EXPECTED_REVISION3_STR "A4"
#endif

Replace this block of code above with:

#ifdef __PIC24HJ256GP610__
#define DEV_ID 0x00007B
#define DEV_ID_STR "PIC24HJ256GP610"
#endif

#ifdef __PIC24HJ256GP610A__
#define DEV_ID 0x0000077B
#define DEV_ID_STR "PIC24HJ256GP610A"
#endif

#if (defined(__PIC24HJ64GP206__) || defined(__PIC24HJ64GP210__) || defined(__PIC24HJ64GP506__)\
|| defined(__PIC24HJ64GP510__)\
|| defined(__PIC24HJ128GP206__) || defined(__PIC24HJ128GP210__) || defined(__PIC24HJ128GP306__)\
|| defined(__PIC24HJ128GP310__) || defined(__PIC24HJ128GP506__)|| defined(__PIC24HJ128GP510__)\
|| defined(__PIC24HJ256GP206__) || defined(__PIC24HJ256GP210__)|| defined(__PIC24HJ256GP610__))
#define EXPECTED_REVISION1 0x003002
#define EXPECTED_REVISION1_STR "A2"
#define EXPECTED_REVISION2 0x003004
#define EXPECTED_REVISION2_STR "A3"
#define EXPECTED_REVISION3 0x003040
#define EXPECTED_REVISION3_STR "A4"
#endif

#if defined(__PIC24HJ256GP610A__)
#define EXPECTED_REVISION1 0x003003
#define EXPECTED_REVISION1_STR "A1"
#endif

I’m not sure what the second last line #define EXPECTED_REVISION1_STR “A1” should be and have not been able to find it, but the above has been tested using the reset.c example from chapter 8 of the book on the Explorer 16 and is working (provided you have also performed the mod described in this article).

This will update the library to accommodate for the new version of the PIC24HJ256GP610 PIM which now uses a PIC24HJ256GP610A.