PIC24 Support Libraries
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
pic24_chip.h
Go to the documentation of this file.
1 /*
2  * "Copyright (c) 2008 Robert B. Reese, Bryan A. Jones, J. W. Bruce ("AUTHORS")"
3  * All rights reserved.
4  * (R. Reese, reese_AT_ece.msstate.edu, Mississippi State University)
5  * (B. A. Jones, bjones_AT_ece.msstate.edu, Mississippi State University)
6  * (J. W. Bruce, jwbruce_AT_ece.msstate.edu, Mississippi State University)
7  *
8  * Permission to use, copy, modify, and distribute this software and its
9  * documentation for any purpose, without fee, and without written agreement is
10  * hereby granted, provided that the above copyright notice, the following
11  * two paragraphs and the authors appear in all copies of this software.
12  *
13  * IN NO EVENT SHALL THE "AUTHORS" BE LIABLE TO ANY PARTY FOR
14  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
15  * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE "AUTHORS"
16  * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
17  *
18  * THE "AUTHORS" SPECIFICALLY DISCLAIMS ANY WARRANTIES,
19  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
20  * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
21  * ON AN "AS IS" BASIS, AND THE "AUTHORS" HAS NO OBLIGATION TO
22  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
23  *
24  * Please maintain this header in its entirety when copying/modifying
25  * these files.
26  *
27  *
28  */
29 
30 
31 // Documentation for this file. If the \file tag isn't present,
32 // this file won't be documented.
33 /** \file
34  * This header file includes the correct
35  * processor-specific include file. It also provides
36  * additional processor-specific information, such as
37  * the device ID, revision IDs, and the number of various
38  * peripherals.
39  */
40 
41 #ifndef _PIC24_CHIP_ALL_H_
42 #define _PIC24_CHIP_ALL_H_
43 
44 // Include processor-specific header file
45 #if defined(__PIC24H__)
46 #include "p24Hxxxx.h"
47 #elif defined(__PIC24F__) || defined(__PIC24FK__)
48 #include "p24Fxxxx.h"
49 #elif defined(__dsPIC33F__)
50 #include "p33Fxxxx.h"
51 #elif defined(__PIC24E__)
52 #include "p24Exxxx.h"
53 #elif defined(__dsPIC33E__)
54 #include "p33Exxxx.h"
55 #else
56 #error Unknown processor.
57 #endif
58 
59 #ifdef _ISR
60 #undef _ISR
61 /// Override the standard Microchip ISR definition, since it produces the
62 /// following warning:
63 /// warning: PSV model not specified for '_DefaultInterrupt';
64 /// assuming 'auto_psv' this may affect latency
65 /// This definition adds the auto_psv specifier, which produces
66 /// a bit of extra code but allow accessing constant data
67 /// (data stored in program memory).
68 #define _ISR __attribute__((interrupt)) __attribute__ ((auto_psv))
69 #endif
70 
71 #ifdef _ISRFAST
72 #undef _ISRFAST
73 /// Unlike \ref _ISR, this definition does not allow the ISR to access
74 /// constant data (data stored in program memory). This saves some
75 /// clock cycles. Unlike the Microchip definition, it does NOT use
76 /// shadow registers as well.
77 #define _ISRFAST __attribute__((interrupt)) __attribute__ ((no_auto_psv))
78 #endif
79 
80 
81 /// Place the processor in sleep mode.
82 #define SLEEP() Sleep()
83 
84 /// Place the processor in idle mode.
85 #define IDLE() Idle()
86 
87 /// Clear the watch-dog timer.
88 #define CLRWDT() ClrWdt()
89 
90 /// Insert a one-cycle nop instruction.
91 #define NOP() Nop()
92 
93 /// Enable the watchdog timer.
94 #define ENABLEWDT() (_SWDTEN = 1)
95 
96 /// Disable the watchdog timer.
97 #define DISABLEWDT() (_SWDTEN = 0)
98 
99 /// \name Peripheral identification
100 //@{
101 /** Define the number of UART modules supported by this chip.
102  * NOTE: this only works when testing \#defines, not
103  * testing variable. So, don't test UxSTA; instead,
104  * test _UxRXIF which is uniquely defined for each
105  * UART. (Idea taken from the C30 peripheral library,
106  * in uart.h.)
107  */
108 #if defined(_U4RXIF)
109 #define NUM_UART_MODS 4
110 #elif defined(_U3RXIF)
111 #define NUM_UART_MODS 3
112 #elif defined(_U2RXIF)
113 #define NUM_UART_MODS 2
114 #elif defined(_U1RXIF) || defined(__DOXYGEN__)
115 #define NUM_UART_MODS 1
116 #else
117 #error UxRXIF flag not defined!
118 #endif
119 
120 /** Define the number of I2C modules supported by this chip.
121  * See \ref NUM_UART_MODS for details on this methodology.
122  */
123 #if defined(_SI2C2IF)
124 #define NUM_I2C_MODS 2
125 #elif defined(_SI2C1IF) || defined(__DOXYGEN__)
126 #define NUM_I2C_MODS 1
127 #else
128 #error SI2CxIF flag not defined!
129 #endif
130 
131 /** Define the number of SPI modules supported by this chip.
132  * See \ref NUM_UART_MODS for details on this methodology.
133  */
134 #if defined(_SPI2IF)
135 #define NUM_SPI_MODS 2
136 #elif defined(_SPI1IF) || defined(__DOXYGEN__)
137 #define NUM_SPI_MODS 1
138 #else
139 #error SPIxIF flag not defined!
140 #endif
141 
142 /** Define the number of ECAN modules supported by this chip.
143  * See \ref NUM_UART_MODS for details on this methodology.
144  */
145 #if defined(_C2IF)
146 #define NUM_ECAN_MODS 2
147 #elif defined(_C1IF) || defined(__DOXYGEN__)
148 #define NUM_ECAN_MODS 1
149 #else
150 #define NUM_ECAN_MODS 0
151 #endif
152 //@}
153 
154 
155 
156 /** \name Chip identification
157  * These routines assist in identifying the device and revision
158  * of the PIC in use. See checkDeviceAndRevision() for a usage
159  * example.
160  */
161 //@{
162 /** The location in program memory of the device ID.
163  * Revision information is found in the Silicon Errata
164  * sheet for the device. The Device ID is contained
165  * in the datasheet for the target device.
166  */
167 #define DEV_ID_LOCATION 0xFF0000
168 /** The location in program memory of the revision. */
169 #define REVISION_LOCATION 0xFF0002
170 
171 
172 #if defined(__PIC24HJ12GP201__) || defined(__DOXYGEN__)
173 /** The device ID for this chip, located in program memory
174  * at \ref DEV_ID_LOCATION.
175  */
176 #define DEV_ID 0x00080a
177 /** A string to identify this chip, printed by
178  * checkDeviceAndRevision().
179  */
180 #define DEV_ID_STR "PIC24HJ12GP201"
181 /** A revision for this device, located in program memory
182  * at \ref REVISION_LOCATION. Additional revisions
183  * can be defined as EXPECTED_REVISIONn, where n = 1..5.
184  */
185 #define EXPECTED_REVISION1 0x003001
186 /** A string to accompany this revision, printed by
187  * checkDeviceAndRevision(). Additional revision strings
188  * can be defined as EXPECTED_REVISIONn, where n = 1..5.
189  */
190 #define EXPECTED_REVISION1_STR "A2"
191 
192 #define EXPECTED_REVISION2 0x003002
193 #define EXPECTED_REVISION2_STR "A3"
194 #define EXPECTED_REVISION3 0x003003
195 #define EXPECTED_REVISION3_STR "A4"
196 #endif
197 
198 #ifdef __PIC24HJ12GP202__
199 #define DEV_ID 0x00080B
200 #define DEV_ID_STR "PIC24HJ12GP202"
201 #define EXPECTED_REVISION1 0x003001
202 #define EXPECTED_REVISION1_STR "A2"
203 #define EXPECTED_REVISION2 0x003002
204 #define EXPECTED_REVISION2_STR "A3"
205 #define EXPECTED_REVISION3 0x003003
206 #define EXPECTED_REVISION3_STR "A4"
207 #endif
208 
209 
210 
211 /* PIC24H32GP202/204,PIC24HJ16GP304 */
212 
213 #ifdef __PIC24HJ16GP304__
214 #define DEV_ID 0x000F17
215 #define DEV_ID_STR "PIC24HJ16GP304"
216 #endif
217 
218 #ifdef __PIC24HJ32GP202__
219 #define DEV_ID 0x000F1D
220 #define DEV_ID_STR "PIC24HJ32GP202"
221 #endif
222 
223 #ifdef __PIC24HJ32GP204__
224 #define DEV_ID 0x000F1F
225 #define DEV_ID_STR "PIC24HJ32GP204"
226 #endif
227 
228 #if (defined(__PIC24HJ16GP304__) || defined(__PIC24HJ32GP202__) || defined(__PIC24HJ32GP204__))
229 #define EXPECTED_REVISION1 0x003001
230 #define EXPECTED_REVISION1_STR "A2"
231 #define EXPECTED_REVISION2 0x003002
232 #define EXPECTED_REVISION2_STR "A3"
233 #define EXPECTED_REVISION3 0x003004
234 #define EXPECTED_REVISION3_STR "A4"
235 #define EXPECTED_REVISION4 0x003005
236 #define EXPECTED_REVISION4_STR "A5"
237 #define EXPECTED_REVISION5 0x003006
238 #define EXPECTED_REVISION5_STR "A6"
239 #endif
240 
241 /* PIC24H32GP302/304, PIC24HJGPX02/X04, PIC24HJ128GPX02/X04 */
242 
243 #ifdef __PIC24HJ32GP302__
244 #define DEV_ID 0x000645
245 #define DEV_ID_STR "PIC24HJ32GP302"
246 #endif
247 
248 #ifdef __PIC24HJ32GP304__
249 #define DEV_ID 0x000647
250 #define DEV_ID_STR "PIC24HJ32GP304"
251 #endif
252 
253 #ifdef __PIC24HJ64GP202__
254 #define DEV_ID 0x000655
255 #define DEV_ID_STR "PIC24HJ64GP202"
256 #endif
257 
258 #ifdef __PIC24HJ64GP204__
259 #define DEV_ID 0x000657
260 #define DEV_ID_STR "PIC24HJ64GP204"
261 #endif
262 
263 #ifdef __PIC24HJ64GP502__
264 #define DEV_ID 0x000675
265 #define DEV_ID_STR "PIC24HJ64GP502"
266 #endif
267 
268 #ifdef __PIC24HJ64GP504__
269 #define DEV_ID 0x000677
270 #define DEV_ID_STR "PIC24HJ64GP504"
271 #endif
272 
273 #ifdef __PIC24HJ128GP202__
274 #define DEV_ID 0x000665
275 #define DEV_ID_STR "PIC24HJ128GP202"
276 #endif
277 
278 
279 #ifdef __PIC24HJ128GP204__
280 #define DEV_ID 0x000667
281 #define DEV_ID_STR "PIC24HJ128GP204"
282 #endif
283 
284 #ifdef __PIC24HJ128GP502__
285 #define DEV_ID 0x00067d
286 #define DEV_ID_STR "PIC24HJ128GP502"
287 #endif
288 
289 #ifdef __PIC24HJ128GP504__
290 #define DEV_ID 0x00067f
291 #define DEV_ID_STR "PIC24HJ128GP504"
292 #endif
293 
294 #if (defined(__PIC24HJ128GP504__) || defined(__PIC24HJ128GP502__)\
295 || defined(__PIC24HJ128GP204__) || defined(__PIC24HJ128GP202__)\
296 || defined(__PIC24HJ64GP504__) || defined(__PIC24HJ64GP502__)\
297 || defined(__PIC24HJ64GP204__) || defined(__PIC24HJ64GP202__)\
298 || defined(__PIC24HJ32GP304__) || defined(__PIC24HJ32GP302__))
299 #define EXPECTED_REVISION1 0x003001
300 #define EXPECTED_REVISION1_STR "A1"
301 #define EXPECTED_REVISION2 0x003002
302 #define EXPECTED_REVISION2_STR "A2"
303 #define EXPECTED_REVISION3 0x003003
304 #define EXPECTED_REVISION3_STR "A3"
305 #endif
306 
307 
308 /* PIC24HJXXXGPX06/X08/X10 */
309 
310 #if (defined(__PIC24HJ64GP206__) || defined(__PIC24HJ64GP206A__))
311 #define DEV_ID 0x000041
312 #define DEV_ID_STR "PIC24HJ64GP206"
313 #endif
314 
315 #if (defined(__PIC24HJ64GP210__) || defined(__PIC24HJ64GP210A__))
316 #define DEV_ID 0x000047
317 #define DEV_ID_STR "PIC24HJ64GP210"
318 #endif
319 
320 #if (defined(__PIC24HJ64GP506__) || defined(__PIC24HJ64GP506A__))
321 #define DEV_ID 0x000049
322 #define DEV_ID_STR "PIC24HJ64GP506"
323 #endif
324 
325 #if (defined(__PIC24HJ64GP510__) || defined(__PIC24HJ64GP510A__))
326 #define DEV_ID 0x00004B
327 #define DEV_ID_STR "PIC24HJ64GP510"
328 #endif
329 
330 #if (defined(__PIC24HJ128GP206__) || defined(__PIC24HJ128GP206A__))
331 #define DEV_ID 0x00005D
332 #define DEV_ID_STR "PIC24HJ128GP206"
333 #endif
334 
335 #if (defined(__PIC24HJ128GP210__) || defined(__PIC24HJ128GP210A__))
336 #define DEV_ID 0x00005F
337 #define DEV_ID_STR "PIC24HJ128GP210"
338 #endif
339 
340 #if (defined(__PIC24HJ128GP306__) || defined(__PIC24HJ128GP306A__))
341 #define DEV_ID 0x000065
342 #define DEV_ID_STR "PIC24HJ128GP306"
343 #endif
344 
345 #if (defined(__PIC24HJ128GP310__) || defined(__PIC24HJ128GP310A__))
346 #define DEV_ID 0x000067
347 #define DEV_ID_STR "PIC24HJ128GP310"
348 #endif
349 
350 
351 #if defined(__PIC24HJ128GP506__) || defined(__PIC24HJ128GP506A__)
352 #define DEV_ID 0x000061
353 #define DEV_ID_STR "PIC24HJ128GP506/506A"
354 #endif
355 
356 #if (defined(__PIC24HJ128GP510__) || defined(__PIC24HJ128GP510A__))
357 #define DEV_ID 0x000063
358 #define DEV_ID_STR "PIC24HJ128GP510"
359 #endif
360 
361 #if (defined(__PIC24HJ256GP206__) )
362 #define DEV_ID 0x000071
363 #define DEV_ID_STR "PIC24HJ256GP206"
364 #endif
365 
366 #ifdef __PIC24HJ256GP210__
367 #define DEV_ID 0x000073
368 #define DEV_ID_STR "PIC24HJ256GP210"
369 #endif
370 
371 
372 #ifdef __PIC24HJ256GP610__
373 #define DEV_ID 0x00007B
374 #define DEV_ID_STR "PIC24HJ256GP610"
375 #endif
376 
377 #if (defined(__PIC24HJ64GP206__) || defined(__PIC24HJ64GP210__) || defined(__PIC24HJ64GP506__) || defined(__PIC24HJ64GP510__)\
378 || defined(__PIC24HJ128GP206__) || defined(__PIC24HJ128GP210__) || defined(__PIC24HJ128GP306__)\
379 || defined(__PIC24HJ128GP310__) || defined(__PIC24HJ128GP506__)|| defined(__PIC24HJ128GP510__)\
380 || defined(__PIC24HJ256GP206__) || defined(__PIC24HJ256GP210__)|| defined(__PIC24HJ256GP610__))
381 
382 #define EXPECTED_REVISION1 0x003002
383 #define EXPECTED_REVISION1_STR "A2"
384 #define EXPECTED_REVISION2 0x003004
385 #define EXPECTED_REVISION2_STR "A3"
386 #define EXPECTED_REVISION3 0x003040
387 #define EXPECTED_REVISION3_STR "A4"
388 #endif
389 
390 #if (defined(__PIC24HJ64GP206A__) || defined(__PIC24HJ64GP210A__) || defined(__PIC24HJ64GP506A__) || defined(__PIC24HJ64GP510A__)\
391 || defined(__PIC24HJ128GP206A__) || defined(__PIC24HJ128GP210A__) || defined(__PIC24HJ128GP306A__)\
392 || defined(__PIC24HJ128GP310A__) || defined(__PIC24HJ128GP506A__)|| defined(__PIC24HJ128GP510A__)\
393 || defined(__PIC24HJ256GP206A__) || defined(__PIC24HJ256GP210A__)|| defined(__PIC24HJ256GP610A__))
394 #define EXPECTED_REVISION1 0x003009
395 #define EXPECTED_REVISION1_STR "A3"
396 #define EXPECTED_REVISION2 0x00300A
397 #define EXPECTED_REVISION2_STR "A4"
398 #define EXPECTED_REVISION3 0x00300B
399 #define EXPECTED_REVISION3_STR "A5"
400 #endif
401 
402 //24F Family
403 
404 /* PIC24FJ128GA010 Family */
405 
406 #ifdef __PIC24FJ128GA010__
407 #define DEV_ID 0x00040D
408 #define DEV_ID_STR "PIC24FJ128GA010"
409 #endif
410 
411 #ifdef __PIC24FJ96GA010__
412 #define DEV_ID 0x00040C
413 #define DEV_ID_STR "PIC24FJ96GA010"
414 #endif
415 
416 #ifdef __PIC24FJ64GA010__
417 #define DEV_ID 0x00040B
418 #define DEV_ID_STR "PIC24FJ64GA010"
419 #endif
420 
421 #ifdef __PIC24FJ128GA008__
422 #define DEV_ID 0x00040A
423 #define DEV_ID_STR "PIC24FJ128GA008"
424 #endif
425 
426 #ifdef __PIC24FJ96GA008__
427 #define DEV_ID 0x000409
428 #define DEV_ID_STR "PIC24FJ96GA008"
429 #endif
430 
431 #ifdef __PIC24FJ64GA008__
432 #define DEV_ID 0x000408
433 #define DEV_ID_STR "PIC24FJ64GA008"
434 #endif
435 
436 #ifdef __PIC24FJ128GA006__
437 #define DEV_ID 0x000407
438 #define DEV_ID_STR "PIC24FJ128GA006"
439 #endif
440 
441 #ifdef __PIC24FJ96GA006__
442 #define DEV_ID 0x000409
443 #define DEV_ID_STR "PIC24FJ96GA006"
444 #endif
445 
446 #ifdef __PIC24FJ64GA006__
447 #define DEV_ID 0x000408
448 #define DEV_ID_STR "PIC24FJ64GA006"
449 #endif
450 
451 #if (defined(__PIC24FJ128GA010__) || defined(__PIC24FJ96GA010__) || defined(__PIC24FJ64GA010__)\
452 || defined(__PIC24FJ128GA008__) || defined(__PIC24FJ96GA008__) || defined(__PIC24FJ64GA008__)\
453 || defined(__PIC24FJ128GA006__) || defined(__PIC24FJ96GA006__) || defined(__PIC24FJ64GA006__))
454 #define EXPECTED_REVISION1 0x003002
455 #define EXPECTED_REVISION1_STR "A2"
456 #define EXPECTED_REVISION2 0x003003
457 #define EXPECTED_REVISION2_STR "A3"
458 #define EXPECTED_REVISION3 0x003007
459 #define EXPECTED_REVISION3_STR "A4"
460 #define EXPECTED_REVISION4 0x003043
461 #define EXPECTED_REVISION4_STR "C1"
462 #define EXPECTED_REVISION5 0x003044
463 #define EXPECTED_REVISION5_STR "C2"
464 #endif
465 
466 
467 
468 //PIC24FJ64GA104 Family
469 #ifdef __PIC24FJ32GA102__
470 #define DEV_ID 0x004202
471 #define DEV_ID_STR "PIC24FJ32GA102"
472 #endif
473 #ifdef __PIC24FJ32GA104__
474 #define DEV_ID 0x00420A
475 #define DEV_ID_STR "PIC24FJ32GA104"
476 #endif
477 #ifdef __PIC24FJ64GA102__
478 #define DEV_ID 0x004206
479 #define DEV_ID_STR "PIC24FJ64GA102"
480 #endif
481 #ifdef __PIC24FJ64GA104__
482 #define DEV_ID 0x00420E
483 #define DEV_ID_STR "PIC24FJ64GA104"
484 #endif
485 
486 
487 #if (defined(__PIC24FJ32GA102__) || defined(__PIC24FJ32GA104__)\
488 || defined(__PIC24FJ64GA102__) || defined(__PIC24FJ64GA104__))
489 #define EXPECTED_REVISION1 0x000002
490 #define EXPECTED_REVISION1_STR "A2"
491 #endif
492 
493 
494 //PIC24FJXXGA002 (28 pin),PIC24FJXXGA004 (44 pin)
495 #ifdef __PIC24FJ16GA002__
496 #define DEV_ID 0x000444
497 #define DEV_ID_STR "PIC24FJ16GA002"
498 #endif
499 
500 #ifdef __PIC24FJ32GA002__
501 #define DEV_ID 0x000445
502 #define DEV_ID_STR "PIC24FJ32GA002"
503 #endif
504 
505 #ifdef __PIC24FJ48GA002__
506 #define DEV_ID 0x000446
507 #define DEV_ID_STR "PIC24FJ48GA002"
508 #endif
509 
510 #ifdef __PIC24FJ64GA002__
511 #define DEV_ID 0x000447
512 #define DEV_ID_STR "PIC24FJ64GA002"
513 #endif
514 
515 #ifdef __PIC24FJ16GA004__
516 #define DEV_ID 0x00044C
517 #define DEV_ID_STR "PIC24FJ16GA004"
518 #endif
519 
520 #ifdef __PIC24FJ32GA004__
521 #define DEV_ID 0x00044D
522 #define DEV_ID_STR "PIC24FJ32GA004"
523 #endif
524 
525 #ifdef __PIC24FJ48GA004__
526 #define DEV_ID 0x00044E
527 #define DEV_ID_STR "PIC24FJ48GA004"
528 #endif
529 
530 #ifdef __PIC24FJ64GA004__
531 #define DEV_ID 0x00044F
532 #define DEV_ID_STR "PIC24FJ64GA004"
533 #endif
534 
535 #if (defined(__PIC24FJ64GA004__) || defined(__PIC24FJ48GA004__) || defined(__PIC24FJ32GA004__) || defined(__PIC24FJ16GA004__)\
536 || defined(__PIC24FJ64GA002__) || defined(__PIC24FJ48GA002__) || defined(__PIC24FJ32GA002__) || defined(__PIC24FJ16GA002__))
537 
538 #define EXPECTED_REVISION1 0x003003
539 #define EXPECTED_REVISION1_STR "A3/A4"
540 #define EXPECTED_REVISION2 0x003042
541 #define EXPECTED_REVISION2_STR "B4"
542 #define EXPECTED_REVISION3 0x003043
543 #define EXPECTED_REVISION3_STR "B5"
544 #define EXPECTED_REVISION4 0x003046
545 #define EXPECTED_REVISION4_STR "B8"
546 #endif
547 
548 
549 /* GA110, GA108,GA106 Family */
550 
551 
552 #ifdef __PIC24FJ256GA110__
553 #define DEV_ID 0x00101E
554 #define DEV_ID_STR "PIC24FJ256GA110"
555 #endif
556 
557 #ifdef __PIC24FJ192GA110__
558 #define DEV_ID 0x001016
559 #define DEV_ID_STR "PIC24FJ192GA110"
560 #endif
561 
562 #ifdef __PIC24FJ128GA110__
563 #define DEV_ID 0x00100E
564 #define DEV_ID_STR "PIC24FJ128GA110"
565 #endif
566 
567 #ifdef __PIC24FJ256GA108__
568 #define DEV_ID 0x00101A
569 #define DEV_ID_STR "PIC24FJ256GA108"
570 #endif
571 
572 #ifdef __PIC24FJ192GA108__
573 #define DEV_ID 0x001012
574 #define DEV_ID_STR "PIC24FJ192GA108"
575 #endif
576 
577 #ifdef __PIC24FJ128GA108__
578 #define DEV_ID 0x00100A
579 #define DEV_ID_STR "PIC24FJ128GA108"
580 #endif
581 
582 #ifdef __PIC24FJ256GA106__
583 #define DEV_ID 0x001018
584 #define DEV_ID_STR "PIC24FJ256GA106"
585 #endif
586 
587 #ifdef __PIC24FJ192GA106__
588 #define DEV_ID 0x001010
589 #define DEV_ID_STR "PIC24FJ192GA106"
590 #endif
591 
592 #ifdef __PIC24FJ128GA106__
593 #define DEV_ID 0x001008
594 #define DEV_ID_STR "PIC24FJ128GA106"
595 #endif
596 
597 #if (defined(__PIC24FJ256GA110__) || defined(__PIC24FJ192GA110__) || defined(__PIC24FJ128GA110__)\
598 || defined(__PIC24FJ256GA108__) || defined(__PIC24FJ192GA108__) || defined(__PIC24FJ128GA108__)\
599 || defined(__PIC24FJ256GA106__) || defined(__PIC24FJ192GA106__) || defined(__PIC24FJ128GA106__))
600 
601 #define EXPECTED_REVISION1 0x003001
602 #define EXPECTED_REVISION1_STR "A3"
603 #define EXPECTED_REVISION2 0x003003
604 #define EXPECTED_REVISION2_STR "A5"
605 #endif
606 
607 /***** PIC24F K ****/
608 
609 #ifdef __PIC24F04KA200__
610 #define DEV_ID 0x000D02
611 #define DEV_ID_STR "PIC24F04KA200"
612 #endif
613 
614 #ifdef __PIC24F04KA201__
615 #define DEV_ID 0x000D00
616 #define DEV_ID_STR "PIC24F04KA201"
617 #endif
618 
619 #if (defined(__PIC24F04KA200__) || defined(__PIC24F04KA201__) )
620 #define EXPECTED_REVISION1 0x000001
621 #define EXPECTED_REVISION1_STR "A1"
622 #endif
623 
624 
625 #ifdef __PIC24F08KA101__
626 #define DEV_ID 0x000D08
627 #define DEV_ID_STR "PIC24F08KA101"
628 #endif
629 
630 #ifdef __PIC24F08KA102__
631 #define DEV_ID 0x000D0A
632 #define DEV_ID_STR "PIC24F08KA102"
633 #endif
634 
635 #ifdef __PIC24F16KA101__
636 #define DEV_ID 0x000D01
637 #define DEV_ID_STR "PIC24F16KA101"
638 #endif
639 
640 #ifdef __PIC24F16KA102__
641 #define DEV_ID 0x000D03
642 #define DEV_ID_STR "PIC24F16KA102"
643 #endif
644 
645 #if (defined(__PIC24F08KA101__) || defined(__PIC24F08KA102__) || defined(__PIC24F16KA101__)\
646 || defined(__PIC24F16KA102__))
647 
648 #define EXPECTED_REVISION1 0x000005
649 #define EXPECTED_REVISION1_STR "A5"
650 #define EXPECTED_REVISION2 0x000006
651 #define EXPECTED_REVISION2_STR "A6"
652 #endif
653 
654 
655 
656 /***** PIC24F GB ****/
657 
658 #ifdef __PIC24FJ256GB110__
659 #define DEV_ID 0x00101F
660 #define DEV_ID_STR "PIC24FJ256GB110"
661 #endif
662 
663 #ifdef __PIC24FJ192GB110__
664 #define DEV_ID 0x001017
665 #define DEV_ID_STR "PIC24FJ192GB110"
666 #endif
667 
668 #ifdef __PIC24FJ128GB110__
669 #define DEV_ID 0x00100F
670 #define DEV_ID_STR "PIC24FJ128GB110"
671 #endif
672 
673 #ifdef __PIC24FJ64GB110__
674 #define DEV_ID 0x001007
675 #define DEV_ID_STR "PIC24FJ64GB110"
676 #endif
677 
678 #ifdef __PIC24FJ256GB108__
679 #define DEV_ID 0x00101B
680 #define DEV_ID_STR "PIC24FJ256GB108"
681 #endif
682 
683 #ifdef __PIC24FJ192GB108__
684 #define DEV_ID 0x001013
685 #define DEV_ID_STR "PIC24FJ192GB108"
686 #endif
687 
688 #ifdef __PIC24FJ128GB108__
689 #define DEV_ID 0x00100B
690 #define DEV_ID_STR "PIC24FJ128GB108"
691 #endif
692 
693 #ifdef __PIC24FJ64GB108__
694 #define DEV_ID 0x001003
695 #define DEV_ID_STR "PIC24FJ64GB108"
696 #endif
697 
698 #ifdef __PIC24FJ256GB106__
699 #define DEV_ID 0x001018
700 #define DEV_ID_STR "PIC24FJ256GB106"
701 #define EXPECTED_REVISION1 0x000001
702 #define EXPECTED_REVISION1_STR "A3"
703 #endif
704 
705 #ifdef __PIC24FJ192GB106__
706 #define DEV_ID 0x001010
707 #define DEV_ID_STR "PIC24FJ192GB106"
708 #endif
709 
710 #ifdef __PIC24FJ128GB106__
711 #define DEV_ID 0x001008
712 #define DEV_ID_STR "PIC24FJ128GB106"
713 #endif
714 
715 #ifdef __PIC24FJ64GB106__
716 #define DEV_ID 0x001001
717 #define DEV_ID_STR "PIC24FJ64GB106"
718 #endif
719 
720 #ifdef __PIC24FJ32GB002__
721 #define DEV_ID 0x004203
722 #define DEV_ID_STR "PIC24FJ32GB002"
723 #endif
724 
725 #ifdef __PIC24FJ32GB004__
726 #define DEV_ID 0x00420B
727 #define DEV_ID_STR "PIC24FJ32GB004"
728 #endif
729 
730 #ifdef __PIC24FJ64GB002__
731 #define DEV_ID 0x004207
732 #define DEV_ID_STR "PIC24FJ64GB002"
733 #endif
734 
735 #ifdef __PIC24FJ64GB004__
736 #define DEV_ID 0x00420F
737 #define DEV_ID_STR "PIC24FJ64GB004"
738 #endif
739 
740 #if (defined(__PIC24FJ32GB002__) || defined(__PIC24FJ32GB004__) || defined(__PIC24FJ64GB002__) || defined(__PIC24FJ64GB004__))
741 #define EXPECTED_REVISION1 0x000002
742 #define EXPECTED_REVISION1_STR "A2"
743 #endif
744 
745 
746 #if (defined(__PIC24FJ256GB110__) || defined(__PIC24FJ192GB110__) || defined(__PIC24FJ128GB110__) || defined(__PIC24FJ64GB110__)\
747 || defined(__PIC24FJ256GB108__) || defined(__PIC24FJ192GB108__) || defined(__PIC24FJ128GB108__) || defined(__PIC24FJ64GB108__)\
748 || defined(__PIC24FJ256GB106__) || defined(__PIC24FJ192GB106__) || defined(__PIC24FJ128GB106__) || defined(__PIC24FJ64GB106__))
749 
750 #define EXPECTED_REVISION1 0x003001
751 #define EXPECTED_REVISION1_STR "A3"
752 #define EXPECTED_REVISION2 0x003003
753 #define EXPECTED_REVISION2_STR "A5"
754 #endif
755 
756 //dsPIC33 CPUS
757 
758 //dsPIC33FJ12GP201, dsPIC33FJ12GP202
759 #ifdef __dsPIC33FJ12GP201__
760 #define DEV_ID 0x000802
761 #define DEV_ID_STR "dsPIC33FJ12GP201"
762 #endif
763 
764 #ifdef __dsPIC33FJ12GP202__
765 #define DEV_ID 0x000803
766 #define DEV_ID_STR "dsPIC33FJ12GP202"
767 #endif
768 
769 #if (defined(__dsPIC33FJ12GP201__) || defined(__dsPIC33FJ12GP202__))
770 #define EXPECTED_REVISION1 0x003001
771 #define EXPECTED_REVISION1_STR "A2"
772 #define EXPECTED_REVISION2 0x003002
773 #define EXPECTED_REVISION2_STR "A3"
774 #define EXPECTED_REVISION3 0x003004
775 #define EXPECTED_REVISION3_STR "A4"
776 #endif
777 
778 //dsPIC33FJ32GP202/04,dsPIC33FJ16GP304
779 
780 #ifdef __dsPIC33FJ32GP202__
781 #define DEV_ID 0x000F0D
782 #define DEV_ID_STR "dsPIC24FJ32GP202"
783 #endif
784 
785 #ifdef __dsPIC33FJ32GP204__
786 #define DEV_ID 0x000F0F
787 #define DEV_ID_STR "dsPIC33FJ32GP204"
788 #endif
789 
790 #ifdef __dsPIC33FJ16GP304__
791 #define DEV_ID 0x000F07
792 #define DEV_ID_STR "dsPIC33FJ16GP304"
793 #endif
794 
795 #if (defined(__dsPIC33FJ32GP202__) || defined(__dsPIC33FJ32GP204___) || defined(__dsPIC33FJ16GP304__))
796 #define EXPECTED_REVISION1 0x003001
797 #define EXPECTED_REVISION1_STR "A2"
798 #define EXPECTED_REVISION2 0x003002
799 #define EXPECTED_REVISION2_STR "A3"
800 #define EXPECTED_REVISION3 0x003004
801 #define EXPECTED_REVISION3_STR "A4"
802 #endif
803 
804 //dsPIC33FJ32GP302/304,dsPIC33FJ64GPX02/X04,dsPIC33FJ128GPX02,X04
805 
806 #ifdef __dsPIC33FJ32GP302__
807 #define DEV_ID 0x000605
808 #define DEV_ID_STR "dsPIC33FJ32GP302"
809 #endif
810 
811 #ifdef __dsPIC33FJ32GP304__
812 #define DEV_ID 0x000607
813 #define DEV_ID_STR "dsPIC33FJ32GP304"
814 #endif
815 
816 #ifdef __dsPIC33FJ64GP202__
817 #define DEV_ID 0x000615
818 #define DEV_ID_STR "dsPIC33FJ64GP202"
819 #endif
820 
821 #ifdef __dsPIC33FJ64GP204__
822 #define DEV_ID 0x000617
823 #define DEV_ID_STR "dsPIC33FJ64GP204"
824 #endif
825 
826 #ifdef __dsPIC33FJ64GP802__
827 #define DEV_ID 0x00061d
828 #define DEV_ID_STR "dsPIC33FJ64GP802"
829 #endif
830 
831 #ifdef __dsPIC33FJ64GP804__
832 #define DEV_ID 0x00061f
833 #define DEV_ID_STR "dsPIC33FJ64GP804"
834 #endif
835 
836 #ifdef __dsPIC33FJ128GP202__
837 #define DEV_ID 0x000625
838 #define DEV_ID_STR "dsPIC33FJ128GP202"
839 #endif
840 
841 
842 #ifdef __dsPIC33FJ128GP204__
843 #define DEV_ID 0x000627
844 #define DEV_ID_STR "dsPIC33FJ128GP204"
845 #endif
846 
847 #ifdef __dsPIC33FJ128GP802__
848 #define DEV_ID 0x00062d
849 #define DEV_ID_STR "dsPIC33FJ128GP802"
850 #endif
851 
852 #ifdef __dsPIC33FJ128GP804__
853 #define DEV_ID 0x00062f
854 #define DEV_ID_STR "dsPIC33FJ128GP804"
855 #endif
856 
857 #if (defined(__dsPIC33FJ128GP804__) || defined(__dsPIC33FJ128GP802__)\
858 || defined(__dsPIC33FJ128GP204__) || defined(__dsPIC33FJ128GP202__)\
859 || defined(__dsPIC33FJ64GP804__) || defined(__dsPIC33FJ64GP802__)\
860 || defined(__dsPIC33FJ64GP204__) || defined(__dsPIC33FJ64GP202__)\
861 || defined(__dsPIC33FJ32GP304__) || defined(__dsPIC33FJ32GP302__))
862 #define EXPECTED_REVISION1 0x003001
863 #define EXPECTED_REVISION1_STR "A1"
864 #define EXPECTED_REVISION2 0x003002
865 #define EXPECTED_REVISION2_STR "A2"
866 #define EXPECTED_REVISION3 0x003003
867 #define EXPECTED_REVISION3_STR "A3"
868 #endif
869 
870 /* PIC24E/dsPIC33E Families */
871 
872 //64K devices
873 #ifdef __PIC24EP64GP202__
874 #define DEV_ID 0x001D39
875 #define DEV_ID_STR "PIC24EP64GP202"
876 #define EXPECTED_REVISION1 0x004002
877 #define EXPECTED_REVISION1_STR "A2"
878 #endif
879 
880 #ifdef __PIC24EP64GP203__
881 #define DEV_ID 0x001D3A
882 #define DEV_ID_STR "PIC24EP64GP203"
883 #define EXPECTED_REVISION1 0x004002
884 #define EXPECTED_REVISION1_STR "A2"
885 #endif
886 
887 #ifdef __PIC24EP64GP204__
888 #define DEV_ID 0x001D38
889 #define DEV_ID_STR "PIC24EP64GP204"
890 #define EXPECTED_REVISION1 0x004002
891 #define EXPECTED_REVISION1_STR "A2"
892 #endif
893 
894 #ifdef __PIC24EP64GP206__
895 #define DEV_ID 0x001D3B
896 #define DEV_ID_STR "PIC24EP64GP206"
897 #define EXPECTED_REVISION1 0x004002
898 #define EXPECTED_REVISION1_STR "A2"
899 #endif
900 
901 #ifdef __dsPIC33EP64GP502__
902 #define DEV_ID 0x001D2D
903 #define DEV_ID_STR "dsPIC33EP64GP502"
904 #define EXPECTED_REVISION1 0x004002
905 #define EXPECTED_REVISION1_STR "A2"
906 #endif
907 
908 #ifdef __dsPIC33EP64GP503__
909 #define DEV_ID 0x001D2E
910 #define DEV_ID_STR "dsPIC33EP64GP503"
911 #define EXPECTED_REVISION1 0x004002
912 #define EXPECTED_REVISION1_STR "A2"
913 #endif
914 
915 #ifdef __dsPIC33EP64GP504__
916 #define DEV_ID 0x001D2C
917 #define DEV_ID_STR "dsPIC33EP64GP504"
918 #define EXPECTED_REVISION1 0x004002
919 #define EXPECTED_REVISION1_STR "A2"
920 #endif
921 
922 #ifdef __dsPIC33EP64GP506__
923 #define DEV_ID 0x001D2F
924 #define DEV_ID_STR "dsPIC33EP64GP506"
925 #define EXPECTED_REVISION1 0x004002
926 #define EXPECTED_REVISION1_STR "A2"
927 #endif
928 
929 #ifdef __PIC24EP64MC202__
930 #define DEV_ID 0x001D31
931 #define DEV_ID_STR "PIC24EP64MC202"
932 #define EXPECTED_REVISION1 0x004002
933 #define EXPECTED_REVISION1_STR "A2"
934 #endif
935 
936 #ifdef __PIC24EP64MC203__
937 #define DEV_ID 0x001D32
938 #define DEV_ID_STR "PIC24EP64MC203"
939 #define EXPECTED_REVISION1 0x004002
940 #define EXPECTED_REVISION1_STR "A2"
941 #endif
942 
943 #ifdef __PIC24EP64MC204__
944 #define DEV_ID 0x001D30
945 #define DEV_ID_STR "PIC24EP64MC204"
946 #define EXPECTED_REVISION1 0x004002
947 #define EXPECTED_REVISION1_STR "A2"
948 #endif
949 
950 #ifdef __PIC24EP64MC206__
951 #define DEV_ID 0x001D33
952 #define DEV_ID_STR "PIC24EP64MC206"
953 #define EXPECTED_REVISION1 0x004002
954 #define EXPECTED_REVISION1_STR "A2"
955 #endif
956 
957 #ifdef __dsPIC33EP64MC202__
958 #define DEV_ID 0x001D21
959 #define DEV_ID_STR "dsPIC33EP64MC202"
960 #define EXPECTED_REVISION1 0x004002
961 #define EXPECTED_REVISION1_STR "A2"
962 #endif
963 
964 #ifdef __dsPIC33EP64MC203__
965 #define DEV_ID 0x001D22
966 #define DEV_ID_STR "dsPIC33EP64MC203"
967 #define EXPECTED_REVISION1 0x004002
968 #define EXPECTED_REVISION1_STR "A2"
969 #endif
970 
971 #ifdef __dsPIC33EP64MC204__
972 #define DEV_ID 0x001D20
973 #define DEV_ID_STR "dsPIC33EP64MC204"
974 #define EXPECTED_REVISION1 0x004002
975 #define EXPECTED_REVISION1_STR "A2"
976 #endif
977 
978 #ifdef __dsPIC33EP64MC206__
979 #define DEV_ID 0x001D23
980 #define DEV_ID_STR "dsPIC33EP64MC206"
981 #define EXPECTED_REVISION1 0x004002
982 #define EXPECTED_REVISION1_STR "A2"
983 #endif
984 
985 #ifdef __dsPIC33EP64MC502__
986 #define DEV_ID 0x001D25
987 #define DEV_ID_STR "dsPIC33EP64MC502"
988 #define EXPECTED_REVISION1 0x004002
989 #define EXPECTED_REVISION1_STR "A2"
990 #endif
991 
992 #ifdef __dsPIC33EP64MC503__
993 #define DEV_ID 0x001D26
994 #define DEV_ID_STR "dsPIC33EP64MC503"
995 #define EXPECTED_REVISION1 0x004002
996 #define EXPECTED_REVISION1_STR "A2"
997 #endif
998 
999 #ifdef __dsPIC33EP64MC504__
1000 #define DEV_ID 0x001D24
1001 #define DEV_ID_STR "dsPIC33EP64MC504"
1002 #define EXPECTED_REVISION1 0x004002
1003 #define EXPECTED_REVISION1_STR "A2"
1004 #endif
1005 
1006 #ifdef __dsPIC33EP64MC506__
1007 #define DEV_ID 0x001D27
1008 #define DEV_ID_STR "dsPIC33EP64MC506"
1009 #define EXPECTED_REVISION1 0x004002
1010 #define EXPECTED_REVISION1_STR "A2"
1011 #endif
1012 
1013 
1014 //256K devices
1015 #ifdef __PIC24EP256GU810__
1016 #define DEV_ID 0x001826
1017 #define DEV_ID_STR "PIC24EP256GU810"
1018 #define EXPECTED_REVISION1 0x004002
1019 #define EXPECTED_REVISION1_STR "B1"
1020 #endif
1021 
1022 #ifdef __PIC24EP256GU814__
1023 #define DEV_ID 0x001827
1024 #define DEV_ID_STR "PIC24EP256GU814"
1025 #define EXPECTED_REVISION1 0x004002
1026 #define EXPECTED_REVISION1_STR "B1"
1027 #endif
1028 
1029 #ifdef __dsPIC33EP256MU806__
1030 #define DEV_ID 0x001861
1031 #define DEV_ID_STR "dsPIC33EP256MU806"
1032 #define EXPECTED_REVISION1 0x004002
1033 #define EXPECTED_REVISION1_STR "B1"
1034 #endif
1035 
1036 #ifdef __dsPIC33EP256MU810__
1037 #define DEV_ID 0x001862
1038 #define DEV_ID_STR "dsPIC33EP256MU810"
1039 #define EXPECTED_REVISION1 0x004002
1040 #define EXPECTED_REVISION1_STR "B1"
1041 #endif
1042 
1043 #ifdef __dsPIC33EP256MU814__
1044 #define DEV_ID 0x001863
1045 #define DEV_ID_STR "dsPIC33EP256MU814"
1046 #define EXPECTED_REVISION1 0x004002
1047 #define EXPECTED_REVISION1_STR "B1"
1048 #endif
1049 
1050 //512K Devices
1051 
1052 #ifdef __dsPIC33EP512MU810__
1053 #define DEV_ID 0x001872
1054 #define DEV_ID_STR "dsPIC33EP512MU810"
1055 #define EXPECTED_REVISION1 0x004002
1056 #define EXPECTED_REVISION1_STR "B1"
1057 #endif
1058 
1059 #ifdef __dsPIC33EP512MU814__
1060 #define DEV_ID 0x001873
1061 #define DEV_ID_STR "dsPIC33EP512MU814"
1062 #define EXPECTED_REVISION1 0x004002
1063 #define EXPECTED_REVISION1_STR "B1"
1064 #endif
1065 
1066 #ifdef __dsPIC33EP512GP806__
1067 #define DEV_ID 0x00187D
1068 #define DEV_ID_STR "dsPIC33EP512GP806"
1069 #define EXPECTED_REVISION1 0x004002
1070 #define EXPECTED_REVISION1_STR "B1"
1071 #endif
1072 
1073 #ifdef __dsPIC33EP512MC806__
1074 #define DEV_ID 0x001879
1075 #define DEV_ID_STR "dsPIC33EP512MC806"
1076 #define EXPECTED_REVISION1 0x004002
1077 #define EXPECTED_REVISION1_STR "B1"
1078 #endif
1079 
1080 #ifdef __PIC24EP512GU810__
1081 #define DEV_ID 0x001836
1082 #define DEV_ID_STR "PIC24EP512GU810"
1083 #define EXPECTED_REVISION1 0x004002
1084 #define EXPECTED_REVISION1_STR "B1"
1085 #endif
1086 
1087 #ifdef __PIC24EP512GU814__
1088 #define DEV_ID 0x001837
1089 #define DEV_ID_STR "PIC24EP512GU814"
1090 #define EXPECTED_REVISION1 0x004002
1091 #define EXPECTED_REVISION1_STR "B1"
1092 #endif
1093 
1094 #ifdef __PIC24EP512GP806__
1095 #define DEV_ID 0x00183D
1096 #define DEV_ID_STR "PIC24EP512GP806"
1097 #define EXPECTED_REVISION1 0x004002
1098 #define EXPECTED_REVISION1_STR "B1"
1099 #endif
1100 
1101 
1102 /* Use these default device ID and revision values
1103  if you are trying to discover the ID/Revision by
1104  executing code on your target device and watching
1105  was is printed by the printResetCause() function.
1106 */
1107 #ifndef DEV_ID
1108 #define DEV_ID 0
1109 #define DEV_ID_STR "unknown"
1110 #define EXPECTED_REVISION1 0
1111 #define EXPECTED_REVISION1_STR "unknown"
1112 #warning *********************************************
1113 #warning * Unknown chip type! Define a device ID and *
1114 #warning * revision ID in the lines above for this *
1115 #warning * chip to remove this warning message. *
1116 #warning * These values can be found by *
1117 #warning * executing the checkDeviceAndRevision() *
1118 #warning * function, which is typically called after *
1119 #warning * reset via calling printResetCause(). *
1120 #warning * This check allows you to ensure that the *
1121 #warning * programmed hex file is running on the *
1122 #warning * same device type it was compiled for. *
1123 #warning * This is only a warning. *
1124 #warning *********************************************
1125 #endif
1126 
1127 //@}
1128 
1129 #endif // #ifndef _PIC24_CHIP_ALL_H_