Skip to content

Instantly share code, notes, and snippets.

@joeynovak
Last active June 6, 2020 00:33
Show Gist options
  • Save joeynovak/ad825078df70c26715d698681e7a2677 to your computer and use it in GitHub Desktop.
Save joeynovak/ad825078df70c26715d698681e7a2677 to your computer and use it in GitHub Desktop.
Pic16 debugging by pulling RB7 Low
#define bump(x) LATB7 = 1; __delay_us(x); LATB7 = 0; __delay_us(x);
#define bumpIfBitSet(x, y) if(x){ bump(y * 2) } else { bump(y) }
TRISBbits.TRISB7 = 0;
bump(10);
bumpIfBitSet(PCONbits.STKOVF, 50);
bumpIfBitSet(PCONbits.STKUNF, 50);
bumpIfBitSet(PCONbits.nRWDT, 50);
bumpIfBitSet(PCONbits.nRMCLR, 50);
bumpIfBitSet(PCONbits.nRI, 50);
bumpIfBitSet(PCONbits.nPOR, 50);
bumpIfBitSet(PCONbits.nBOR, 50);
bumpIfBitSet(STATUSbits.nTO, 50);
bumpIfBitSet(STATUSbits.nPD, 50);
@joeynovak
Copy link
Author

Allows you to easily see the status and pcon bits that indicate why a device reset.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment