Restart 18F2620


Closed Thread
Results 1 to 9 of 9

Thread: Restart 18F2620

Hybrid View

  1. #1


    Did you find this post helpful? Yes | No

    Default

    Am I correct that this can be used to cancel a GOSUB? Thank you.

    start:
    gosub blink
    do more stuff here

    blink:
    if porta.1 = 1 then sound
    high porta.0
    pause 50
    low porta.0
    return

    sound:
    @ POP
    make sound on a pin
    goto start

  2. #2


    Did you find this post helpful? Yes | No

    Default

    I believe this is correct. I ran into this problem when I switched from a 16F877 to the 18F452. Took a little bit to track it down. The 16F masked my bad coding practice quite well, lol.

  3. #3
    Join Date
    Sep 2005
    Location
    Dayton, Ohio
    Posts
    72


    Did you find this post helpful? Yes | No

    Default

    Peter, yes I would say that is correct (or at least one way to do it). I suppose there are no hard and fast rules per se, but any Programming 101 professor would surely beat us with a stick for exiting a GOSUB with a GOTO rather than RETURN with a flag set or some other method.

    CCK, Same here, I spent MANY hours headscratching over that one. Until I discovered that the processor always reset after exactly the same number of calls to a certain subroutine. Lots of time spent reading the datasheets/forums too. All resulting from poor (untrained) programming practices/bad habits. But learned a LOT in the process. 18F definitely has a few "gotchas" when migrating.
    Jim Robertson
    "MilesTag" DIY Lasertag
    www.lasertagparts.com/mtdesign.htm
    Dayton, Ohio

  4. #4


    Did you find this post helpful? Yes | No

    Default

    Thank you for the fast replies guys. Are you also saying that if you don't cancel a gosub with a return on the 16F parts, it doesn't matter? I am not in the habit of doing this but, as a quick fix to a program, it would be handy to know. I was told it will eventually cause a stack overflow on any PIC. Thank you. - Peter

  5. #5
    sinoteq's Avatar
    sinoteq Guest


    Did you find this post helpful? Yes | No

    Default

    You could test to disable the Stack reset in the configuration bits, that should prevent the MCU from doing a reset when doing a stack under- or overflow. Simple and easy but be aware that a return later in the code can make stange things. Page 253 in the manual if you want to look CONFIG4L register.

  6. #6
    Join Date
    Mar 2005
    Posts
    4


    Did you find this post helpful? Yes | No

    Smile

    Power supply: 3.6V current peaks of up to 2° and a maxximum voltage drop of 300mV durino transmission burst. Local power source feeds the Q2501 module and the PIC 18f2620.
    Connection MCLRE pin – Diode –R 11Kohm – Vcc. I use one breadboard.
    Hour we come to the good news: inserted condenser from 0,1 uf. They are some hours that software turn without restart. The strange characters between the PIC and the PC are passings also. Thanks. Perhaps resolved problem

Similar Threads

  1. In Circut Debug (ICD) buttons palet is disable for 18F2620
    By muskut in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 17th June 2010, 05:21
  2. 18F2620 tmr0 and interrupts
    By astouffer in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 8th March 2009, 00:56
  3. X-10 and the proper XOUT statement for 18F2620
    By JohnP in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 10th December 2007, 22:04
  4. 18F2620 compile problems in PBP
    By Joe Rocci in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 13th August 2006, 10:11
  5. How can I find Code Loader 18F2620 files ?
    By muskut in forum General
    Replies: 1
    Last Post: - 14th October 2005, 12:26

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