.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_EC & I2C1SEL_SEC & IOL1WAY_OFF & OSCIOFNC_ON & FCKSM_CSECME & FNOSC_FRC & SOSCSEL_LPSOSC & WUTSEL_FST & IESO_OFF config __CONFIG1, WDTPS_PS1 & FWPSA_PR32 & WINDIS_OFF & FWDTEN_OFF & COE_ON & BKBUG_ON & GWRP_ON & GCP_ON & JTAGEN_OFF .align 2 ;need this so that we have the next word at even address ;;stack: ;; .space 32 ;this will be our stack area, from var_16_bit to here .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 #stack,w15 ;initialize the stack pointer ; set up PORTB bit 0 for output. mov #0,w0 mov w0,TRISB ;make PORTB output mov #0x9fff,w0 mov w0,AD1PCFG ;PORTB will be digital, not analog! mov #5,w3 loop1: btg PORTB, #0 dec WREG3 bra nz, loop1 mov #3, w3 loop2: btg PORTB, #0 dec WREG3 bra z, endLoop2 bra loop2 endLoop2: mov #3, w0 clr PORTB loop3: inc PORTB cp PORTB bra nz, loop3 endLoop3 repeat #3 inc PORTB lpbk: bra lpbk .end