Searching \ for 'Help...what am I missing?' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: techref.massmind.org/techref/index.htm?key=helpwhat+missing
Search entire site for: 'Help...what am I missing?'.

Truncated match.
PICList Thread
'Help...what am I missing?'
1998\12\14@020334 by Scott Shidel...

flavicon
face
Can some of you guys look at the following code and tell me why it wont
compile(MPLAB)?  The program takes a variable maf, and sees if it falls
between a bunch of vales(if then elses).  If it is between certain values,
it sets a multiplier(xfer) in the main program to value.  The program
should then multply by a number then divide by h80.
Please help..I have been pulling my hair all day on this.
here is the program
thanks in advance

       List    p=16c711
       include <p16c71.inc>
vaf     equ     0x0c
VAF     equ     0x0d
LoopCount       equ     0x0e
maf     equ     0x0f
xfer    equ     0x11
reset
       goto    start
       org     0x04
;
;       INIT 2
;
start
       clrf    vaf
       clrf    LoopCount
       clrf    maf
       clrf    maf+1
       clrf    vaf+1
       clrf    xfer
       clrf    xfer+1
       movlw   H'd3'   ;maf
       movwf   maf
;
;       START IF THEN PROCESS
;
Decis
       movlw   h'f0'   ; idle value
       addwf   maf, w
       btfss   STATUS, C
       goto    Idle
       movlw   h'B3'   ; 0 to .3
       addwf   maf, w
       btfss   STATUS, C
       goto    Uno
       movlw   h'80'   ; .3-.5
       addwf   maf, w
       btfss   STATUS, C
       goto    Dos
       movlw   h'4D'   ; .5-.7
       addwf   maf, w
       btfss   STATUS, C
       goto    Tres
       movlw   h'34'   ; .7-.8
       addwf   maf, w
       btfss   STATUS, C
       goto     Quatro
       goto    Cinco
;
;       ARITHMETIC
;
mult
       movlw   d'15'
       movwf   LoopCount
Loop
       rrf     maf+1
       rrf     maf
       btfss   STATUS, C
        goto   AddSkip
       movf    xfer+1, w
       addwf   vaf+1
       movf    xfer, w
       addwf   vaf
       btfsc   STATUS, C
        incf   vaf+1
AddSkip
       bcf     STATUS, C
       rlf     xfer
       rlf     xfer+1

       decfsz  LoopCount
       goto    Loop
Division
       rlf     vaf+1
       bcf     vaf+1, 0
       btfsc   vaf, 7
       incf    vaf+1, 1
DONE
       NOP
       goto    DONE
       End

;
;       TRANSFER FUNCTIONS;
;
Idle
       movlw   h'0f'   ; sets output to .06 fso
       movwf   VAF
       goto    DONE
Uno
       movlw   h'85'   ; sets mult to 1.04
       movwf   xfer
       goto    mult
Dos
       movlw   h'89'   ; sets mult to 1.07
       movwf   xfer
       goto    mult
Tres
       movlw   h'8d'   ; sets mult to 1.1
       movwf   xfer
       goto    mult
Quatro
       movlw   h'89'   ; set mult to 1.07
       movwf   xfer
       goto    mult
Cinco
       movlw   h'85'   ; sets mult to 1.04
       movwf   xfer
       goto    mult


-----------------------------------------------------------------------
               The Pinto Page:  http://www.eng.usf.edu/~shidel
                  Join the Ford Turbo Mailing List!
                 http://www.FindMail.com/list/turbo/
Scott
-71 Pinto, stock 2.3 turbo, 13.67@98, radials
       8.1@85 1/8th mile on slicks
-85 Merkur 13.764@98 on radials&3300lbs! Under $300 in mods!
------------------------------------------------------------------------

1998\12\14@025002 by Quentin

flavicon
face
Scott Shidel... wrote:

>         List    p=16c711
>         include <p16c71.inc>
> vaf     equ     0x0c
> VAF     equ     0x0d

What error do you get in the build window? Look under your node properties
(Edit Project)  and see if you got case sensitivity on. After a quick scan
through your program I notice you use vaf and vaf+1, but no VAF, so I guess
you can remove it.

Quentin

1998\12\14@030036 by Scott Shidel...

flavicon
face
>
> >         List    p=16c711
> >         include <p16c71.inc>
> > vaf     equ     0x0c
> > VAF     equ     0x0d
>
> What error do you get in the build window? Look under your node properties
> (Edit Project)  and see if you got case sensitivity on. After a quick scan
> through your program I notice you use vaf and vaf+1, but no VAF, so I guess
> you can remove it.
>

I have the case sensitivity on.  The program uses vaf and vaf+1 ina 16 bit
multiplication.  The result after the division is always an 8 bit number,
called VAF, which happens to be the same as vaf+1.
Anyhow, the error I am getting is if you scan the program from top to
bottom, if a subroutine hasnt been read already, and the program tries to
perform a goto to it, it will say the symbol naming the sub is undefined.
in other words, unless I put my subroutines at the top of the program, it
wont compile.  The prob I have is that the subroutines jump around and its
about impossible to lay it out that way.

-----------------------------------------------------------------------
               The Pinto Page:  http://www.eng.usf.edu/~shidel
                  Join the Ford Turbo Mailing List!
                 http://www.FindMail.com/list/turbo/
Scott
-71 Pinto, stock 2.3 turbo, 13.67@98, radials
       8.1@85 1/8th mile on slicks
-85 Merkur 13.764@98 on radials&3300lbs! Under $300 in mods!
------------------------------------------------------------------------

1998\12\14@112909 by Ryan Miller

flavicon
face
You put your subroutines after your END directive. END needs to be the last
thing in your code. Make sure that the word doesn't appear anywhere else in
your code; that's bit me before.

Ryan


> {Original Message removed}

1998\12\14@144015 by Stig Brautaset

flavicon
face
Hello Scott,

I am a bit on thin ice here, but although I don't know why you want to start
your program at 0x04 instead of 0x00, how about changing this part:

>         goto    start
>         org     0x04

to:

       org     0x04    ; Program starts here.
start                   ;  Ready to rock :-)

Hope I'm not entirely wrong on this one :-)

Cheers, Stig


{Quote hidden}

1998\12\14@152928 by evan

picon face
> I am a bit on thin ice here, but although I don't know why you
> want to start
> your program at 0x04 instead of 0x00, how about changing this part:
>
> >         goto    start
> >         org     0x04
>
> to:
>
>         org     0x04    ; Program starts here.
> start                   ;  Ready to rock :-)
>
Your suggestion will leave address 0x00 undefined (depending on the
assember), which is the first instruction the processor executes after reset
(that's bad).

All PIC interrupts vector to 0x04, so it's good practice to place all code
after this point.  Thus if your PIC program doesn't use interrupts, but for
whatever reason accidentally generates one, the effect will be the same as a
reset.

-Ed V.
Agile Controls
spam_OUTevanTakeThisOuTspamdirect.ca
* Want to leave the piclist?  See
http://persweb.direct.ca/evan/pic/piclist.htm *

1998\12\14@162042 by Michael J. Ghormley

flavicon
face
When I have no interrupt routine I usually write something like this:

; ******************************
; *****  CODE BEGINS HERE  *****
; ******************************
       ORG     0x000           ; reset vector
       GOTO    START           ; jump over interrrupt
;
       ORG     0x004           ; interrupt vector
       RETFIE                  ; no legal INT if we get here there is nothing t
o do
                               ; so just return to doing what you were doing
;
START   ...                     ; initialization code goes here


If I have inadvertatly allowed an INT on PortB or something, at least it has a
minimal effect.  I have always thought that this is a good idea.

What do y`all think?

Michael

*************************************************************************
When the way of the Tao is forgotten, kindness and ethics must be taught.
Men must learn to pretend to be wise and good.  --  Lao Tzu
*************************************************************************

1998\12\14@165834 by Clyde Smith-Stubbs

flavicon
face
On Mon, Dec 14, 1998 at 02:03:55PM -0800, Michael J. Ghormley wrote:
> If I have inadvertatly allowed an INT on PortB or something, at least it has a
> minimal effect.  I have always thought that this is a good idea.

IMHO I think it's not such a good idea. What I would rather do is place
some code at the interrupt vector location that did something noticeable
then hung, e.g. sit in a tight loop toggling an output pin. During development
this would alert you to what has happened. In the field, with the watchdog
timer on, this would lead to a watchdog reset.

Basically the philosophy is that there is no such thing as a small error
in an embedded system - if anything unexpected happens you either want
to know about it RIGHT NOW! or recover in a conservative manner. Trying
to ignore the problem and hope it's not symptomatic of something more
serious will lead to subtly incorrect behaviour that is hard to track
down. Fail-safe is not the same as fail-silently.

Regards, Clyde

--
Clyde Smith-Stubbs               |            HI-TECH Software
Email: .....clydeKILLspamspam@spam@htsoft.com          |          Phone            Fax
WWW:   http://www.htsoft.com/    | USA: (408) 490 2885  (408) 490 2885
PGP:   finger clydespamKILLspamhtsoft.com   | AUS: +61 7 3355 8333 +61 7 3355 8334
---------------------------------------------------------------------------
HI-TECH C: compiling the real world.

1998\12\14@171842 by Scott Shidel...

flavicon
face
On Mon, 14 Dec 1998, Stig Brautaset wrote:

> Hello Scott,
>
> I am a bit on thin ice here, but although I don't know why you want to start
> your program at 0x04 instead of 0x00, how about changing this part:
>
> >         goto    start
> >         org     0x04
>
> to:
>
>         org     0x04    ; Program starts here.
> start                   ;  Ready to rock :-)

Well, i am new to the pics and on things I dont understand I just copy out
of sample programs.  My first program I ever did on mpsim was the tutorial
number 84.  For whatever reason, it starts at 0x04.  I dont understand
why, I just copied it.  Last nite I put it to 0x00 though..Dun ask
me..heheh


-----------------------------------------------------------------------
               The Pinto Page:  http://www.eng.usf.edu/~shidel
                  Join the Ford Turbo Mailing List!
                 http://www.FindMail.com/list/turbo/
Scott
-71 Pinto, stock 2.3 turbo, 13.67@98, radials
       8.1@85 1/8th mile on slicks
-85 Merkur 13.764@98 on radials&3300lbs! Under $300 in mods!
------------------------------------------------------------------------

1998\12\14@190345 by Mike Keitz

picon face
On Mon, 14 Dec 1998 14:03:55 -0800 "Michael J. Ghormley"
<.....mjg99KILLspamspam.....JPS.NOSPAM.NET> writes:

>        ORG     0x004           ; interrupt vector
>        RETFIE                  ; no legal INT if we get here there is
>nothing to do
>                                ; so just return to doing what you
>were doing

>What do y`all think?

A "dummy" ISR consisting of just RETFIE won't clear any interrupt request
flags.  If an enabled interrupt flag does become set, the PIC will start
processing interrupts constantly and the main program will stop.

It would be better to use a RETURN instead.  The PIC's interrupt logic
clears the GIE flag after every interrupt, then ordinarily the RETFIE
will re-set it and allow more interrupts.  But in this case you don't
want more interrupts.  A RETURN will leave GIE cleared so more should
occur after the first spurious one.  In order to be more sure, you could
make the "dummy" ISR a little longer and have it clear all the IE flags
before returning.


___________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com/getjuno.html
or call Juno at (800) 654-JUNO [654-5866]

1998\12\15@010342 by Michael J. Ghormley

flavicon
face
Mike Keitz wrote:
>
> A "dummy" ISR consisting of just RETFIE won't clear any interrupt request
> flags.  If an enabled interrupt flag does become set, the PIC will start
> processing interrupts constantly and the main program will stop.
>
> It would be better to use a RETURN instead.  The PIC's interrupt logic
> clears the GIE flag after every interrupt, then ordinarily the RETFIE
> will re-set it and allow more interrupts.  But in this case you don't
> want more interrupts.  A RETURN will leave GIE cleared so more should
> occur after the first spurious one.  In order to be more sure, you could
> make the "dummy" ISR a little longer and have it clear all the IE flags
> before returning.

This is a good idea.  I figure that there is a typo in the second paragraph and
you meant
to say:

"A RETURN will leave GIE cleared so NO more should occur after the first spuriou
s one."
                                   ^^
Yes?

As far as commercial products (mentioned by a slew of other posters), I never me
ant my
RETFIE to be applied there!  The original poster was talking about a quick one-o
ff thingy
for a hobby project I thought.  I was suggesting that I threw in the RETFIE as b
eing
better than nothing at 0x004.  Mike's idea of RETURN sounds much better if it wi
ll clear
GIE.

Back to the Microchip CD ROM...  Thanks Mike.

Michael

*************************************************************************
When the way of the Tao is forgotten, kindness and ethics must be taught.
Men must learn to pretend to be wise and good.  --  Lao Tzu
*************************************************************************

1998\12\23@163034 by John Payson

flavicon
face
|When I have no interrupt routine I usually write something like this:

|        ORG     0x004           ; interrupt vector
|        RETFIE                  ; no legal INT if we get here there is nothing
to do

|If I have inadvertatly allowed an INT on PortB or something, at least it has a
|minimal effect.  I have always thought that this is a good idea.

Since you don't disable whatever flag caused the interrupt,
the effect of this will most likely be to hang the CPU when
the spurious interrupt occurs; if you're using an emulator,
you'd probably be able to find out where the fault occurred
by looking where the PC went after the RETFIE (I would exp-
ect the instruction at the return address to be fetched even
though it won't execute).

If no watchdog is enabled, then the processor will hang for-
ever until a reset.  If the watchdog is enabled, you may want
to expidite its occurrence by:

               movlw           0       ; Or 128, depending upon what you want
               option          ; ...done with pullups.

Otherwise, for clarity you may want to replace the RETFIE with
a GOTO $ instruction if you don't have an emulator; the latter
is a more obvious "hang the CPU" method and will have the same
net effect.

I disagree with the suggestions of using a RETURN instead of a
RETFIE, or with using a GOTO START [or starting the user code
at address four].  If an interrupt can only occur if there's a
fault (e.g. electrical glitch) then there's no reason to believe
that fault didn't also affect something else.  A watchdog reset
will hopefully recover from such a problem, but a RETURN probably
won't, and even a GOTO START may not (since most programs don't
explicitly turn off PIC features which they don't use, it would
be possible for a PWM or other such function to be turned on and
prevent its I/O port from operating normally).

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