counter.c
/*****************************************************************************
* MPLAB ICD 3 In-Circuit Debugger Tutorial
* Counting program
*
*****************************************************************************
* Demo Board:
Explorer 16
* Processor:
PIC24FJ128GA010
* Compiler:
MPLAB C30
* Linker:
MPLAB LINK30
* Company:
Microchip Technology Incorporated
*
*****************************************************************************/
#include "p24FJ128GA010.h"
// Set up configuration bits
_CONFIG1( JTAGEN_OFF & GCP_OFF & GWRP_OFF & COE_OFF & FWDTEN_OFF & ICS_PGx2)
_CONFIG2( FCKSM_CSDCMD & OSCIOFNC_ON & POSCMOD_HS & FNOSC_PRI )
void TimerInit(void);
unsigned char TimerIsOverflowEvent(void);
// Set up user-defined variables
#define
INIT_COUNT
unsigned int counter;
int main(void)
{
// Set up PortA IOs as digital output
AD1PCFG = 0xffff;
TRISA = 0x0000;
// Set up Timer1
TimerInit();
// Initialize variables
counter = INIT_COUNT;
while (1) {
// Wait for Timer1 overflow
if (TimerIsOverflowEvent()){
counter++;
//increment counter
PORTA = counter;
}// End of if...
}// End of while loop...
}// End of main()...
© 2008 Microchip Technology Inc.
0
//display on port LEDs
Tutorial
DS51766A-page 31
Need help?
Do you have a question about the MPLAB ICD 3 and is the answer not in the manual?