let me take a step back. You are being super helpful !!! Some time ago I as= ked for help in finding a project that had an associated assembly code fi= le I could use to learn assembly and how to assemble a program for my 16f= 876. From that I hoped to be able to start to understand the things you t= alk about (registers, instruction sets etc.). The individual helping me a= t the time said that this project by just changing the 16f84 to 16f876 wo= uld be what I could use: http://www.piclist.org/techref/piclist/cheapic/bincnt.htm Looks like that may have been bad advice as I am more of a newbie than was = assumed I guess. So I don't want to waste your time. I think I need to go= find a simple program written for the 16F876 to start with so I can lear= n. Trying to port from the 16f84 is out of my league at this point from w= hat you describe.=20 As for the crystal I am using well I did not know that made much difference= . I am using a 20 khz resonator and the project uses a 32.768 Khz Crystal= so I figured that it would be fine just not accurate and just not 1 seco= nd between changes so the timing would be off. Guess I may be wrong on th= at. Maybe if you know a simple project like this one with assembly source code = written for the 16F876 that may be better for me at this point. I will tr= y to "google" to find one. SORRY TO SHOUT BUT I REALLY APPRECIATE THE HELP BY EVERYONE !!!! Also I tried this as you recommended (gave it the old college try): ;-----------------------------------------------------------------------; ; 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 it o= ver. ERRORLEVEL -224 ; supress annoying message because of tris __CONFIG _PWRTE_ON & _LP_OSC & _WDT_OFF ; configuration switches ORG 0 ; start a 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 ; ;-----------------------------------------------------------------------; movlw B'00000000' ; all bits low in W MOVWF TRISA ; contents of W copied to PORT A ... MOVWF TRISB ; and PORT B MOVWF TRISC movlw B'00000100' ; pull-ups active ; prescalar assigned to TMR0 and set 1:32 MOVWF OPTION_REG ; rolls over each second =20 ;-----------------------------------------------------------------------; ; This is the main program ; ;-----------------------------------------------------------------------; clrf PORTB ; start with zero loop: incf PORTB, f ; add 1 to port B btfss INTCON, T0IF ; wait on T0IF to be set goto $ -1 bcf INTCON, T0IF ; clear the interrupt flag goto loop end ; end of program I then get the following on build: Deleting intermediary files... done. Executing: "C:\Program Files\MPLAB IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F87= 6 "Binarycounter_876.asm" /l"Binarycounter_876.lst" /e"Binarycounter_876.= err" Message[302] C:\16F876 PROJECTS\BINARYCOUNTER_876.ASM 19 : Register in oper= and not in bank 0. Ensure that bank bits are correct. Message[302] C:\16F876 PROJECTS\BINARYCOUNTER_876.ASM 20 : Register in oper= and not in bank 0. Ensure that bank bits are correct. Message[302] C:\16F876 PROJECTS\BINARYCOUNTER_876.ASM 21 : Register in oper= and not in bank 0. Ensure that bank bits are correct. Message[302] C:\16F876 PROJECTS\BINARYCOUNTER_876.ASM 24 : Register in oper= and not in bank 0. Ensure that bank bits are correct. Loaded C:\16f876 Projects\Binarycounter_876.COD BUILD SUCCEEDED: Mon Mar 08 17:36:48 2004 Since the build did succeed I tried it but still does not work :-(( -----Original Message----- From: Jan-Erik Soderholm To: PICLIST@MITVMA.MIT.EDU Date: Mon, 8 Mar 2004 22:48:53 +0100 Subject: Re: [PIC:] Newbie trying to assemble using MPASM for 16f876 Richard S wrote : > Jan-Erik: > I tried to find the information in the datasheet (yes I found > the datasheet :-) Which data sheet ? The number at the bottom of each page... > I also set to US-ASCII hope its better > now thanks for that info. Now TRISA seems to be what is in > the data sheet but OPTION_REG seems to be what is used in the > datasheet not OPTION. Well, "TRIS" and "OPTION" was two valid instructions some time ago. They are still used in your code below, and should be replaced with the MOVWF instruction. "TRISA", "TRISB" and "TRISB" as well as "OPTION_REG" are *registers* (SFR's). I think you mixed register names with instructions... > I assembled the program with > OPTION_REG and I get a warning since apparently the > p16f876.inc supplied with MPLAB does not have this referenced > in it but it does have the OPTION referenced and that is a > clean build. replace : tris PORTA tris PORTB tris PORTC with : MOVWF TRISA MOVWF TRISB MOVWF TRISC and : option with : MOVWF OPTION_REG Now, as I said, this is probably not your problem, but I think you shold change them anyway. That will make the code easier to read for us who never used the TRIS and OPTION instructions. > I tried both builds anyway and neither seem to > work. No, since you mixed up register names with instructions. > Now as you justly put it how do I know its not working. > What I mean is that after flashing the 16f876 with the hex > file the LED's do nothing. I then do a POR and still nothing. OK, just a quick check. From the "__CONFIG" statement in your code, your use the "low power osc" ("_LP_OSC"). What crystal are you using ? And have you ported the __CONFIG statement from the 16F84 to the 16F876 at all ? The __CONFIG statement seems pretty short for a 16F876... > You stated "Make sure that interrupts are disabled by > clearing the GIE flag. Proaby not the problem here either, > but anyway..." I did not do this yet as I am not up to the > level of such things yet. Yes, that's why you should make sure that GIE is cleared, since you don't use interrupts ! Now, I think that GIE should be cleared from POR, but just to be sure... > I am still learning by getting > somethiong done by someone else running first and go from > there. This is the first assembly project I tried Part of the problem is that it's a porting effort at the same time. The original code was for a 16F84, right ? Whoever wrote that could have left things in there POR-state. And newer processors have a lot of new stuff that might play a role here, like the parameters to the __CONFIG statement. > > Alex: > On p149 It has a number at the bottom > the specification states for DC operation that any > I/O pin can source or sink 25mA and the maximum total current > is 200 mA all ports. Page 149 ??? What data sheet are you using ? I have the latest data sheet for both 16F876 (DS30292C) and 16F876A (DS30292C, and none of them have anything about that on page 149... Regards Jan-Erik. -- 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 list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics