1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

watchdog timer

Discussion in '8051/8951' started by Anderson_87, Jun 22, 2012.

  1. Anderson_87

    Anderson_87 New Member

    Joined:
    Jun 22, 2012
    Messages:
    1
    Likes:
    0
    Hi,
    I would like to know about the watchdog Timer.
    I am working on CCS compiler and i want to know at what time the reset occurs. My code is


    #include <16F877A.h>
    #fuses WDT,XT

    int8 i,j;

    void main()
    {
    TRISA=0x00;
    TRISB=0x00;
    TRISC=0x00;
    TRISD=0x00;
    TRISE=0x00;

    PORTA=0x00;
    PORTB=0x00;
    PORTC=0x00;
    PORTD=0x00;
    PORTE=0x00;

    OPTION_REG=0X88;
    INTCON=0XE0;
    T0IE=1;

    switch(restart_cause())
    {
    case WDT_TIMEOUT:
    lcd_putc("\fwatch timeout");
    break;
    case NORMAL_POWER_UP:
    lcd_putc("\fnormal time out");
    break;
    }

    setup_wdt(WDT_2304MS);

    while(true)
    {
    lcd_putc("\fnormal operation");
    while(1);

    }

    }
     
  2. alec_t

    alec_t Well-Known Member Most Helpful Member

    Joined:
    Jul 10, 2011
    Messages:
    9,255
    Likes:
    1,218
    Location:
    Cardiff, Wales
    From the datasheet the WDT period is from 7 to 33 mS (typically 18 mS) with no prescaler, but it looks as though your code assumes 18 mS and sets the prescaler to 128 to give a period of 2304 mS. In reality the period could be anywhere from 896 to 4224 mS.
     
  3. WTP Pepper

    WTP Pepper Active Member

    Joined:
    Jan 24, 2012
    Messages:
    648
    Likes:
    41
    Location:
    UK
    main is not terminated with a } for a start.
     

Share This Page