.equ __P24FJ64GA002,1 ;required "boiler-plate" (BP) .include "p24Fxxxx.inc" ;BP #include "xc.inc" ;BP ;the next two lines set up the actual chip for operation - required config __CONFIG2, POSCMOD_NONE & I2C1SEL_PRI & IOL1WAY_OFF & OSCIOFNC_ON & FCKSM_CSECME & FNOSC_FRCPLL & SOSCSEL_LPSOSC & WUTSEL_FST & IESO_OFF config __CONFIG1, FWDTEN_OFF & COE_OFF & BKBUG_OFF & GWRP_OFF & GCP_OFF & JTAGEN_OFF .align 2 ;need this so that we have the next word at even address .text ;BP (put the following data in ROM(program memory)) .global _main ;BP ;because we are using the C compiler to assemble our code, we need a "_main" label ;somewhere. (There's a link step that looks for it.) _main: bclr CLKDIV,#8 ;BP mov #0xffff,w0 mov w0,LATB ;make all bits in LATB SFR 1 mov #3,w0 mov w0,TRISB ;make bits 15-2 of PORTB outputs (RB0 and RB1 remain inputs) mov #0x9fff,w0 mov w0,AD1PCFG ;PORTB will be digital, not analog! bset TRISA,#0 ;PORTA, bit 0, will be an input (safety first!) bset CNPU1,#2 ;turns on internal Pull UP on CN01 (RA0) .end