Restart 18F2620


Closed Thread
Results 1 to 9 of 9

Thread: Restart 18F2620

  1. #1
    Join Date
    Mar 2005
    Posts
    4

    Smile Restart 18F2620

    I ask aid, I do not know English well. Use PBP2.46 and MPLAB v7.50 the circuit works well with 16F876. The connected PIC to Wawecom Q2501ed to the PC. They are passed to the 18F2640. The program from time to time restart and I do not understand the cause, as it is made has to find the cause of the restart? I enclose the SW and the rows 18F2620.INC modified. Salutes to all thanks
    Report PC
    Fine Inizializzazione
    StatoQ2501 OK
    Tensione= 3,377
    GestioneSŤS <---- non corrected ?
    StatoQ2501 OK
    Tensione= 3,377
    .
    .
    .
    Tensione= 3,377
    GestioneSMS
    StatoQ2501 OűStartup Startup <---- SW restart
    Fine controllo RTS/CTS
    Rete GSM OK
    CBST OK
    Fine Inizializzazione
    StatoQ2501OK
    Tensione= 3,377
    GestioneSMS
    3StatoQ2501 OK <---- non corrected ?
    Tensione= 3,377
    GestioneSMS
    StatoQ™501 OK <---- non corrected ?

    .
    .
    .
    GestµoneSMS <---- non corrected ?
    StatoQ2501 OK
    Tensione= 3,377
    GestioneSMS
    StaStartup Startup <---- SW restart
    Fine controllo RTS/CTS
    Rete GSM OK
    CBST OK
    Fine Inizializzazione
    StatoQ2501 OK
    .
    .
    Attached Files Attached Files

  2. #2
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Hello cerio,
    Your English is good enough it seems. I have questions about your power supply and the load you have hooked up to your PIC. Is there a posibility you are drawing too much current on an output or on your power supply? I see you have disabled BODREN. Your MCLRE pin, Is tied to +, yes ? Through what ohm value resistor? I would add a .01 uf capacitor to the power pins directly at the PIC and perhaps, a large capacitor of say 50uf as a transient buffer too.
    HTH
    JS
    EDIT: one last thought, if you are having this problem on a breadboard, IT may be the problem.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

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


    Did you find this post helpful? Yes | No

    Default

    I had a similar problem when moving from 16F to 18F. Finally I discovered it was a STACK OVERFLOW reset. The 16F does not care if you overflow the stack, but the 18F does!

    If you call a subroutine (GOSUB) and you do not RETURN from that subroutine, because of a GOTO or IF-THEN or TimeOut within the subroutine (looks like you have them), then the last address PUSHed onto the stack does not get POPped from the stack and it eventually overflows causing a reset.

    If you exit the subroutine without a RETURN, then you must manually POP the stack. (I also use the STKPTR = 0 in some parts of the program, though I know this is cheating a bit).

    So... anytime you are exiting a subroutine early (not using Return) you should POP the stack:

    @ POP

    On the 16F you can keep pushing onto the stack with no problems, so you never see the problem until you move to an 18F chip.

    I'm sure someone else here can provide a more detailed (accurate?) explanation of the 18F stack pointer, but I hope this at least helps you in the right direction.

    Jim
    Last edited by milestag; - 26th June 2007 at 13:57. Reason: add info
    Jim Robertson
    "MilesTag" DIY Lasertag
    www.lasertagparts.com/mtdesign.htm
    Dayton, Ohio

  4. #4


    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

  5. #5


    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.

  6. #6
    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

  7. #7


    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

  8. #8
    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.

  9. #9
    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 : 1

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