#include "pic24_all.h"
#include <stdio.h>
Go to the source code of this file.
Defines | |
#define | u16_INTTREGlast BITS2WORD(INTTREGBITS_last) |
Functions | |
void _ISR | _DefaultInterrupt (void) |
void | reportError (const char *sz_errorMessage) |
void | printResetCause (void) |
void | configPinsForLowPower (void) |
void | configBasic (const char *sz_helloMsg) |
Variables | |
_PERSISTENT const char * | sz_lastError |
_PERSISTENT INTTREGBITS | INTTREGBITS_last |
Definition in file pic24_util.c.
#define u16_INTTREGlast BITS2WORD(INTTREGBITS_last) |
Make the INTTREGBITS_last also accessible as a word. This is like uint16 u16_INTTREGlast
except that INTTREGBITS_last and u16_INTTREGlast refer to the same data.
Definition at line 110 of file pic24_util.c.
void _ISR _DefaultInterrupt | ( | void | ) |
Provide a default interrupt handler which records what interrupt was not handled then resets the chip. Typically, a call to printResetCause during chip startup will then print the error.
Definition at line 120 of file pic24_util.c.
void configBasic | ( | const char * | sz_helloMsg | ) |
Perform basic chip configuration:
sz_helloMsg | Hello message to print. |
Definition at line 454 of file pic24_util.c.
void configPinsForLowPower | ( | void | ) |
This function puts the PIC24 in low-power mode by:
WARNING: if pullups are enabled on pins used by the oscillator, the clock typically stops running. Currently, this code works for demo purposes with the FRC oscillator when used in the reset.c program. It *should* also work with primary and secondary oscillators, using conditional compiles in the code.
Definition at line 440 of file pic24_util.c.
void printResetCause | ( | void | ) |
Determines and prints the cause of a CPU reset. This should be called when the chip first starts up. For an example, see the configBasic function.
Definition at line 275 of file pic24_util.c.
void reportError | ( | const char * | sz_errorMessage | ) |
Report a critical error by recording a message in sz_lastError then resetting the chip, assuming hat printResetCause will be called during chip initialization.
sz_errorMessage | Error message to report. |
Definition at line 141 of file pic24_util.c.
_PERSISTENT INTTREGBITS INTTREGBITS_last |
Store a copy of the INTTREG register as a bitfield. This is not defined for the PIC24F, so work around with an #ifdef. This is _PERSISTENT so that it survives the resets which occurs immeidately after the default interrupt handler _DefaultInterrupt copies INTTREG to this variable.
Definition at line 104 of file pic24_util.c.
_PERSISTENT const char* sz_lastError |
Persistent storeage for an error message, typically set by reportError and reported at reset by printResetCause.
Definition at line 93 of file pic24_util.c.