Searching \ for '[PIC]: Please help me before i loose sanity :)' 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/devices.htm?key=pic
Search entire site for: 'Please help me before i loose sanity :)'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: Please help me before i loose sanity :)'
2001\09\23@170929 by Lasse Madsen

flavicon
face
Hi All

I have used the code that Anders M. J. send me and modified my own code with it BUT it doesnt work !
What i want the below code to do is:
do the "thing" 50 times (0x32 in hex) and do nothing (end program)
BUT:
The program keeps repeating it self to infinity and i didnt specify that anywhere (i think)

Please help me.

Best regards lasse madsen

<CODE>
list p=16f84  radix hex  porta equ 0x05  org 0x000  start  movlw 0x00   tris porta  ecount equ 0x0c
ncount equ 0x0d
mcount equ 0x0e
count equ 0x1a
counter equ 0x1b
;
;
movlw 0xFF
movwf counter
loop:
BCF porta,01
CALL    pulse
BSF     porta,01
CALL    farve_1
BCF porta,01
decfsz counter
goto loop
BCF porta,01
;
;
; ===== Subprocedure 1 ===== farve_1 clrf mcount
clrf ecount
movlw 0x09  movwf mcount
l1 movlw 0x19
movwf ecount
d1 decfsz ecount,f
goto d1
decfsz mcount,f
goto l1
clrf mcount
movlw 0x1B
movwf mcount
a1 decfsz mcount,f
goto a1
NOP
NOP
NOP
NOP
NOP
return ;
; ===== Subprocedure 2  =====
pulse clrf ncount
clrf count
movlw 0x52  movwf count
loadn movlw 0x50
movwf ncount
decn decfsz ncount,f
goto decn
decfsz count,f
goto loadn
return
;
end
</CODE>

--
http://www.piclist.com hint: To leave the PICList
spam_OUTpiclist-unsubscribe-requestTakeThisOuTspammitvma.mit.edu


2001\09\23@180221 by Lasse Madsen

flavicon
face
Sorry i wrote wrong in my code here:

movlw 0xFF
movwf counter

But it still doesnt change that it doesnt work when i correct it to 0x32

best regards
lasse

--
http://www.piclist.com hint: To leave the PICList
.....piclist-unsubscribe-requestKILLspamspam@spam@mitvma.mit.edu


2001\09\23@185316 by Jinx

face picon face
In the code below it looks to me (although it would have
been clearer commented and better formatted) that when
the decfsz is true, the PC flow moves into the farve_1 routine
which is terminated with an uncalled return. Where it will go
from there is anyone's guess. Start with "movlw 0x32" and
after the bcf porta,01 **** put "goto end"

movlw 0xFF
movwf counter

loop:

BCF porta,01
CALL    pulse
BSF     porta,01
CALL    farve_1
BCF porta,01
decfsz counter
goto loop
BCF porta,01 ****
;
; ===== Subprocedure 1 =====
farve_1 clrf mcount
>>>>
return

end
</CODE>

--
http://www.piclist.com hint: To leave the PICList
piclist-unsubscribe-requestspamKILLspammitvma.mit.edu


2001\09\23@190812 by David Duffy

flavicon
face
Lasse Madsen wrote:
{Quote hidden}

What is it supposed to do here?
It will run into the subroutine the way it is and cause havoc!
Add this line:

wait:   goto    wait

This will make it just hang around after it's done your 255 loops.
I have not checked for other errors.
Regards...

{Quote hidden}

--
http://www.piclist.com hint: To leave the PICList
.....piclist-unsubscribe-requestKILLspamspam.....mitvma.mit.edu


2001\09\23@203234 by Bob Barr

picon face
Jinx wrote:
>
>In the code below it looks to me (although it would have
>been clearer commented and better formatted) that when
>the decfsz is true, the PC flow moves into the farve_1 routine
>which is terminated with an uncalled return. Where it will go
>from there is anyone's guess. Start with "movlw 0x32" and
>after the bcf porta,01 **** put "goto end"
>

It'll take a little more than that. 'end' is a directive that marks the end
of the source file, not the code space.

You've got to program something to make the processor stop executing code.

In your example, I would expect the processor to run off the end of the code
space, wrap around, and start executing from location 0 again.

A 'branch to self' will leave the processor executing branches forever. See
below.

Regards, Bob

{Quote hidden}

; stop executing   <<<<<< added
 goto  $          <<<<<< added, loop forever until reset

{Quote hidden}

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp

--
http://www.piclist.com hint: To leave the PICList
EraseMEpiclist-unsubscribe-requestspam_OUTspamTakeThisOuTmitvma.mit.edu


2001\09\23@221412 by Jinx

face picon face
> It'll take a little more than that. 'end' is a directive that marks
> the end of the source file, not the code space

I know what you mean but it was a kind of figurative "goto end",
obviously the code has to go somewhere after the loop. The
basic problem is that bad skip, Lasse can sort out where PC
goes to when that's fixed

--
http://www.piclist.com hint: To leave the PICList
piclist-unsubscribe-requestspamspam_OUTmitvma.mit.edu


2001\09\24@014947 by Bob Barr

picon face
Jinx wrote:
>
> > It'll take a little more than that. 'end' is a directive that marks
> > the end of the source file, not the code space
>
>I know what you mean but it was a kind of figurative "goto end",
>obviously the code has to go somewhere after the loop. The
>basic problem is that bad skip, Lasse can sort out where PC
>goes to when that's fixed
>

Sorry, I took your 'goto end' too literally. It appeared that you were using
'end' as an assembler label. (I'm not sure that's even legal.)

Regards, Bob



_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\09\24@020227 by BENEDICIC SAMO

flavicon
face
Hi!

First, your code gets executed 255 times (0xFF) in a loop. When done, it
doesn't stop like you want it to, instead it goes straight on to
subprocedure1. When it gets to RETURN command, stack underflow
occurs-processor doesn't have an address on stack to return anywhere. In
MPLAB SIM you get an warning for that, in reality I don't know what happens.
You should put an neverending loop at the end of your code to cure that. As
for constant repeating, maybe you have WDT set to ON and PIC keeps reseting
itself.One more thing: it would help a great deal also to you if you'd put
some comments to your code.Regards, Samo

CURE for first problem:

movlw 0xFF              ;you want 50 here, not 255
movwf counter
loop:
BCF porta,01
CALL    pulse
BSF     porta,01
CALL    farve_1
BCF porta,01
decfsz counter
goto loop
BCF porta,01

STOP
       goto STOP       ;loop here forever
;
;
; ===== Subprocedure 1 =====
farve_1 clrf mcount
clrf ecount
movlw 0x09
movwf mcount
l1 movlw 0x19
movwf ecount
d1 decfsz ecount,f
goto d1
decfsz mcount,f
goto l1
clrf mcount
movlw 0x1B
movwf mcount
a1 decfsz mcount,f
goto a1
NOP
NOP
NOP
NOP
NOP
return
;
; ===== Subprocedure 2  =====
pulse clrf ncount
clrf count
movlw 0x52
movwf count
loadn movlw 0x50
movwf ncount
decn decfsz ncount,f
goto decn
decfsz count,f
goto loadn
return
;
end
{Original Message removed}

2001\09\24@042726 by Jinx

face picon face
> Sorry, I took your 'goto end' too literally. It appeared that
> you were using 'end' as an assembler label. (I'm not sure
> that's even legal.)

No prob. "not legal" OK. "getting caught" not OK ;-)))

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\09\24@114939 by m.craig

picon face
I used to have a problem with programs repeating when they reached the "end"
command. I added a sleep before it and that sorted it out.
Simple solutions satisfy simple people.
Mark Craig
@spam@m.craigKILLspamspamntlworld.com
Glasgow
Scotland

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\09\24@124624 by Joris van den Heuvel

flavicon
face
Hi Lasse,

Anyone correct me if I'm wrong, but I believe you forgot the [,f] following
the decfsz counter in your main loop. If you don't specify a source for the
result of the decrement, the assembler assumes you want it stored in W, and
as a result the counter is NOT updated.

Regards,
Joris.

{Original Message removed}

2001\09\24@134133 by Bob Barr

picon face
Joris van den Heuvel wrote:
>
>Hi Lasse,
>
>Anyone correct me if I'm wrong, but I believe you forgot the [,f] following
>the decfsz counter in your main loop. If you don't specify a source for the
>result of the decrement, the assembler assumes you want it stored in W, and
>as a result the counter is NOT updated.
>

In MPASM, the default destination is ',f' if it's not specified. This
generates a warning something like 'default destination used'.

Regards, Bob



_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\09\24@150653 by Olin Lathrop

face picon face
> Anyone correct me if I'm wrong,

OK, you're wrong.

> but I believe you forgot the [,f] following
> the decfsz counter in your main loop. If you don't specify a source for
the
> result of the decrement, the assembler assumes you want it stored in W,
and
> as a result the counter is NOT updated.

The default is F, not W.


********************************************************************
Olin Lathrop, embedded systems consultant in Littleton Massachusetts
(978) 742-9014, KILLspamolinKILLspamspamembedinc.com, http://www.embedinc.com

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\09\24@152701 by Lasse Madsen

flavicon
face
WOW

Talk about major response !

I thought that I had been spammed today when I opened my mail program !

Thanks to all who has written and used so much precious time.

Best Regards

Lasse Madsen



{Original Message removed}

2001\09\25@110209 by BENEDICIC SAMO

flavicon
face
Hi!

Well, today I wasted time on you, the next day, when I have a problem,
you'll do the same for me.I belive that's what piclist is about.
Best regards, Samo

{Original Message removed}

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