AVR-8515 Watchdog , Brownout etc - Problemo !

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi all ,
At the outset , let me clarify that I am an old hand on PIC , just
moved to AVR . I have downloaded a trial version C compiler from
Imagecraft , and set to work on 8515 . The problem is with the Watchdog
, which I have enabled thus ..

#include
#include
#include
#include
#include
#include

void main(void){
//stop errant interrupts until set up..
CLI();//disable all interrupts....
init_port();
timer0_init();
timer1_init();
WDR();
WDTCR = 0x0F; //WATCHDOG ENABLED - dont forget WDR in main
MCUCR = 0x00;//mcu control and status register
EMCUCR = 0x00;//external mcu control and status register
GICR = 0x00;//general interrupt
TIMSK = 0x02;////TIMER INTERRUPT MASK REG.
SEI();//re-enable interrupts..........
//all peripherals are now initialized.. proceed with other code......
while(1){
WDR(); // keep serving the dog..!
// all application code here..

} // end of infinite while loop..
} // end of main

void init_port(void)
{
PORTA = 0x00;
DDRA = 0x80;
PORTB = 0x00;
DDRB = 0xFA;
PORTC = 0x00;
DDRC = 0xFF;
PORTD = 0x00;
DDRD = 0xFF;
PORTE = 0x00;
DDRE = 0x03;
}

void timer0_init(void)
{
TCCR0 = 0x00;//stop timer
TCNT0 = 0x00;//set count value
OCR0 = 0x00;//OUTPUT COMPARE REGISTER
TCCR0 = 0x02;//0X02..start timer 8 PRESCALER..make it 0x01 for

prescaler of 1 !
}

//TIMER1 initialize - prescale:8
// WGM: 0) Normal, TOP=0xFFFF
void timer1_init(void)
{
TCCR1B = 0x00;//INITIALLY CLEARED
TCNT1H = 0x00;//COUNT H
TCNT1L = 0x00;//COUNT L
OCR1AH = 0x00;//AOUTPUT COMPARE H
OCR1AL = 0x00;//AOUTPUT COMPARE L
OCR1BH = 0x00;//B OP COMPARE H
OCR1BL = 0x00;//B OP COMPARE L
TCCR1A = 0x00;//TIMER1A CONTROL REGISTER
}

Now the problem is... I have provided the maximum possible watchdog timeout i.e. 2 secs odd.. the code body which goes in the infinite loop CANNOT take two seconds , but still the watchdog causes continuous reset.. leading me to conclude that the timeout is not getting programmed correctly ... can anyone throw some light on this ?
Also , HOW does one enable and configure the brownout reset circuitry on the chip from within the application code ? Or is blowing the fuses before the actual flash programming the only method ? If it is , I shudder to think what the production guys might do , rather not do... units going out to field without the brownout enabled and so on...

All good samaritans , please help a newbie..

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I take it that you are discussing an ATMega8515, and not an AT90S8515?

The internal brownout, as well as all the other chip option selectable by "fuses", cannot be set or (in most cases read) by application code running on the AVR. Setup of these options is normally done at ISP time with the chip programming subsystem.

Quote:

WDTCR = 0x0F; //WATCHDOG ENABLED

Not exactly. Check the datasheet for the "timed sequence"--I'm not goinjg to re-type from my locked datasheet (thanks, Atmel). Short answer: One write with "enable" and immediately followed with another with the setup.

Lee

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Problem solved . Thanks a ton.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Did Lee's suggestion fix the problem? If not what did? Think of your fellow human being(s) who might search the forum for the same problem...I bet they would like to see a definitive answer.