Monday, July 5, 2010

External Triggering Using ICD 2



Based on some experiments from NIEDZIELSKI.COM, it is said that external triggering can be archived by simply sending a pulse to PGC and PGD simultaneously as shown in the diagram.

Here is the sample code provided:

/*******************************************************************************
PIC18F4550 infinite breakpoints C example.
Created:  Wednesday, October 3, 2007 [Stephen Niedzielski]
Modified: Wednesday, October 3, 2007 [Stephen Niedzielski]
*******************************************************************************/

/****************** Includes. ******************/
#include <p18f4550.h> /* PIC18F4550 symbolics. */

/****************** Configuration bits. ******************/
/* Watch dog timer disabled. */
#pragma config WDT    = OFF
/* PORTB 4:0 digital IO. */
#pragma config PBADEN = OFF

/****************** Macros. ******************/
/* Breakpoint. */
#define Break(); \
PORTBbits.RB0 = 1; \
PORTBbits.RB0 = 0; \
Nop(); \
Nop();

void main(void)
{
/****************** Watch dog timer setup. ******************/
/* Disable the watch dog timer. */
WDTCONbits.SWDTEN = 0;

/****************** Breakpoint setup. ******************/
/* Turn off RB0 and RB1. */
PORTBbits.RB0 = 0;
PORTBbits.RB1 = 0;
/* PORTB digital IO on all channels. */
ADCON1 = 0x0F;
/* RB0 to output, RB1 to input. */
TRISBbits.TRISB0 = 0;
TRISBbits.TRISB1 = 1;

/* Wait for input on RB1. */
while( !PORTBbits.RB1 )
{
}

Break();
Nop(); /* Pop out of breakpoint here. */
Nop();
Nop();

}

*try it at your own risk :)

No comments:

Post a Comment