Microchip Technology ICD 3 In-Circuit Debugger DV164035 DV164035 Manuel D’Utilisation

Codes de produits
DV164035
Page de 108
Tutorial
© 2008 Microchip Technology Inc.
DS51766A-page 31
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       0
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;  //display on port LEDs
      }// End of if...
    }// End of while loop...
}// End of main()...