48 #if !USE_HEARTBEAT && !defined(__DOXYGEN__) 76 # define MS_PER_HEARTBEAT (1) 78 # define MS_PER_HEARTBEAT (10) 82 #define HEARTBEAT_MAX (CYCLES_PER_MS * MS_PER_HEARTBEAT) 145 static _PERSISTENT INTTREGBITS INTTREGBITS_last;
152 # define u16_INTTREGlast BITS2WORD(INTTREGBITS_last) 197 uint16_t u16_offset = u32_address;
198 TBLPAG = u32_address >> 16;
199 return ( ((uint32_t) __builtin_tblrdh(u16_offset)) << 16) |
200 __builtin_tblrdl(u16_offset);
210 outString(
"**** SIMULATION MODE: cannot read device and revision ID ****\n");
215 const char* devIDStr =
"unknown";
216 const char* revisionStr =
"unknown";
227 # ifdef EXPECTED_REVISION2 228 case EXPECTED_REVISION2 :
229 revisionStr = EXPECTED_REVISION2_STR;
232 # ifdef EXPECTED_REVISION3 233 case EXPECTED_REVISION3 :
234 revisionStr = EXPECTED_REVISION3_STR;
237 # ifdef EXPECTED_REVISION4 238 case EXPECTED_REVISION4 :
239 revisionStr = EXPECTED_REVISION4_STR;
242 # ifdef EXPECTED_REVISION5 243 case EXPECTED_REVISION5 :
244 revisionStr = EXPECTED_REVISION5_STR;
261 "******************************************************\n" 262 "* WARNING - this program was compiled for the wrong *\n" 263 "* chip. This program may produce unexpected behvior! *\n" 264 "* Edit the header files to properly define this chip *\n" 265 "* and to insure correct operation. *\n" 267 "* NOTE: If this was compiled for the correct chip, *\n" 268 "* and only occurs at power-on (not during a MCLR *\n" 269 "* reset), verify that AVDD and AVSS are connected. *\n" 270 "* On the PIC24H32GP202, not connecting AVDD *\n" 271 "* produces this message only at power-up. *\n" 272 "******************************************************\n");
292 outString(
"Primary Osc (XT, HS, EC) with PLL\n");
300 # if defined(__PIC24H__) || defined(__dsPIC33F__) || defined(__PIC24E__) || defined(__dsPIC33E__) 307 # elif defined(__PIC24F__) || defined(__PIC24FK__) 310 outString(
"Low power fast RC Osc with Postscaler\n");
314 outString(
"Fast RC Osc with Postscaler\n");
317 # error "Unknown processor." 332 u8_resetIdentified = 0;
334 outString(
"\nDevice has been in sleep mode\n");
338 outString(
"\nDevice has been in idle mode\n");
343 u8_resetIdentified = 1;
357 u8_resetIdentified = 1;
362 u8_resetIdentified = 1;
372 u8_resetIdentified = 1;
377 u8_resetIdentified = 1;
382 u8_resetIdentified = 1;
387 u8_resetIdentified = 1;
393 u8_resetIdentified = 1;
400 if (!u8_resetIdentified) {
452 if ((f_x - u32_y) < 0.5)
return u32_y;
464 if ((f_x - u16_y) < 0.5)
return u16_y;
474 uint16_t
compute_brg(uint32_t u32_fcy, uint16_t u16_brgh, uint32_t u32_baudrate) {
480 f_brg = (((float) u32_fcy)/((float) u32_baudrate)/16.0) - 1.0;
482 f_brg = (((float) u32_fcy)/((float) u32_baudrate)/4.0) - 1.0;
488 #else // #ifndef _NOFLOAT, so _NOFLOAT is defined. 490 uint16_t
compute_brg(uint32_t u32_fcy, uint16_t u16_brgh, uint32_t u32_baudrate) {
495 u32_brg = u32_fcy/u32_baudrate;
497 if ((u32_brg & 0x0FL) >= 8) {
498 u32_brg = u32_brg/16;
500 u32_brg = u32_brg/16 - 1;
503 if ((u32_brg & 0x03L) >= 2) {
506 u32_brg = u32_brg/4 - 1;
void _ISR _DefaultInterrupt(void)
static uint16_t u16_INTTREGlast
void toggleHeartbeat(void)
static void configClock()
void outUint32(uint32_t u32_x)
#define EXPECTED_REVISION1_STR
uint32_t roundFloatToUint32(float f_x)
void configHeartbeat(void)
void configBasic(const char *sz_helloMsg)
Configures the system clock.
void configDefaultUART(uint32_t u32_baudRate)
void outString(const char *psz_s)
_PERSISTENT const char * sz_lastTimeoutError
uint16_t compute_brg(uint32_t u32_fcy, uint16_t u16_brgh, uint32_t u32_baudrate)
uint32_t readProgramMemory(uint32_t u32_address)
_PERSISTENT uint32_t u32_heartbeatCount
void checkOscOption(void)
#define HEARTBEAT_MAX
The approximate half period, in processor cycles, of the heartbeat.
void checkDeviceAndRevision(void)
void printResetCause(void)
uint16_t roundFloatToUint16(float f_x)
#define EXPECTED_REVISION1
#define REVISION_LOCATION
unsigned char uint8_t
An abbreviation for an 8-bit unsigned integer.
void outUint8(uint8_t u8_x)
void reportError(const char *sz_errorMessage)
static _PERSISTENT const char * sz_lastError