Searching \ for 'Newbie code doesn't seem to work - please take a l' 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/index.htm?key=newbie+code+doesnt
Search entire site for: 'Newbie code doesn't seem to work - please take a l'.

Truncated match.
PICList Thread
'Newbie code doesn't seem to work - please take a l'
1999\07\06@094841 by Daniel Watford

flavicon
face
Hi all.

I've been playing with this bit of code for a few days now and I can't see
what the problem is.

Using RB0 the code should generate a morse signal as DIT - DAH - DIT - DAH -
DIT - DAH reapeatedly. However I seem to be getting an extra DAH in there
somewhere. I am getting DIT - DAH - DIT - DAH - DIT - DAH - DAH repeatedly.

Looking at the code can anyone see a problem, or can i assume it is a
hardware problem.

I am using a P16F84 processor.

Thanks
Dan

<CODE>
PORTA  EQU 0x05
PORTB  EQU 0x06
TRISA  EQU 0x85
TRISB  EQU 0x86
STATUS  EQU 0x03
DITLEN  EQU 0x64
CNT1  EQU 0x30
DITCOUNT1 EQU 0X20
DITCOUNT2 EQU 0X21
DAHCOUNT1 EQU 0X22

 ORG 0x00
 GOTO START


ONOFF  MOVLW 1
 MOVWF PORTB
 MOVLW 0xFF
 MOVWF CNT1
LOOPONOFF1 DECFSZ CNT1
 GOTO LOOPONOFF1
 MOVLW 0
 MOVWF PORTB
 MOVLW 0xFF
 MOVWF CNT1
LOOPONOFF2 DECFSZ CNT1
 GOTO LOOPONOFF2
 RETURN


OFFOFF  MOVLW 0
 MOVWF PORTB
 MOVLW 0xFF
 MOVWF CNT1
LOOPOFFOFF1 DECFSZ CNT1
 GOTO LOOPOFFOFF1
 MOVLW 0
 MOVWF PORTB
 MOVLW 0xFF
 MOVWF CNT1
LOOPOFFOFF2 DECFSZ CNT1
 GOTO LOOPOFFOFF2
 RETURN


PLAYDIT  MOVLW DITLEN
 MOVWF DITCOUNT1
PLAYDITLOOP CALL  ONOFF
 DECFSZ DITCOUNT1
 GOTO PLAYDITLOOP
 RETURN


DITSPACE MOVLW DITLEN
 MOVWF DITCOUNT2
DITSPACELOOP CALL OFFOFF
 DECFSZ DITCOUNT2
 GOTO DITSPACELOOP
 RETURN


PLAYDAH  MOVLW DITLEN
 MOVWF DAHCOUNT1
PLAYDAHLOOP CALL ONOFF
 CALL ONOFF
 CALL ONOFF
 DECFSZ DAHCOUNT1
 GOTO PLAYDAHLOOP
 RETURN


START  BSF STATUS, 5
 MOVLW 0
 MOVWF TRISB
 BCF STATUS, 5
STARTLOOP
 CALL PLAYDIT
 CALL DITSPACE
 CALL PLAYDAH
 CALL DITSPACE

 END

</CODE>



************************************************************************
Daniel Watford
CCTEC Ltd.
23 Station Road
Westgate
KENT    CT8 8RB
UK

Tel: +44 (0) 1843 833999
Fax: +44 (0) 1843 835999

Software Developer - Windows 95, 98, NT, Linux.

spam_OUTdaniel.watfordTakeThisOuTspamcctec.ltd.uk

************************************************************************
How many programmers does it take to change a light bulb?
They refuse. They say, "It's a hardware fault".  -- Arthur Buse
************************************************************************

1999\07\06@185118 by Tony Nixon

flavicon
picon face
Daniel Watford wrote:

>
> Using RB0 the code should generate a morse signal as DIT - DAH - DIT - DAH -
> DIT - DAH reapeatedly. However I seem to be getting an extra DAH in there
> somewhere. I am getting DIT - DAH - DIT - DAH - DIT - DAH - DAH repeatedly.


> STARTLOOP
>   CALL PLAYDIT
>   CALL DITSPACE
>   CALL PLAYDAH
>   CALL DITSPACE

Maybe put

   GOTO STARTLOOP

>
>   END
>



--
Best regards

Tony

'The Engine' - Design your own programmer.

http://www.picnpoke.com
Email .....picnpokeKILLspamspam@spam@cdi.com.au

1999\07\07@050152 by Daniel Watford

flavicon
face
Hi all.

I've been playing with this bit of code for a few days now and I can't see
what the problem is.

Using RB0 the code should generate a morse signal as DIT - DAH - DIT - DAH -
DIT - DAH reapeatedly. However I seem to be getting an extra DAH in there
somewhere. I am getting DIT - DAH - DIT - DAH - DIT - DAH - DAH repeatedly.

Looking at the code can anyone see a problem, or can i assume it is a
hardware problem.

I am using a P16F84 processor.

Thanks
Dan

<CODE>
PORTA  EQU 0x05
PORTB  EQU 0x06
TRISA  EQU 0x85
TRISB  EQU 0x86
STATUS  EQU 0x03
DITLEN  EQU 0x64
CNT1  EQU 0x30
DITCOUNT1 EQU 0X20
DITCOUNT2 EQU 0X21
DAHCOUNT1 EQU 0X22

 ORG 0x00
 GOTO START


ONOFF  MOVLW 1
 MOVWF PORTB
 MOVLW 0xFF
 MOVWF CNT1
LOOPONOFF1 DECFSZ CNT1
 GOTO LOOPONOFF1
 MOVLW 0
 MOVWF PORTB
 MOVLW 0xFF
 MOVWF CNT1
LOOPONOFF2 DECFSZ CNT1
 GOTO LOOPONOFF2
 RETURN


OFFOFF  MOVLW 0
 MOVWF PORTB
 MOVLW 0xFF
 MOVWF CNT1
LOOPOFFOFF1 DECFSZ CNT1
 GOTO LOOPOFFOFF1
 MOVLW 0
 MOVWF PORTB
 MOVLW 0xFF
 MOVWF CNT1
LOOPOFFOFF2 DECFSZ CNT1
 GOTO LOOPOFFOFF2
 RETURN


PLAYDIT  MOVLW DITLEN
 MOVWF DITCOUNT1
PLAYDITLOOP CALL  ONOFF
 DECFSZ DITCOUNT1
 GOTO PLAYDITLOOP
 RETURN


DITSPACE MOVLW DITLEN
 MOVWF DITCOUNT2
DITSPACELOOP CALL OFFOFF
 DECFSZ DITCOUNT2
 GOTO DITSPACELOOP
 RETURN


PLAYDAH  MOVLW DITLEN
 MOVWF DAHCOUNT1
PLAYDAHLOOP CALL ONOFF
 CALL ONOFF
 CALL ONOFF
 DECFSZ DAHCOUNT1
 GOTO PLAYDAHLOOP
 RETURN


START  BSF STATUS, 5
 MOVLW 0
 MOVWF TRISB
 BCF STATUS, 5
STARTLOOP
 CALL PLAYDIT
 CALL DITSPACE
 CALL PLAYDAH
 CALL DITSPACE

 END

</CODE>
************************************************************************
Daniel Watford
CCTEC Ltd.
23 Station Road
Westgate
KENT    CT8 8RB
UK

Tel: +44 (0) 1843 833999
Fax: +44 (0) 1843 835999

Software Developer - Windows 95, 98, NT, Linux.

daniel.watfordspamKILLspamcctec.ltd.uk

************************************************************************
How many programmers does it take to change a light bulb?
They refuse. They say, "It's a hardware fault".  -- Arthur Buse
************************************************************************

1999\07\07@063250 by Caisson

flavicon
face
> Van: Daniel Watford <.....piclistKILLspamspam.....CCTEC.LTD.UK>
> Aan: EraseMEPICLISTspam_OUTspamTakeThisOuTMITVMA.MIT.EDU
> Onderwerp: Newbie code doesn't seem to work - please take a look
> Datum: dinsdag 6 juli 1999 14:39
>
> Hi all.

Hello Daniel,

> I've been playing with this bit of code for a few days now and I can't
see
> what the problem is.
>
> Using RB0 the code should generate a morse signal as DIT - DAH - DIT -
DAH -
> DIT - DAH reapeatedly. However I seem to be getting an extra DAH in there
> somewhere. I am getting DIT - DAH - DIT - DAH - DIT - DAH - DAH
repeatedly.
>
> Looking at the code can anyone see a problem, or can i assume it is a
> hardware problem.

<Snip>

> STARTLOOP
>   CALL PLAYDIT
>   CALL DITSPACE
>   CALL PLAYDAH
>   CALL DITSPACE
>
>   END

As someone else allready pointed out, your program stops at the END
directive, but the PIC's Program-counter does not.  So it will continue
into uncharted lands :-)  Amazing that your program went into a loop !

Another thing: You _did_ disable the WachDog, did you ... <grin>

Greetz,
 Rudy Wieser

1999\07\07@101738 by Daniel Watford

flavicon
face
On Wed, 7 Jul 1999, Caisson wrote:

>
> Another thing: You _did_ disable the WachDog, did you ... <grin>
>
> Greetz,
>   Rudy Wieser
>
Ahah! I'm not sure.... I will check when I get home from work tonite.


Thanks
Dan
daniel.watfordspamspam_OUTcctec.ltd.uk

1999\07\08@050926 by Daniel Watford

flavicon
face
Hi again,

I've checked the watchdog timer, and indeed it was enabled.

I've now disabled it and the circuit is working perfectly.

What does the watchdog time do exactly?

Thanks for your help

Dan

1999\07\08@065759 by Caisson

flavicon
face
> Van: Daniel Watford <@spam@piclistKILLspamspamCCTEC.LTD.UK>
> Aan: KILLspamPICLISTKILLspamspamMITVMA.MIT.EDU
> Onderwerp: Re: Newbie code doesn't seem to work - please take a look
> Datum: donderdag 8 juli 1999 12:05
>
> Hi again,

Hello Daniel,

> I've checked the watchdog timer, and indeed it was enabled.
> I've now disabled it and the circuit is working perfectly.
> What does the watchdog time do exactly?

Wachdog-timers are invented to mess-up programs of Newbies.  Really ! :-)

Ah, well.  Id see you don't beleive me.  O.k. Another explanation of their
existence:  It is possible that a controller will get stuck in some kind of
loop, due to bad programming (go kick the programmer :-) or due to power
spikes and the like.  When this happens, the circuit has to be reset to
enable it to work again.

So, the first controllers where build wid a LED attached, that blinked when
all was well.  If it stopped blinking, someone had to press the RESET
button.

After a while someone build a "missing puls" detector (a retriggerable
mono-flop) and connected that to the blinking led and the RESET button.
Now, whenever the led stopped blinking, the mono-flop would time-out, and
reset the system.  No human needed anymore !

Later they decided to build the mono-flop into the system.  That feature is
now known as a "WachDog".  It will simply count pulses (from and
independend internal source).  If the WachDog-counter overflows it will
either Reset the controller (or generate a Interrupt, depended on how it's
configured).  The blinking LED was replaced by an Instruction to re-set the
WachDog (CLRWDT -> Clear WachDog Timer).

So, when a WachDog is enabled and not re-set every once-in-a-while, it will
eventually reset the controller, creating strange effects for unsuspecting
Newbies .... (Sorry, could not let this one go ... :-)

Greetz,
  Rudy Wieser

1999\07\09@065605 by Daniel Watford

flavicon
face
Hi Caisson,

Just a quick message to say thanks for the explanation.

It does sound that if used properly the watchdog timer can be a very usefull
feature.
Is it just a case that when using it you must issue the CLRWDT command.


Thanks again

Dan

************************************************************************
Daniel Watford
CCTEC Ltd.
23 Station Road
Westgate
KENT    CT8 8RB
UK

Tel: +44 (0) 1843 833999
Fax: +44 (0) 1843 835999

Software Developer - Windows 95, 98, NT, Linux.

RemoveMEdaniel.watfordTakeThisOuTspamcctec.ltd.uk

************************************************************************
How many programmers does it take to change a light bulb?
They refuse. They say, "It's a hardware fault".  -- Arthur Buse
************************************************************************

1999\07\09@155229 by Mark Willis

flavicon
face
Daniel Watford wrote:
>
> Hi Caisson,
>
> Just a quick message to say thanks for the explanation.
>
> It does sound that if used properly the watchdog timer can be a very usefull
> feature.
> Is it just a case that when using it you must issue the CLRWDT command.
>
> Thanks again
>
> Dan

 Watchdog Timer's pretty much mandatory on life-critical systems (On
avionics, for example, you don't want a 747 crashing into the ground
because your ground proximity warning system's been hung for the last 3
hours, due to a cosmic ray ionizing things & crashing your GroundProx
system.)  Wouldn't be good if the CPU in someone's pacemaker crashed,
either...  I prefer "Feed the dog" to "Kick the dog" which some people
use when resetting the Watchdog Timer (Dogs're FAR happier when fed
treats, then when kicked!)  WDT isn't particularly necessary on LED
blinkers & so on <G>

 Mark

1999\07\12@071645 by Caisson

flavicon
face
> Van: Daniel Watford <spamBeGonepiclistspamBeGonespamcctec.ltd.uk>
> Aan: TakeThisOuTPICLISTEraseMEspamspam_OUTMITVMA.MIT.EDU
> CC: RemoveMEcaissonspamTakeThisOuTtelebyte.nl
> Onderwerp: Re: Newbie code doesn't seem to work - please take a look
(watchdog)
> Datum: vrijdag 9 juli 1999 12:05
>
> Hi Caisson,
>
> Just a quick message to say thanks for the explanation.

You're welcome.

> It does sound that if used properly the watchdog timer can be a very
usefull
> feature.

It is !

> Is it just a case that when using it you must issue the CLRWDT command.

No.  You have to set-up the Wach-dog timer first.  It must be enabled (in
the configuration-word), and you can assign a pre-scaler to it, so that the
time-out of the wachdog-timer can be extended. And you can define what an
wachdog time-out does: Reset the device, or issue an interrupt.   Default :
No prescaler, reset the device (as you have noticed :-)

Greetz,
 Rudy Wieser

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