Life after 2k w/ 16F648


Closed Thread
Results 1 to 15 of 15

Hybrid View

  1. #1
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648

    Unhappy Life after 2k w/ 16F648

    Hi,

    I face a strange thing : in my program, I have a not nested GOSUB statement ( without any jumps ...) . It is placed at line 890 ( PBP ) of my program ... ( 2520 assembler lines )

    When alone everything all right ... normal !

    But placed in a FOR NEXT loop ... program hangs up !!!

    The same loop, in a shorter program on a 16F628 runs fine ...

    Any ideas ???

    16F648 also needs to be erased before re-programming ...

    Alain

    PS PBP + MPLAB 7.11 Environment ( Win XP )

  2. #2
    Join Date
    Dec 2003
    Location
    Wichita KS
    Posts
    511


    Did you find this post helpful? Yes | No

    Default

    How is the GoSub returning??

    If I remember correctly, you are only allowed 4 levels of "GoSubs"

    Thus, my first impression would be a "illegal" return from your GoSub... Something like the following:

    Loop:

    .....
    ......
    ......
    if (something happens gosub Loop2)
    goto Loop

    Loop2:
    ......
    ......
    ......
    if (something happens goto Loop) ' This is a NO NO!!!!
    .....
    .....
    return

    end


    Dwayne
    Ability to Fly:
    Hurling yourself towards the ground, and missing.

    Engineers that Contribute to flying:
    Both optimists and pessimists contribute to the society. The optimist invents the aeroplane, the pessimist the parachute

    Pilots that are Flying:
    Those who know their limitations, and respect the green side of the grass...

  3. #3
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Default

    No, it's much simpler ...

    Start:

    result = 0

    For I = 1 to 16....

    GOSUB Thesub
    PULSIN input,1, value

    IF (value < A) OR ( value > B ) then

    error = 1 ( it's a red led ! )
    value1 = ...
    value2 = ...
    GOTO Start

    ENDIF

    result = result + value

    NEXT I

    result = result >> 4 ( the mean value ....)


    .
    .
    .

    the sub:
    Low out1
    Pulsout out1,value1...
    Low out2
    Pulsout out2,value2

    RETURN

    That's all !!!
    Alain

  4. #4
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Is there another GOTO Start that's not enclosed in the IF/THEN block?

    If program execution falls-through, lands in TheSub, then hits the RETURN, it will go haywire on you.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  5. #5
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Default

    Hi, Bruce

    No, nothing else.

    Note without the FOR NEXT, it works well , but a further (in the 2 following lines ) " If result = ...THEN" test always passes, even if values should make the test fail ...

    another strange thing.

    Alain

  6. #6
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Remove the GOTO Start from the IF/THEN block. Place it after the NEXT.
    Last edited by Bruce; - 23rd June 2005 at 19:45.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  7. #7
    Join Date
    Dec 2003
    Location
    Wichita KS
    Posts
    511


    Did you find this post helpful? Yes | No

    Default

    How about a interupt??

    Maybe a wrong return on a interupt (Like a Goto Start), instead of not returning on the GoSub?

    I was looking at your code....

    What happens if A = Value? and that IF statement fails?

    It goes right through 16 times, and then continues to the Subroutine...hits REturn... and...and...<g>

    DWayne
    Ability to Fly:
    Hurling yourself towards the ground, and missing.

    Engineers that Contribute to flying:
    Both optimists and pessimists contribute to the society. The optimist invents the aeroplane, the pessimist the parachute

    Pilots that are Flying:
    Those who know their limitations, and respect the green side of the grass...

Similar Threads

  1. Worst day of my life
    By brid0030 in forum USB
    Replies: 6
    Last Post: - 12th March 2008, 22:27
  2. EEPROM life expectancy?
    By muddy0409 in forum General
    Replies: 3
    Last Post: - 1st May 2007, 12:44
  3. Replies: 5
    Last Post: - 11th February 2007, 23:55
  4. Any chance of Life being easy?
    By josegamez in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 2nd November 2006, 20:52
  5. above 2k with 16F877
    By Peter Oors in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 6th March 2006, 12:43

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts