Searching \ for '[PIC:] Newbie trying to assemble using MPASM for 1' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/begin.htm?key=asm
Search entire site for: 'Newbie trying to assemble using MPASM for 1'.

Exact match. Not showing close matches.
PICList Thread
'[PIC:] Newbie trying to assemble using MPASM for 1'
2004\03\08@014741 by Richard S

picon face
I am trying to assemble the code for the following project so that it
will run on my 16F876 since I do not have a 16F84.

http://www.piclist.org/techref/piclist/cheapic/bincnt.htm

I can sucessfully assembe the code there by pasting it into a file and
naming it Name.asm using the p16f84.inc file included with the MPASM
download from microchip. The I searched the web for an include file for
the 16F876 found it copied it to a text file and saved it as
p16f876.inc.and placed this file in the same directory as the p16f84.inc
file.  I then edited the program for this project by replacing 16F84
with  16F876.

The first error I get is "Error[132]
C:\DOCUME~1\ADMINI~1.COM\DESKTOP\MPASM&~1\ASM21500\BINARY~2.ASM 7 :
Unknown processor (16F876)"

The I get many OPCODE errors but I assume (maybe incorrectly) that these
are generated as a result of the Unknown Processor error..

I guess fiirst I don't know if  MPASM can assemble for the 16F876 so
that would be good to know so I know to look elsewhere for my problem
if MPASM can assemble code for the 16F876 (I do not have the 16F876A).

I am a newbie so please go easy. Any help appreciated

Thanks all

--
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

2004\03\08@022555 by Scott Pierce

flavicon
face
MPLAB does support all processors Microchip makes.  The include file for
the 16F876 will be in your MPLAB director such as: C:\Program Files\MPLAB
IDE\MCHIP_Tools.  The file name will be: P16F876.INC.

Make sure you set MPLAB up to know which processor you are using.  In
MPLAB, click on the "Configure" menu then click "Select Device".  From the
drop down menu select the 16F876.

What version of MPLAB are you using?  If you changed the project defaults,
you will also need to change the compiler option to "Microchip MPASM
Toolsuite.  Click on the "Project" menu then click on "Select Language
Toolsuite".  There'll be a drop down box where you can select the
"Microchip MPASM Toolsuite"  That should get you going.

I got the code you pointed to in your e-mail and put it into MPLAB and just
changed the LIST and Include lines and it compiled correctly.  Here it is:

;-----------------------------------------------------------------------;
; BINCNT.ASM         Counts in binary on LEDs ( RB0 - RB4 )             ;
;-----------------------------------------------------------------------;
;-----------------------------------------------------------------------;
;         The next 6 lines are directions to the assembler              ;
;-----------------------------------------------------------------------;
        LIST P=16F876           ;  tells which processor is used
        INCLUDE "p16f876.inc"   ;  defines various registers etc. Look it
over.
        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
         tris PORTA           ; contents of W copied to PORT A ...
         tris PORTB           ; and PORT B
         movlw B'00000100'    ; pull-ups active
                              ; prescalar assigned to TMR0 and set 1:32
         option               ; rolls over each second

;-----------------------------------------------------------------------;
;                      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


Scott Pierce




At 10:47 PM 3/7/2004, you wrote:
{Quote hidden}

--
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

2004\03\08@023629 by Jinx

face picon face
> I guess fiirst I don't know if  MPASM can assemble for the 16F876

MPASM 3.30 has 876 and 876A in the list of supported PICs

In the target folder for MPASM,

\Program Files\MPLAB IDE\MCHIP_Tools

you should find P16f876.inc and P16f876a.inc

--
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

2004\03\08@024044 by Jinx

face picon face
> MPLAB does support all processors Microchip makes

That's true of the latest releases, but it's not so long ago (6.00
I think was the abomination I tried), that several popular PICs
and the whole 17 series were not supported

--
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

2004\03\08@034215 by Jan-Erik Soderholm

face picon face
Richard S wrote :

> I am trying to assemble the code for the following project so that it
> will run on my 16F876 since I do not have a 16F84.
>
> http://www.piclist.org/techref/piclist/cheapic/bincnt.htm
>
> I can sucessfully assembe the code there by pasting it into a file and
> naming it Name.asm using the p16f84.inc file included with the MPASM
> download from microchip. Then I searched the web

The "web" ?? But you do have MPLAB, right ? Did you look there ?

> for an include file for the 16F876 found it

Don't use that one, use the one delivered with MPLAB...

> copied it to a text file and saved it as
> p16f876.inc.and placed this file in the same directory as the
> p16f84.inc file.

It should already be in the "correct" directory, no reason to
copy it anyware.

> I then edited the program for this project by replacing 16F84
> with  16F876.
> The first error I get is "Error[132]
> C:\DOCUME~1\ADMINI~1.COM\DESKTOP\MPASM&~1\ASM21500\BINARY~2.ASM 7 :
> Unknown processor (16F876)"

You have to both change your source code *and* the setting in MPLAB.

>
> The I get many OPCODE errors but I assume (maybe incorrectly)
> that these are generated as a result of the Unknown Processor error..

Maybe, impossible to say since you don't give any examples.

> I guess fiirst I don't know if  MPASM can assemble for the 16F876

Yes, as far as I know.

> so that would be good to know so I know to look elsewhere for my problem
> if MPASM can assemble code for the 16F876 (I do not have the 16F876A).
>
> I am a newbie so please go easy. Any help appreciated

Sure !

Fix the things above and tell us what happens. If you get errors,
tell us what they are and not just "I get errors". :-) :-)

Best 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

2004\03\08@094304 by Richard S

picon face
Thanks all made some progress with your help. After you get done laughing I need more help :-)

I will post the explicit errors next time I thought it would have been too much text to show but I guess you are right the experts know what to look for given ALL the information.

I downloaded MPASM from Michrochip and was using that directly to try to assemble with. I downloaded MPLAB but did not use that at first. I appreciate the effort to modify the file and test that it builds a tremendous help. I installed MPLAB and see that it is a development environment with simulation capabilty (No idea yet what to do with this simulation capability yet). First just getting a build and a *.hex file to use seems a good place to start.

My edit was identical except I had put a TRISC after the TRISB to set all bits such that none were floating (just thought this was needed based on the write-up but I am not really at that level of understanding yet). I used the Project wizard and set it for the 16F876 and to use the MPASM as recommended.

With the file as presented in the reply by Scott I get the following  output.  I would like to understand what the information is telling me but it looks like I did get a build to complete. Warnings I know are not fatal but seems like I better understand what it is trying to tell. Here is the output:

Deleting intermediary files... done.
Executing: "C:\Program Files\MPLAB IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F676 "Binarycounter_876.asm" /l"Binarycounter_876.lst" /e"Binarycounter_876.err"
Warning[215] C:\16F876 PROJECTS\BINARYCOUNTER_876.ASM 7 : Processor superceded by command line.  Verify processor symbol.
Message[301] C:\PROGRAM FILES\MPLAB IDE\MCHIP_TOOLS\P16F876.INC 37 : MESSAGE: (Processor-header file mismatch.  Verify selected processor.)
Loaded C:\16f876 Projects\Binarycounter_876.COD
BUILD SUCCEEDED: Mon Mar 08 09:18:18 2004

Thanks again all. I really appreciate it I was totally frustrated when I posted this need for help around 2am my time. Now it looks like I am close to moving on and doing some project changes.
{Original Message removed}

2004\03\08@100414 by Alexander JJ Rice

picon face
> Deleting intermediary files... done.
> Executing: "C:\Program Files\MPLAB IDE\MCHIP_Tools\mpasmwin.exe" /q
> /p16F676 [WOOPS!!!!]"Binarycounter_876.asm" /l"Binarycounter_876.lst"
> /e"Binarycounter_876.err"
> Warning[215] C:\16F876 PROJECTS\BINARYCOUNTER_876.ASM 7 : Processor
> superceded by command line.  Verify processor symbol.
> Message[301] C:\PROGRAM FILES\MPLAB IDE\MCHIP_TOOLS\P16F876.INC 37 :
> MESSAGE: (Processor-header file mismatch.  Verify selected processor.)
> Loaded C:\16f876 Projects\Binarycounter_876.COD
> BUILD SUCCEEDED: Mon Mar 08 09:18:18 2004
>
> Thanks again all. I really appreciate it I was totally frustrated when I
> posted this need for help around 2am my time. Now it looks like I am
> close to moving on and doing some project changes.

You have accidentally set you processor as a 676 not an 876 - i
put[WOOPS!!!] next to the error, the asswmbler is complaining that you
then have the wrong include file etc etc. Go to options > development mode
and set the processor as an 876 and all will be fine.

regards

alex

--
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

2004\03\08@104605 by Richard S

picon face
Think you very helpful the build is clean now.

Next problem:

I loaded the program onto my circuit but does not work. I have a jal writen blinking light program (I use the wisp628 to program with). I modified it to use RB0 and it works fine so I know my ciruit works. The circuit for this project uses the RB0 to RB3

Here is my program as I have it now can anyone see a reason this should not work.

Again appreciate the help

;-----------------------------------------------------------------------;
; BINCNT.ASM         Counts in binary on LEDs ( RB0 - RB4 )             ;
;-----------------------------------------------------------------------;
;-----------------------------------------------------------------------;
;         The next 6 lines are directions to the assembler              ;
;-----------------------------------------------------------------------;
       LIST P=16f876           ;  tells which processor is used
       INCLUDE "p16f876.inc"   ;  defines various registers etc. Look it over.
       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
        tris PORTA           ; contents of W copied to PORT A ...
        tris PORTB           ; and PORT B
        tris PORTC           ; and PORT C
        movlw B'00000100'    ; pull-ups active
                             ; prescalar assigned to TMR0 and set 1:32
        option               ; rolls over each second
;-----------------------------------------------------------------------;
;                      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

{Original Message removed}

2004\03\08@110439 by Alexander JJ Rice

picon face
On Mon, 8 Mar 2004 10:44:21 -0500, Richard S <spam_OUTrschulTakeThisOuTspamMYREALBOX.COM> wrote:

> Think you very helpful the build is clean now.
>
> Next problem:
>
> I loaded the program onto my circuit but does not work. I have a jal
> writen blinking light program (I use the wisp628 to program with). I
> modified it to use RB0 and it works fine so I know my ciruit works. The
> circuit for this project uses the RB0 to RB3
>
> Here is my program as I have it now can anyone see a reason this should
> not work.

Port B has weak pullup's rather than full cmos drivers. The pull ups can
only manage a few uA of current - not enough for an LED, either swap it
round so that the LED's are connected to the positive rail and you pull
the pin down to turn them on or use another port.

Regards

Alex

--
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

2004\03\08@110847 by Jan-Erik Soderholm

face picon face
Richard S wrote :

> Here is my program as I have it now can anyone see a reason
> this should not work.

First one thing...
Try to set you mail tool so it sends "plain text/US-ASCII". Your
used "plain text/UTF-8", which (at least in my tool) gives
vaiable character spacing and hard to read code. Next, try to keep
each line not longer then aprox 66 characters (or at least as short
as possible) to avoid split lines.

Now, look up the instructions TRIS and OPTION in your
data sheet (if you can find them at all (the intructions ! Not
the data sheets :-) :-) )). They are both "depricated" and
should not be used on newer PICs. Probably not the
problem here, but why take the risk :-)

Make sure that interrupts are disabled by clearing the GIE
flag. Proaby not the problem here either, but anyway...

And finaly, how do you *know* that the program doesn't
work ? What happens if anything happens at all ?

Good luck !

Jan-Erik.

{Quote hidden}

--
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

2004\03\08@161344 by Richard S

picon face
Did some digging in the specification. I am still learning how to understand the datasheet so I can be reading it wrong so here is what I found:

Jan-Erik:
I tried to find the information in the datasheet (yes I found the datasheet :-) . 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.  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. I tried both builds anyway and neither seem to work. 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.

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. 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 my others were with the JAL program.

Alex: On p149 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. The circuit has only 4 LED's each with a 330 ohm resistor in series (15 mA per LED if I got that right) so it appears like I should be OK. I just want to check to see if I am OK so I don't damage my 16F876 !!! With a different program the LED flashes fine on RB0.

ANY other help appreciated


{Original Message removed}

2004\03\08@164916 by Jan-Erik Soderholm

face picon face
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

2004\03\08@175919 by Richard S

picon face
let me take a step back. You are being super helpful !!! Some time ago I asked for help in finding a project that had an associated assembly code file I could use to learn assembly and how to assemble a program for my 16f876. From that I hoped to be able to start to understand the things you talk about (registers, instruction sets etc.). The individual helping me at the time said that this project by just changing the 16f84 to 16f876 would 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 learn. Trying to port from the 16f84 is out of my league at this point from what you describe.
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 second between changes so the timing would be off. Guess I may be wrong on that.

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 try 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=16f876           ;  tells which processor is used
       INCLUDE "p16f876.inc"   ;  defines various registers etc. Look it over.
       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
;-----------------------------------------------------------------------;
;                      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 /p16F876 "Binarycounter_876.asm" /l"Binarycounter_876.lst" /e"Binarycounter_876.err"
Message[302] C:\16F876 PROJECTS\BINARYCOUNTER_876.ASM 19 : Register in operand not in bank 0.  Ensure that bank bits are correct.
Message[302] C:\16F876 PROJECTS\BINARYCOUNTER_876.ASM 20 : Register in operand not in bank 0.  Ensure that bank bits are correct.
Message[302] C:\16F876 PROJECTS\BINARYCOUNTER_876.ASM 21 : Register in operand not in bank 0.  Ensure that bank bits are correct.
Message[302] C:\16F876 PROJECTS\BINARYCOUNTER_876.ASM 24 : Register in operand 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 removed}

2004\03\08@181202 by Richard S

picon face
Critical correction to my last e-mail!!

I am using a 20 MHZ resonator not a 20KHZ so that is probably the problem as the Crystal is a 32.768 KHZ so mine is probably too fast to see the LED's I would guess. Maybe I need to buy a 32.768 KHZ Crystal.

{Original Message removed}

2004\03\08@181823 by Andrew Warren

flavicon
face
Richard S <.....PICLISTKILLspamspam@spam@mitvma.mit.edu> wrote:

> Critical correction to my last e-mail!!
>
> I am using a 20 MHZ resonator not a 20KHZ so that is probably the
> problem as the Crystal is a 32.768 KHZ so mine is probably too fast to
> see the LED's I would guess. Maybe I need to buy a 32.768 KHZ Crystal.

   You'll want to change "_LP_OSC" to "_HS_OSC".

   Also, the advice you were given (to replace the TRIS and OPTION
   instructions) was incomplete... The person giving the advice
   neglected to tell you that you'll need to change pages before
   the MOVWFs (with "BSF STATUS,RP0" and change back after (with
   "BCF STATUS,RP0").

   -Andy

=== Andrew Warren -- aiwspamKILLspamcypress.com
=== Principal Design Engineer
=== Cypress Semiconductor Corporation
===
=== Opinions expressed above do not
=== necessarily represent those of
=== Cypress Semiconductor Corporation

--
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

2004\03\08@193415 by Richard S

picon face
Warren / Jan-Erik

I found at the link for this project that they had a version for a 4mHz that used a delay to slow things down. Using both of your edits rolled into the 4mhz version it now works :))

Before I now try to dig into the very long datasheet to understand how this code realy works I would be very appreciative if you could take a look and see If i have the code right so I don't try to learn from bad code.

Few things that bother me:

It only counts using 3 LED's so it counts up to 7 and then starts at 0 again the circuit has 4 LED's so I figure I still have something wrong as its not using the 4th LED.

I also get this build output so it does not seem entirely right:

Deleting intermediary files... done.
Executing: "C:\Program Files\MPLAB IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F876 "Binarycounter_876.asm" /l"Binarycounter_876.lst" /e"Binarycounter_876.err"
Message[302] C:\16F876 PROJECTS\BINARYCOUNTER_876.ASM 25 : Register in operand not in bank 0.  Ensure that bank bits are correct.
Message[302] C:\16F876 PROJECTS\BINARYCOUNTER_876.ASM 26 : Register in operand not in bank 0.  Ensure that bank bits are correct.
Message[302] C:\16F876 PROJECTS\BINARYCOUNTER_876.ASM 32 : Register in operand not in bank 0.  Ensure that bank bits are correct.
Loaded C:\16f876 Projects\Binarycounter_876.COD
BUILD SUCCEEDED: Mon Mar 08 19:22:42 2004

Thanks again. Guess progress however slow is still progress :-))

Here is my code:

;-----------------------------------------------------------------------;
; BINCNT.ASM         Counts in binary on LEDs ( RB0 - RB4 )             ;
;-----------------------------------------------------------------------;
;-----------------------------------------------------------------------;
;         The next 6 lines are directions to the assembler              ;
;-----------------------------------------------------------------------;
       LIST P=16F876           ;  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'0C'           ;  set up general registers starting at
                              ;  address 12
         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          ;
;----------------------------------------------------------------------;
        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

;----------------------------------------------------------------------;
;                      This is the main program                        ;
;----------------------------------------------------------------------;
        clrf PORTB           ;  start with zero in port B
                             ;  all LEDs off 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)

; The instructions from loop to goto loop are executed about 61 times
; a second.   The majority of this time is taken up in the 2 instruction
; loop made up by the next two instructions.  This simply waits for the ; timer zero interrupt flag to be set which happens after timer zero ; overflows.  TMR0 overflows after going from 255 to 0.  TMR0 normally
; runs at a rate of crystal freq/4 but we have added a 1:64 prescalar ; which make the increment every 64 microseconds or a overflow after
; 256 * 64 = 16384 usec.  61 of these gives 999424 usec.

loop:    btfss INTCON, T0IF   ;  wait on T0IF set, skip next when set
        goto $ -1            ;  T0IF not set yet continue to loop
        bcf INTCON, T0IF     ;  clear interrupt flag, timer runs always
        decfsz counter, f    ;  decrement counter, skip if zero
        goto loop            ;  if counter not zero, wait on T0IF again

;  once 255 cycles of waiting for T0IF have happened we go back and
;  reset the counter to 255 and bump the binary number displayed by one

        goto again

        end                   ; end of program


{Original Message removed}

2004\03\08@194451 by Jinx

face picon face
> Warren / Jan-Erik

> CBLOCK H'0C'  ;  set up general registers starting at address 12

('scuse me butting in)

RAM starts at 0x20 on the 876

0X0C is RAM in the 84, PIR1 on the 876/877

--
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

2004\03\08@201433 by Richard S

picon face
Jinx

Butt in all you want I appreciate the help !!

Is this correct now for the 16f876?

CBLOCK H'20'           ;  set up general registers starting at
                              ;  address 32

Thanks

{Original Message removed}

2004\03\08@205452 by Jinx

face picon face
> 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 ?

{Quote hidden}

   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)

<snip>

>         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=0 and then you'd
jumped to a movlw 255 movwf counter, which is extraneous, unless
you actually wanted to skip a procedure when counter=0. 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 clearing
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

2004\03\08@210527 by Jinx

face picon face
>         movlw B'00000101'    ;  TMR0 assigned to incr. on internal clk
>         MOVWF OPTION_REG     ;  W inserted into OPTION register

BTW, one other thing I find useful

When addressing bits, especially in a control register where those
bits will be significant to the operation of the s/w, I include something
like this (lines up in MPLAB courier)

    movlw b'00000101'

;            0                PortB pull-ups enabled
;             0
;              0              internal TMR0 source
;               0
;                0            pre-scaler -> TMR0
;
;                 1           101 = /64 pre-scaler
;                  0
;                   1

It's the sort of feed-back you need when bug hunting

--
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

2004\03\08@215831 by Richard S

picon face
Jinx:

I will edit a copy of my curent *.asm with you alternate code and see if I can get it to work. Studying both versions should be a good learning experience.

I can see the advantage of your commenting to show what each bit means. I just started to learn MPLAB so not sure what you mean by "lines up in MPLAB courier" what is this courier? yea I know a dumb question.....

{Original Message removed}

2004\03\08@221747 by Jinx

face picon face
> MPLAB courier" what is this courier ?

Fixed-space font. I can't imagine anyone changing to a
proportional one from the (I think) default Courier

--
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

2004\03\08@221749 by Tony Nixon

flavicon
picon face
>I will edit a copy of my curent *.asm with you alternate code and see if I can get it to work. Studying both versions should be a good learning experience.
>
>
>

I have some introduction to PIC code examples in PDF format I can email
if you are interested (350K). It also explains getting started with MPLAB.

regards

Tony

--
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

2004\03\09@015437 by Richard S

picon face
Jinx:

I tried to piece together a new vertion of the code with what you gave me but 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=16F876           ;  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          ;
;----------------------------------------------------------------------;
               banksel trisa        ;switch to bank1
           clrf trisa                ;set A and B as all outputs
           clrf trisb
           movlw b'00000101'
                       ; 0 PortB pull-ups enabled
                       ; 0
                       ; 0 internal TMR0 source
                       ; 0
                       ; 0 pre-scaler -> TMR0
                       ;
                       ; 1 101 = /64 pre-scaler
                       ; 0
                       ; 1
           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
;----------------------------------------------------------------------;
;                      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=0 and then you'd
;jumped to a movlw 255 movwf counter, which is extraneous, unless
;you actually wanted to skip a procedure when counter=0. 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 clearing
;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 /p16F876 "Binarycounter_876_V2.asm" /l"Binarycounter_876_V2.lst" /e"Binarycounter_876_V2.err"
Error[113]   C:\16F876 PROJECTS\BINARYCOUNTER_876_V2.ASM 23 : Symbol not previously defined (trisa)
Error[113]   C:\16F876 PROJECTS\BINARYCOUNTER_876_V2.ASM 24 : Symbol not previously defined (trisa)
Error[113]   C:\16F876 PROJECTS\BINARYCOUNTER_876_V2.ASM 25 : Symbol not previously defined (trisb)
Error[113]   C:\16F876 PROJECTS\BINARYCOUNTER_876_V2.ASM 36 : Symbol not previously defined (option_reg)
Error[113]   C:\16F876 PROJECTS\BINARYCOUNTER_876_V2.ASM 42 : Symbol not previously defined (adcon1)
Error[113]   C:\16F876 PROJECTS\BINARYCOUNTER_876_V2.ASM 44 : Symbol not previously 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 previously 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 previously defined (loop)
Halting build on first failure as requested.
BUILD FAILED: Tue Mar 09 01:49:52 2004

Thanks for the help :-))


{Original Message removed}

2004\03\09@040325 by Jan-Erik Soderholm

face picon face
> Error[113]   C:\16F876 PROJECTS\BINARYCOUNTER_876_V2.ASM 23 :
> Symbol not previously defined (trisa)

So MPASM can not find "trisa". Have you looked for it ?

Have you enabled "case sensitivity" ?
(Or disabled case un-sensitivity", whatever...)
[Meny "Project" -> "Build Options" -> "Disable case sensitivity" checkbox.

As a quick check, you could just change one instance
of "trisa" to "TRISA" and see if one of the error goes away.

And have you looked in the "p16f876.inc" file ? How is
trisa/TRISA defined ?

But best is to just disable case sensitivity.

> Error[113]   C:\16F876 PROJECTS\BINARYCOUNTER_876_V2.ASM 51 :
> Symbol not previously defined (loop)
> [From line "goto loop", right ? ]

So MPASM can not find the "loop" label. Can you ? :-)
I can not, at least not in tje code included...

Another thing, have you checked the LST file ? There you will
get the error messages above lined up at the actual
code line. And you will get symbols lists and other things to
help debug the error messages.

/Jan-Erik.

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2004\03\09@065801 by Jinx

face picon face
> Symbol not previously defined (trisa)

etc etc etc

Sorry, my bad. As Jan-Erik says, case sensitivity will be the
fix. I generally use lower case (don't like the look of code that's
SHOUTING at me). You'll see a Case Sensitive box on the
MPASM screen, make sure it's unticked if you're going to use
any lower case. If you look in any .inc file you'll find it's all upper
case

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2004\03\09@070627 by Jan-Erik Soderholm

face picon face
Jinx wrote :

> If you look in any .inc file you'll find it's all upper case.

Hm, not *any* .inc file...

Many (well, at least some) 18F*.INC files have symbols
*both* in upper and lower case.

If you untick the case sensitivines (?) in those cases,
you'll get loads of "multiple defined symbol" or what ever
the message was :-)

Jan-Erik.

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2004\03\09@071249 by Jinx

face picon face
> Symbol not previously defined (loop)

My apologies. I snipped those three OK "loop" lines out when
I was trying to tidy up the others

;----------------------------------------

loop:    btfss INTCON, T0IF
        goto $ -1
        bcf INTCON, T0IF     ;
;----------------------------------------

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2004\03\09@094106 by Richard S

picon face
I REALLY APPRECIATE (now I will lower my voice) the help and you all sticking with me I am sure you sensed my frustration and lack of knowledge. I now have two programs working written differently that do the same thing that should get me going faster that I hoped. The support here is nothing short of outstanding.

Right on about the "CASE sensitivity" I thought only Linux was case sensitive. Question: thinking ahead what is the risk of being case insensitive I much prefer it.

Now I think I am ready to tacvkle the 200+ page datasheet and begin to understand in depth what these two programs are doing and how everything ties together.

I still don't know what limits the counter to count binary 000 to 111 and then restart at 000 does not continuously count up. That hopefully will be something I can figure out as I study what I have.
I think one I understand the following build log and how to fix it I am ready to tackle the datasheet and modify the code on my own and see what happens.

Code now looks like this (the Jinx one) but I get basically the same error with my other version. what do these unfatal failures mean I can't seem to find a sourse of information so I can understand for myself.

Build Log:
Deleting intermediary files... done.
Executing: "C:\Program Files\MPLAB IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F876 "Binarycounter_876_V2.asm" /l"Binarycounter_876_V2.lst" /e"Binarycounter_876_V2.err" /c-
Message[302] C:\16F876 PROJECTS\BINARYCOUNTER_876_V2.ASM 24 : Register in operand not in bank 0.  Ensure that bank bits are correct.
Message[302] C:\16F876 PROJECTS\BINARYCOUNTER_876_V2.ASM 25 : Register in operand not in bank 0.  Ensure that bank bits are correct.
Message[302] C:\16F876 PROJECTS\BINARYCOUNTER_876_V2.ASM 36 : Register in operand not in bank 0.  Ensure that bank bits are correct.
Message[302] C:\16F876 PROJECTS\BINARYCOUNTER_876_V2.ASM 42 : Register in operand not in bank 0.  Ensure that bank bits are correct.
Message[305] C:\16F876 PROJECTS\BINARYCOUNTER_876_V2.ASM 49 : Using default destination of 1 (file).
Message[305] C:\16F876 PROJECTS\BINARYCOUNTER_876_V2.ASM 54 : Using default destination of 1 (file).
Loaded C:\16f876 Projects\Binarycounter_876_V2.COD
BUILD SUCCEEDED: Tue Mar 09 09:11:43 2004

The source code:

;-----------------------------------------------------------------------;
; BINCNT.ASM         Counts in binary on LEDs ( RB0 - RB4 )             ;
;-----------------------------------------------------------------------;
;-----------------------------------------------------------------------;
;         The next 6 lines are directions to the assembler              ;
;-----------------------------------------------------------------------;
       LIST P=16F876           ;  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          ;
;----------------------------------------------------------------------;
               banksel trisa        ;switch to bank1
           clrf trisa                ;set A and B as all outputs
           clrf trisb
           movlw b'00000101'
                       ; 0 PortB pull-ups enabled
                       ; 0
                       ; 0 internal TMR0 source
                       ; 0
                       ; 0 pre-scaler -> TMR0
                       ;
                       ; 1 101 = /64 pre-scaler
                       ; 0
                       ; 1
           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
;----------------------------------------------------------------------;
;                      This is the main program                        ;
;----------------------------------------------------------------------;
        clrf counter
again:   incf  portb          ;"f" is default

loop:    btfss INTCON, T0IF
        goto $ -1
        bcf INTCON, T0IF ;
        decfsz counter
        goto loop

        goto  again

;because when decfsz counter is true, counter=0 and then you'd
;jumped to a movlw 255 movwf counter, which is extraneous, unless
;you actually wanted to skip a procedure when counter=0. 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 clearing
;variables can be a good practice (especially if they pop up in other
;routines and you get unexpected results)

        end                   ; end of program


Thanks again all :-)) Hope I can start asking inteligent questions soon.!!!


{Original Message removed}

2004\03\09@101815 by hael Rigby-Jones

picon face
{Quote hidden}

The assembler does not have the intelligence to keep track of which RAM bank
is selected.  Whenever you access a register that is not in Bank 0, the
assembler automaticaly spits out a warning, tell you to make sure that the
bank has been selected correctly, because it dosen't know.

Many people find this very annoying, but it is easy to remove the warning by
a couple of methods.  One is to use the errorlevel command within you source
code as follows:

errorlevel -302

This stops the assembler spitting out message 302.  You can re-enable it by
using errorlevel +302.  The trouble with this is that it is possible to be
writing or reading to completely the wrong bank and the assembler won't say
a word about it.

Another method is shown at
http://www.piclist.com/techref/microchip/mplab/msg302.htm  This at least
gives you some protection against making a silly banking error (that can
take hours to track down).

Once you have found you feet with basic use of the assembler, you may want
to start writing relocatable code.  A previous piclister Olin Lathrop, has
written a usefull set of tools that includes some macro's that (mostly) keep
track of your bank selection automaticly.  You can find them at
http://www.embedinc.com/pic/

Regards





=======================================================================
This e-mail is intended for the person it is addressed to only. The
information contained in it may be confidential and/or protected by
law. If you are not the intended recipient of this message, you must
not make any use of this information, or copy or show it to any
person. Please contact us immediately to tell us that you have
received this e-mail, and return the original to us. Any use,
forwarding, printing or copying of this message is strictly prohibited.
No part of this message can be considered a request for goods or
services.
=======================================================================
Any questions about Bookham's E-Mail service should be directed to
EraseMEpostmasterspam_OUTspamTakeThisOuTbookham.com.

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2004\03\09@113351 by Jan-Erik Soderholm

face picon face
> I still don't know what limits the counter to count binary
> 000 to 111 and then restart at 000 does not continuously
> count up. That hopefully will be something I can figure out
> as I study what I have.

The "incf  portb"  *could* be a problem. Try the following :

In the CBLOCK add a new variable, let's say "portb_tmp".

Then change :

>          clrf counter
> again:   incf  portb          ;"f" is default

to :

>          clrf counter
> again:   incf  portb_tmp, w
>          movwf portb

>
> Message[302] C:\16F876 PROJECTS\BINARYCOUNTER_876_V2.ASM 24 :
> Register in operand not in bank 0.  Ensure that bank bits are correct.

Just a warning...

> Message[305] C:\16F876 PROJECTS\BINARYCOUNTER_876_V2.ASM 49 :
> Using default destination of 1 (file).

The cause is here :
> again:   incf  portb          ;"f" is default

Note that the comment says the same thing as the message :-)

Regards
Jan-Erik.

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2004\03\09@113808 by Jan-Erik Soderholm

face picon face
Sorry, the code should have been :

> >          clrf counter
> > again:   incf  portb_tmp, w  ; inc portb_tmp and move to W.
> >          movwf portb_tmp    ; save incremented value.
> >          movwf portb       ; move to LEDs.

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2004\03\09@143753 by Richard S

picon face
I gave this change a try. The system still counts to 111 then either resets or rolls back over to 000 in an endless loop.

Good thing is I think you just taught me how to name a register. Use that name and tranfer data from one register to another using W as the intermediary. :-))

{Original Message removed}

2004\03\09@160955 by Randy Ott

flavicon
face
Are you sure it counts to 111 and resets to 000 or is that what you are seeing on the LEDs?  Maybe your'e not lighting all of them.

Randy Ott


Richard S <rschulspamspam_OUTMYREALBOX.COM> wrote:
I gave this change a try. The system still counts to 111 then either resets or rolls back over to 000 in an endless loop.

Good thing is I think you just taught me how to name a register. Use that name and tranfer data from one register to another using W as the intermediary. :-))

{Original Message removed}

2004\03\09@161334 by Jan-Erik Soderholm

face picon face
Richard S wrote :

> I gave this change a try. The system still counts to 111 then
> either resets or rolls back over to 000 in an endless loop.

But that is what you see on the LED's right ?
Can you make some simple change to you code
just to verify that you can lit up the other LEDs at all ?

What I'm trying to say is that, maybe the system *do*
count as it should, it just don't show on the LEDs.

> Good thing is I think you just taught me how to name a
> register. Use that name and tranfer data from one register to
> another using W as the intermediary. :-))

The reason fpr this change, is that you should generally speaking
be carefull with any "read-modify-write" instruction on the PORTx
registers. As an example, the INCF instruction must first read
whatever the PORTx reg is, increment the value and at last
write the incremented value back to the PORTx register.

On the other hand, a MOVWF instruction just writes to the
PORTx reg (the read is done from the W regsiter).

The problem with reading from the PORTx registers (without
going into to much detail) is that you can (sometimes) not
be sure that what you read, is what you wrote last time.
Details in the docs, and it's a very well know "gotcha"...

The standard cure is to keep a "shadow" register (portb_tmp
in this case), then do any modifications on this register, and
at last only *write* to the PORTx register using e.g. MOVWF.

What I would do now, is to modify the code a little to verify that
all 8 LED's actualy are working and are "settable" from the
code. Something like :

       movlw  x'hh'   ; All "1"
       movwf  portb  : Send to portb

loop
       goto loop         ; Endless loop

This should lit up all LEDs, I think.

Jan-Erik.

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2004\03\09@171641 by Richard S

picon face
Good catch. I used the code supplied to light all led's on port b had to change the x'hh' to h'ff' lucky guess but my first sucessful debug :-))

All LED's work except the one on port RB3 ( this is pin24 and is a shared funtion with PGM). It is counting all the way up. Only way to reset to zero is reflash POR does not reset to zero.

I have a program written in JAL that does work just fine for RB3 so it does work just not with the counter you are all helping me with. I expect the problem has to do with the shared function with PGM but I really have no idea. I disconnected my wisp628 in circuit programmer but the LED on RB3 still does not light.

Any ideas ???

{Original Message removed}

2004\03\09@173545 by Richard S

picon face
maybe this willhelp someone help me on thjis. I took a look at the JAL program and apparently during the build it creates a *.asm file that looks like assembly code. At the beginning of the code it has the following:

; note: the f877 config is still fixed!
__CONFIG H'3F32'  ORG 0000
 goto    __main
ORG 0004
ORG 0004
__interrupt: ; 0004
__main: ; 0004
; var H'020:000'  transfer_bit
; var H'020:000'  transfer_byte

;; 040 : var volatile byte status       at  3
; var H'003:000' status

I don't understand this but maybe it will help shed some "light" on the problem. also I know it states a 16f877 but it does work on this 16f876.

Thanks again !!!

{Original Message removed}

2004\03\09@183722 by Tony Nixon

flavicon
picon face
Richard S wrote:

>All LED's work except the one on port RB3 ( this is pin24 and is a shared funtion with PGM). It is counting all the way up. Only way to reset to zero is reflash POR does not reset to zero.
>
>
>
If you have LVP mode enabled, then pull this pin low with a 10K resistor
or similar.

Otherwise disable LVP in the FUSES and you can use it as a standard port
pin.

regards

Tony

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2004\03\09@195101 by Richard S

picon face
Hi Tony:

I don't know how to dissable the LVP but if I do I am concerned that my WISP628 in circuit programmer will not be able to progam the chip anymore once I dissable the LVP. I think for the 16f876 the programmer is not using the LVP but is using the MCLR#  but not sure this is all still new to me. I disconnected the wire from my programmer that was connected to the RB3 pin and it still programs just fine with or without the 10K to ground but I did find a note on the wisp628 web site about putting this resistor in.

So maybe it is safe to dissable the LVP bit. I think the 16f876 is self protecting if I read the specification correctly P134 of the data sheet. It looks like the only way to change the LVP bit is to do so in the HVP mode therefore the wisp628 (my in circuit programmer) must be programming in this HVP mode.

Can someone please help me understand how to set the LVP bit I can see from the datasheet that its bit 7 of the "configuration word address 2007h".

Thanks again


{Original Message removed}

2004\03\09@195310 by Jinx

face picon face
> > If you look in any .inc file you'll find it's all upper case.
>
> Hm, not *any* .inc file...
>
> Many (well, at least some) 18F*.INC files have symbols
> *both* in upper and lower case.

I was going to say "any (most ?)" because I had a recollection
of seeing multiple entries in a newer .inc but changed my mind
after looking at F452.inc  Of no real importance if case is ignored.
You'd probably have to anyway, if you copy/paste code off the
web or this list for example

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2004\03\09@200537 by Jinx

face picon face
> I still don't know what limits the counter to count binary 000 to 111
> and then restart at 000 does not continuously count up

That puzzled me too. The lower 4 bits of PIR1 are all R/W, but maybe
the problem was actually the port, not PIR1. Although it is probably very
bad practice to use SFRs as general purpose RAM unless you can
really justify it and accept responsibility when it all goes horribly
horribly
wrong, they should work as such. In your case I didn't see anything in
PIR1 that would affect a simple program

What you could be interpreting as restarting may not be so

0000
0001
....
....
0110
0111
1000

If you aren't seeing the "!" on the port you might assume that the counter
has reset. It's the same effect as AND b'00000111'

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2004\03\09@201828 by Richard S

picon face
Jinx:

Thanks. A few things that has been figured out so far from some other great help including yours of course.

The problem was isolated by using a program that turns on all led's to being that only the LED on RB3 does not work. I only had 4 LED's hooked up now I have 8 and I can see that the system is in fact counting up just fine its just that the LED on port RB3 does not work. That is why I thought it was resetting it was really lighting a higher bit LED that was not there. Embarrassing.

After reading through the website for my programmer (wisp628) and the data sheet I can see that what I need to do id dissable the LVP capability and that will turn RB3 into an I/O port it is factory default to enabled so it can not work as an I/o port.

Now I am looking for help on how to set this bit to zero (dissable the LVP). Hopefully that will solve this problem.

Thanks again for your continued effort in helping me.



{Original Message removed}

2004\03\09@202645 by Jinx

face picon face
> Thanks again for your continued effort in helping me

On the roller-coaster that is learning PICs we can all manage
the clack-clack-clack part on our own. It's the downhill-upside-
down-inside-out bit when we need someone to tells us it's OK
to scream ;-)

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2004\03\09@212144 by Tony Nixon

flavicon
picon face
Hi Richard,

You probably have something like this at the start of your source code.

;
   Title "Man, I wish I knew how this PIC works"
;
   list P = 16F876
;
   include "P16f876.inc"

I am assuming nothing special for your project so this FUSE setting
should be OK for your purposes. Just copy this into your source after
the above.

;
; ------------------
; CONFIGURATION FUSE
; ------------------
;
   __CONFIG _CP_OFF & _WRT_ENABLE_OFF & _HS_OSC & _WDT_OFF & _PWRTE_OFF
& _BODEN_OFF & _LVP_OFF & _CPD_OFF & _DEBUG_OFF

NOTE: that ALL of this __CONFIG statement must be on a single line.

Wouters WISP programmer will see the FUSE data in the HEX file after you
assemble it ready for programming and will automatically write to the
FUSE register in the PIC according to the settings listed above.


There are 2 modes to programming this chip. High voltage where around
13V is needed on the MCLR pin, and low voltage mode (LVP) where only 5V
is needed on the MCLR pin, but in this case RB3 is also used. If the
WISP is not using anything connected to RB3, then you are using HV mode
and don't need LVP enabled.

If you have LVP mode enabled, then the RB3 pin should be tied low. If
this pin is allowed to float unconnected or go HI, the PIC may
inadvertantly go into programming mode, and you may think something is
wrong with your code or circuit when the chip does not work as expected.
Very frustrating.

The above FUSE statement has LVP_OFF and disables LVP programming mode.

You will be able to use RB3 as a general purpose IO pin with LVP disabled.

LVP mode is enabled by default on a blank chip.

regards

Tony

Richard S wrote:

{Quote hidden}

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2004\03\09@225401 by Richard S

picon face
I did finally figure out how to fix the problem. All I had to do once I understood what the configuration line was doing was to add to that line
& _LVP_OFF  ; this disables LVT and enables I/O for RB3

only took me a full day to finally figure this out. Now it counts up and up and up hey kind of like the roller coaster before the fall . LOL

Now I can try to understand the nuances of the code that everyone helped me get working.  But all the playing and reading I did to figure this out I think it was a good day :-)

{Original Message removed}

2004\03\10@014303 by Wouter van Ooijen

face picon face
> I don't know how to dissable the LVP but if I do I am
> concerned that my WISP628 in circuit programmer will not be
> able to progam the chip anymore once I dissable the LVP.

No need to worry.

Wisp628 is an HVP programmer, so it can program the chip whether you
enable LVP or not. But do not forget to connect the LVP (white) wire to
the corresponding chip pin.

That that if it were an LVP programmer it would not be able to disable
LVP. That is a property of the chip: disabling LVP can only be done in
HVP.

rad http://www.voti.nl/swp for some more words about this.

Wouter van Ooijen

-- -------------------------------------------
Van Ooijen Technische Informatica: http://www.voti.nl
consultancy, development, PICmicro products

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email @spam@listservKILLspamspammitvma.mit.edu with SET PICList DIGEST in the body

2004\03\10@035925 by Jan-Erik Soderholm

face picon face
Jinx wrote :

> > > If you look in any .inc file you'll find it's all upper case.
> >
> > Hm, not *any* .inc file...
> >
> > Many (well, at least some) 18F*.INC files have symbols
> > *both* in upper and lower case.
>
> I was going to say "any (most ?)" because I had a recollection
> of seeing multiple entries in a newer .inc but changed my mind
> after looking at F452.inc  Of no real importance if case is ignored.

Hi.
I'm not sure I follow here...
As I remember it, was that *if* you set it up to ignore
case (as most seems to prefer to do), the upper/lower
case definitions in the INC file will show up as
"multiple defined symbols" (not sure about the exact
message) when assembling. Which is logical.

Anyway, I just looked through the INC files from
MPLAB 6.40, and I could not find this double defined
symbols any more. But I'm *sure* this was a problem,
it was also verified by Olin since I was hit by this when
installing his environment...

Regards,
Jan-Erik.

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email KILLspamlistservKILLspamspammitvma.mit.edu with SET PICList DIGEST in the body

2004\03\10@041830 by Jan-Erik Soderholm

face picon face
Richard S wrote :

> The problem was isolated by using a program that turns on all
> led's to being that only the LED on RB3 does not work. I only
> had 4 LED's hooked up now I have 8 and I can see that the
> system is in fact counting up just fine its just that the LED
> on port RB3 does not work...

Ouch, you was asked multiple times *HOW* you verified that
the counter didn't "count". And you was asked multiple times
if it could be that the other LEDs (I'm sure everyone *thought*
that you had 8 LED's connected !!) just didn't worked for some reason.

*Now* you tell us that you, in fact, just had 4 LED's connected,
and that it's the LED on RB3 that doesn't work (since you
had LVP enabled)...

Anyway, I'm glad you got it working !

/Jan-Erik.

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email RemoveMElistservTakeThisOuTspammitvma.mit.edu with SET PICList DIGEST in the body

2004\03\10@050306 by Jinx

face picon face
> As I remember it, was that *if* you set it up to ignore
> case (as most seems to prefer to do), the upper/lower
> case definitions in the INC file will show up as
> "multiple defined symbols" (not sure about the exact
> message) when assembling. Which is logical.

I have been known to edit .inc files, especially when you get
unnecessary and daft error reports. Possibly that 452 file had
been previously edited

I'm using 6.20 / PicStart Plus BTW for 628A and 452. Is there
anything to be gained by moving up to 6.40 ? Any major problems
with it ? (I generally stay one release behind and let other, braver
souls find the bugs)

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email spamBeGonelistservspamBeGonespammitvma.mit.edu with SET PICList DIGEST in the body

2004\03\10@050925 by Jan-Erik Soderholm

face picon face
Jinx wrote :

> Is there
> anything to be gained by moving up to 6.40 ? Any major problems
> with it ? (I generally stay one release behind and let other, braver
> souls find the bugs)

Don't know realy, I mainly update MPLAB to get the newest versions
of the command line tools (MPASM, MPLINK), since I'm using
UltraEdit and Olins environment instead of MPLAB for development...

Jan-Erik.

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email TakeThisOuTlistservEraseMEspamspam_OUTmitvma.mit.edu with SET PICList DIGEST in the body

2004\03\10@071430 by Richard S

picon face
The circuit on piclist shows only 4 LED's so that is exactly how I built the circuit. Maybe that should be updated. For a newbie like me I assumed it only counted to 1111.

Richard

{Original Message removed}

2004\03\10@151349 by Richard S

picon face
I can not thank everyone enough for the support so far and I hope that such support will continue.
I certainly do not like getting yelled at and expected more from the talent here I would never have thought that anyone one flame someone here. I know newbies can be frustrating to all you experts but that is why I stated up front that I was a newbie so you knew what you were dealing with.

That being said:

I will first like to appologize to Jan-Erik you are definitely a great guy and your willingness to share you knowledge is something to be commended. I Know I will need your help again and hope that will be possible.

Next I will appologize if I wasted anyones time by poor communication or presenting the wrong information.
Even though I am definitely a newbie to PIC's and assembly I do have a strong technical background. When asked how I knew the system was not working I stated basically as best I could think of "because NONE of the LED's light up at all". It was not until someone her showed me that the problem was that I needed to configre for a different occillator using the _HS_OSC to get the LED's to light. Once this was done then the system was working and I then asked for help on why it counted only to 111 and no higher so even 4 LED's is enough to work withI agree 8 is better but at the time I did not even know that I could hook up 8. Sorry again but not sure what I did wrong here.

Thanks again eveyone

Regards,

Richard

{Original Message removed}

2004\03\10@161648 by Jan-Erik Soderholm

face picon face
Richard S wrote :

> I certainly do not like getting yelled at and expected more
> from the talent here I would never have thought that anyone
> one flame someone here.

Two things.

First, I'm realy sorry about that. When I read my own post,
I didn't think either that it was a very clever post. Rather
un-clever actualy...

Second, I *do* think I have quite a way to go before I
match some other (or rather *former*) list members :-) :-)
(Hint : search the list archives for a thread called :
"[PIC]: PIC18F8720 insuccesses")

> I will first like to appologize to Jan-Erik you are
> definitely a great guy and your willingness to share you
> knowledge is something to be commended.

Ha !
I was in your position just about a year and a half ago. :-)
Just for your amusement, I 've added my first post to
the list with some replies at the end of this post. Enjoy !! :-)

Time flies, doesn't it ?

> Next I will appologize if I wasted anyones time by poor
> communication or presenting the wrong information.

Well, at least you didn't asked about debugging a program and
just presenting some HEX code... :-) :-)
(Hint: see the hint above...)

> Sorry again but not sure what I did wrong here.

Frankly, with a second thought, I'm not sure you did
anything *that* wrong, or even wrong at all. Just the
standard series of missunderstandings that is the
life-on-the-net...

If there is anything else I can do to help you,
I'd be realy happy to, even more now after I made
that rather stupid post earlier...

Best Regards
Jan-Erik.


[My very first post to the list the 6 Sep 2002 : ]

Hi.
(Just subscribed to the piclist yesterday, so I'm sorry
if this are just some FAQ's...)

I'm using a dev/educ card with a PIC16F84A built
from a design in Elektor this spring. Now, I'v found
this PIC a bit limited in features. To what degree are
the newer 18-pin PIC's compatable (the HW, not by SW)
with the 16F82A ? Such as the 16F62X series.

Or should one try to go with some of the "bigger" PIC's ?

Which PIC is the most popular amongst "hobbyists" today ?
And what programming/experimenting cards are most popular ?
Or maybe the "The PICLIST Beginners Kit" is what I'm
looking for ?

Regards
Jan-Erik Soderholm

[One of the replies :]

> Or should one try to go with some of the "bigger" PIC's ?
> Which PIC is the most popular amongst "hobbyists" today ?

Oh no, you don't want to start that war again!

> And what programming/experimenting cards are most popular ?

Looking for another flame war ;)

> Or maybe the "The PICLIST Beginners Kit" is what I'm
> looking for ?

If you have got the time...

Wouter van Ooijen


[Another reply :]

>Hi.
>(Just subscribed to the piclist yesterday, so I'm sorry
>if this are just some FAQ's...)

Don't be sorry, RTFM. Search piclist.com before posting the same
question that has been answered at least a dozen times before!

Best regards,

Spehro Pefhany


And I survived. :-)

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email RemoveMElistservspamTakeThisOuTmitvma.mit.edu with SET PICList DIGEST in the body

More... (looser matching)
- Last day of these posts
- In 2004 , 2005 only
- Today
- New search...