avr-libc-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-libc-dev] wdt problem with mega 88


From: avr
Subject: [avr-libc-dev] wdt problem with mega 88
Date: Tue, 21 Jun 2005 17:22:40 +0100 (BST)

Hello list,

I'm wondering if anyone has any ideas on the following. This program
demonstrates the issue:

#include <avr/io.h>
#include <avr/wdt.h>

#define CHIPOK PD7

#define sbi(p,m) ((p) |= (1<<m))
#define cbi(p,m) ((p) &= ~(1<<m))

void delay( unsigned int delay )
{
        unsigned int a;
        for( a = 0; a < delay ; a++ )
        {
                //wdt_reset();
        }
}

int main( void )
{
        //turn off the wdt
        wdt_disable();

        //set to output
        sbi( DDRD, CHIPOK );

        //delay
        delay( 30000 );

        //turn on led
        sbi( PORTD, CHIPOK );

        //loop
        while( 1 )
        {
                ;;
        }

        return 0;
}

I would expect this program to wait for a time and then turn on an led
indefinately.

What actually happens depends on whether wdt_reset is commented out.

wdt_reset commented: led is off and stays off (because the WDT is
timing out before the delay ends, and resets the program)

wdt_reset uncommented: led is flashing (because the delay completes
but then the WDT times out in the main loop)

It appears that the WDT is on even though I am turning it off.

RE fuse settings: the WDT fuse stuff is set in the high byte, bit 4 - which 
should be
unprogrammed (1) for no WDT. My high byte fuse reads as:

Fuse High Byte     = 0xdf (0b11011111)

Which is correct.

Does anyone have any ideas as to what the issue is here? I'm pretty
sure its WDT issues, but when I checked the MCUSR, the only reset flag
was the power on reset. I could never detect the WDT reset.

Any replies to my address please, as I'm not subscribed.

Cheers,

Matthew

-- 
Never mistake motion for action.
  - Ernest Hemingway





reply via email to

[Prev in Thread] Current Thread [Next in Thread]