Jinx: I tried to piece together a new vertion of the code with what you gave me b= ut I can not get it to build so I missed something. Here is what I got by= cut and pasting you input: ;-----------------------------------------------------------------------; ; BINCNT.ASM Counts in binary on LEDs ( RB0 - RB4 ) ; ;-----------------------------------------------------------------------; ;-----------------------------------------------------------------------; ; The next 6 lines are directions to the assembler ; ;-----------------------------------------------------------------------; LIST P=3D16F876 ; tells which processor is used INCLUDE "p16f876.inc" ; defines various registers etc. Look ERRORLEVEL -224 ; supress annoying message from tris __CONFIG _PWRTE_ON & _HS_OSC & _WDT_OFF ; config. switches CBLOCK H'20' ; set up general registers starting at ; address 32 counter ; a general counting register ENDC ; end of register definitions ORG 0 ; start at program memory location zero ;----------------------------------------------------------------------; ; First we set up all bits of PORT A and B as outputs ; ; and set bits in the OPTION register concerning TMR0 ; ;----------------------------------------------------------------------; =09=09banksel trisa ;switch to bank1 =09clrf trisa ;set A and B as all outputs =09clrf trisb =09movlw b'00000101' =09=09=09; 0 PortB pull-ups enabled =09=09=09; 0 =09=09=09; 0 internal TMR0 source =09=09=09; 0 =09=09=09; 0 pre-scaler -> TMR0 =09=09=09; =09=09=09; 1 101 =3D /64 pre-scaler =09=09=09; 0 =09=09=09; 1 =09movwf option_reg ;You also need to set the analogue/digital status of PortA. This ;can be found in Section 11 of DS30292B (F87x manual) =09movlw b'00000110' ;set to all digital =09movwf adcon1 =09banksel porta ;switch back to bank0 ;----------------------------------------------------------------------; ; This is the main program ; ;----------------------------------------------------------------------; clrf counter again: incf portb ;"f" is default decfsz counter goto loop goto again ;because when decfsz counter is true, counter=3D0 and then you'd ;jumped to a movlw 255 movwf counter, which is extraneous, unless ;you actually wanted to skip a procedure when counter=3D0. Otherwise ;just clear it once and let it repeatedly roll under on its own. In your ;case you don't even really need to initially clear it, but actively cleari= ng ;variables can be a good practice (especially if they pop up in other ;routines and you get unexpected results) end ; end of program The output of the build with the errors is: Deleting intermediary files... done. Executing: "C:\Program Files\MPLAB IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F87= 6 "Binarycounter_876_V2.asm" /l"Binarycounter_876_V2.lst" /e"Binarycounte= r_876_V2.err" Error[113] C:\16F876 PROJECTS\BINARYCOUNTER_876_V2.ASM 23 : Symbol not pr= eviously defined (trisa) Error[113] C:\16F876 PROJECTS\BINARYCOUNTER_876_V2.ASM 24 : Symbol not pr= eviously defined (trisa) Error[113] C:\16F876 PROJECTS\BINARYCOUNTER_876_V2.ASM 25 : Symbol not pr= eviously defined (trisb) Error[113] C:\16F876 PROJECTS\BINARYCOUNTER_876_V2.ASM 36 : Symbol not pr= eviously defined (option_reg) Error[113] C:\16F876 PROJECTS\BINARYCOUNTER_876_V2.ASM 42 : Symbol not pr= eviously defined (adcon1) Error[113] C:\16F876 PROJECTS\BINARYCOUNTER_876_V2.ASM 44 : Symbol not pr= eviously defined (porta) Message[305] C:\16F876 PROJECTS\BINARYCOUNTER_876_V2.ASM 49 : Using default= destination of 1 (file). Error[113] C:\16F876 PROJECTS\BINARYCOUNTER_876_V2.ASM 49 : Symbol not pr= eviously defined (portb) Message[305] C:\16F876 PROJECTS\BINARYCOUNTER_876_V2.ASM 50 : Using default= destination of 1 (file). Error[113] C:\16F876 PROJECTS\BINARYCOUNTER_876_V2.ASM 51 : Symbol not pr= eviously defined (loop) Halting build on first failure as requested. BUILD FAILED: Tue Mar 09 01:49:52 2004 Thanks for the help :-)) -----Original Message----- From: Jinx To: PICLIST@MITVMA.MIT.EDU Date: Tue, 9 Mar 2004 14:55:16 +1300 Subject: Re: [PIC:] Newbie trying to assemble using MPASM for 16f876 > Is this correct now for the 16f876? > > CBLOCK H'20' ; set up general registers starting at > ; address 32 Yup Could I suggest an alternative way to write this ? > movlw B'00000000' ; all bits low in W > BSF STATUS,RP0 > MOVWF TRISA ; make all bit of PORT A outputs ... > MOVWF TRISB ; and all bits of PORT B also > movlw B'00000101' ; TMR0 assigned to incr. on internal clk > BCF STATUS,RP0 > ; prescalar assigned to TMR0 and set 1:64 > ; bit 5 set means timer runs off RA4 > BSF STATUS,RP0 > MOVWF OPTION_REG ; W inserted into OPTION register >BCF STATUS,RP0 > ; check OPTION register in data sheet banksel trisa ;switch to bank1 clrf trisa ;set A and B as all outputs clrf trisb movlw b'00000101' movwf option_reg You also need to set the analogue/digital status of PortA. This can be found in Section 11 of DS30292B (F87x manual) movlw b'00000110' ;set to all digital movwf adcon1 banksel porta ;switch back to bank0 > again: movlw D'255' ; set up a counter to count down from 255 > movwf counter > incf PORTB, f ; add 1 to port B, (next binary byte) > decfsz counter, f ; decrement counter, skip if zero > goto loop ; if counter not zero, wait on T0IF again > goto again Could be re-written as clrf counter again incf portb ;"f" is default decfsz counter goto loop goto again because when decfsz counter is true, counter=3D0 and then you'd jumped to a movlw 255 movwf counter, which is extraneous, unless you actually wanted to skip a procedure when counter=3D0. Otherwise just clear it once and let it repeatedly roll under on its own. In your case you don't even really need to initially clear it, but actively clearin= g variables can be a good practice (especially if they pop up in other routines and you get unexpected results) -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.