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 ..
//stop errant interrupts until set up..
CLI();//disable all interrupts....
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.
//all peripherals are now initialized.. proceed with other code......
WDR(); // keep serving the dog..!
// all application code here..
} // end of infinite while loop..
} // end of main
PORTA = 0x00;
DDRA = 0x80;
PORTB = 0x00;
DDRB = 0xFA;
PORTC = 0x00;
DDRC = 0xFF;
PORTD = 0x00;
DDRD = 0xFF;
PORTE = 0x00;
DDRE = 0x03;
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
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..