Skip to main content
deleted 6 characters in body
Source Link
JYelton
  • 34.9k
  • 34
  • 147
  • 272

I was using ATmega32A before and now iI am migrating to ATmega324PA just to enhance power management. So nowNow I am testing the new controller in every aspectsaspect. This is a simple code to check the watchdog timer andbut it keeps on resetting the controller.

codeCode:

int main(void)
{
  uart_init();
  PORTA|=(1<<PORTA1);
  _delay_ms(1500);
  PORTA&=~(1<<PORTA1);
  _delay_ms(2000);
  uart_array("FFFFFFFFFFFFFFFFFF");
  wdt_enable(WDTO_2S);
  _delay_ms(5000);
}

void uart_init()
{
 /*set PinA1 as output for LED*/
 DDRA|=(1<<1);

 /*set PinD3 as output for UART*/
 DDRD|=(1<<3);

 /*set pinD2 as input for UART*/
 DDRD&=~(1<<2);

 /*enabling TX and RX*/
 UCSR1B |=(1<<TXEN1) | (1<<RXEN1);

 /*asynchronous mode selection*/
 UCSR1C&=~(1<<UMSEL11);
 UCSR1C&=~(1<<UMSEL10);

 /*setting data format to 8 bit*/
 UCSR1B &=~(1<<UCSZ12);
 UCSR1C|=(1<<UCSZ11)|(1<<UCSZ10);

 /* setting one bit as stop bit*/
 UCSR1C &=~(1<<USBS1);

 /*Disabling parity*/
 UCSR1C &= ~((1<<UPM11) | (1<<UPM10));

 /* loading 8 LSB to UBRRL*/
 UBRR1L = UBRRL_VALUE;

 /* loading 4 MSB to UBRRH*/
 UBRR1H = UBRRH_VALUE;
}

The code works well for the first time and, but after that, LED keeps blinking.

Note: watchdog  (WDTON) fuse bit is disabled.

I was using ATmega32A before and now i am migrating to ATmega324PA just to enhance power management. So now am testing the new controller in every aspects. This is a simple code to check the watchdog timer and it keeps on resetting the controller

code:

int main(void)
{
  uart_init();
  PORTA|=(1<<PORTA1);
  _delay_ms(1500);
  PORTA&=~(1<<PORTA1);
  _delay_ms(2000);
  uart_array("FFFFFFFFFFFFFFFFFF");
  wdt_enable(WDTO_2S);
  _delay_ms(5000);
}

void uart_init()
{
 /*set PinA1 as output for LED*/
 DDRA|=(1<<1);

 /*set PinD3 as output for UART*/
 DDRD|=(1<<3);

 /*set pinD2 as input for UART*/
 DDRD&=~(1<<2);

 /*enabling TX and RX*/
 UCSR1B |=(1<<TXEN1) | (1<<RXEN1);

 /*asynchronous mode selection*/
 UCSR1C&=~(1<<UMSEL11);
 UCSR1C&=~(1<<UMSEL10);

 /*setting data format to 8 bit*/
 UCSR1B &=~(1<<UCSZ12);
 UCSR1C|=(1<<UCSZ11)|(1<<UCSZ10);

 /* setting one bit as stop bit*/
 UCSR1C &=~(1<<USBS1);

 /*Disabling parity*/
 UCSR1C &= ~((1<<UPM11) | (1<<UPM10));

 /* loading 8 LSB to UBRRL*/
 UBRR1L = UBRRL_VALUE;

 /* loading 4 MSB to UBRRH*/
 UBRR1H = UBRRH_VALUE;
}

The code works well for the first time and after that LED keeps blinking.

Note: watchdog(WDTON) fuse bit is disabled

I was using ATmega32A before and now I am migrating to ATmega324PA just to enhance power management. Now I am testing the new controller in every aspect. This is a simple code to check the watchdog timer but it keeps resetting the controller.

Code:

int main(void)
{
  uart_init();
  PORTA|=(1<<PORTA1);
  _delay_ms(1500);
  PORTA&=~(1<<PORTA1);
  _delay_ms(2000);
  uart_array("FFFFFFFFFFFFFFFFFF");
  wdt_enable(WDTO_2S);
  _delay_ms(5000);
}

void uart_init()
{
 /*set PinA1 as output for LED*/
 DDRA|=(1<<1);

 /*set PinD3 as output for UART*/
 DDRD|=(1<<3);

 /*set pinD2 as input for UART*/
 DDRD&=~(1<<2);

 /*enabling TX and RX*/
 UCSR1B |=(1<<TXEN1) | (1<<RXEN1);

 /*asynchronous mode selection*/
 UCSR1C&=~(1<<UMSEL11);
 UCSR1C&=~(1<<UMSEL10);

 /*setting data format to 8 bit*/
 UCSR1B &=~(1<<UCSZ12);
 UCSR1C|=(1<<UCSZ11)|(1<<UCSZ10);

 /* setting one bit as stop bit*/
 UCSR1C &=~(1<<USBS1);

 /*Disabling parity*/
 UCSR1C &= ~((1<<UPM11) | (1<<UPM10));

 /* loading 8 LSB to UBRRL*/
 UBRR1L = UBRRL_VALUE;

 /* loading 4 MSB to UBRRH*/
 UBRR1H = UBRRH_VALUE;
}

The code works well for the first time, but after that, LED keeps blinking.

Note: watchdog  (WDTON) fuse bit is disabled.

Source Link
gzix
  • 403
  • 9
  • 22

Watchdog timer issue - AVR ATmega324PA

I was using ATmega32A before and now i am migrating to ATmega324PA just to enhance power management. So now am testing the new controller in every aspects. This is a simple code to check the watchdog timer and it keeps on resetting the controller

code:

int main(void)
{
  uart_init();
  PORTA|=(1<<PORTA1);
  _delay_ms(1500);
  PORTA&=~(1<<PORTA1);
  _delay_ms(2000);
  uart_array("FFFFFFFFFFFFFFFFFF");
  wdt_enable(WDTO_2S);
  _delay_ms(5000);
}

void uart_init()
{
 /*set PinA1 as output for LED*/
 DDRA|=(1<<1);

 /*set PinD3 as output for UART*/
 DDRD|=(1<<3);

 /*set pinD2 as input for UART*/
 DDRD&=~(1<<2);

 /*enabling TX and RX*/
 UCSR1B |=(1<<TXEN1) | (1<<RXEN1);

 /*asynchronous mode selection*/
 UCSR1C&=~(1<<UMSEL11);
 UCSR1C&=~(1<<UMSEL10);

 /*setting data format to 8 bit*/
 UCSR1B &=~(1<<UCSZ12);
 UCSR1C|=(1<<UCSZ11)|(1<<UCSZ10);

 /* setting one bit as stop bit*/
 UCSR1C &=~(1<<USBS1);

 /*Disabling parity*/
 UCSR1C &= ~((1<<UPM11) | (1<<UPM10));

 /* loading 8 LSB to UBRRL*/
 UBRR1L = UBRRL_VALUE;

 /* loading 4 MSB to UBRRH*/
 UBRR1H = UBRRH_VALUE;
}

The code works well for the first time and after that LED keeps blinking.

Note: watchdog(WDTON) fuse bit is disabled