Strange problem with an 18F4580 based project


Closed Thread
Results 1 to 11 of 11

Hybrid View

  1. #1
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    To see where the CLRWDT instructions are inserted, you would have to look at the .LST file because they are part of the library, not the generated .ASM code.

    The one's you found are part of DT_INTS, and as you can see they also respond to the NO_CLRWDT define.

    The base period of the WDT on a 4580 is 4ms, and with a postscaler of 512 it will timeout after about 2 seconds.

    Your main loop will take less than 2 seconds each time so a single CLEARWDT statement at the end of the loop just before GOTO Main should suffice, although it may be advantageous to put it in the area where it updates the heater drives just to be sure that is getting accomplished. But then if you turn off power to all 4 channels, you'll have to clear it somewhere else or it will reset every 2 seconds. You may just have to play with it and see what works best.
    Code:
                IF ChannelPWR(pid_Channel) THEN
                    HeaterDrives(pid_Channel) = pid_Out
                    CLEARWDT
                ELSE
                    HeaterDrives(pid_Channel) = 0
                ENDIF
    HTH,
    DT

  2. #2
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post

    The base period of the WDT on a 4580 is 4ms, and with a postscaler of 512 it will timeout after about 2 seconds.

    Your main loop will take less than 2 seconds each time so a single CLEARWDT statement at the end of the loop just before GOTO Main should suffice,
    Darrel,

    I've added DEFINE NO_CLRWDT 1 at the start of the code along with other defines. Then added one CLEARWDT just before the GOTO MAIN -

    Just before the main loop the code jumps to a simple section that displays the current version
    Code:
    about:
        LCDOUT $FE,2,"   Multi - Therm    "
    lcdout $FE, $C0, "    Thermostat      "
    
    lcdout $FE, $D4, " Firmware Ver 4.60  "
    Pause 2000
    LCDOUT $FE,1
    goto main
    No with the CLEARWDT inserted as suggested the code is constantly displaying the about screen. IE its constantly resetting which looking at the pause 2000 line in the about the same as the WDT.

    So I commented out the GOTO About and the program ran fine, however if I jump to the main menu it quickly resets before you get chance to make any changes. So I guess I have to go through each section of the code to ensure that I insert enough CLEARWDT statements to allow the program to function, but not defeat the purpose of the WDT ?

  3. #3
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Yup, that's part of that "strategically" idea.

    And now you will appreciate the idea of "Event Driven" software, instead of GOSUB somewhere then return when it's finished, whenever that is.

    With event driven, everything keeps running, even if you're moving through menu's on an LCD.

    Keep in mind that if your light bulb spark is causing a false button press and it's going off into one of those routines ... the WDT won't help unless that routine times out eventually because now you've added CLEARWDT's to it.
    DT

  4. #4
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    Yup, that's part of that "strategically" idea.

    And now you will appreciate the idea of "Event Driven" software, instead of GOSUB somewhere then return when it's finished, whenever that is.

    With event driven, everything keeps running, even if you're moving through menu's on an LCD.

    Keep in mind that if your light bulb spark is causing a false button press and it's going off into one of those routines ... the WDT won't help unless that routine times out eventually because now you've added CLEARWDT's to it.
    Yeah, having to work through the sub-routines to add the CLEARWDT so that it doesn't reset, but then to add some form of time out routine so that if nothing is pressed it returns to the main menu.

    I must admit my old brain finds it comfortable with the goto / gosub way of coding... the "if button pressed gosub xyz", and I wouldn't know how to re-work the code for event driven routines... still learning ! I'll keep plodding away through the code to insert the CLEARWDT hear and there, at least it will provide some form protection.

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