I am getting a Compiler Error when i use avr/wdt.h include

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

Would someone help me to spot why am i getting these errors having set mcu target, programmer, and port all propely within the Mfile?

I am usig Atmega32 and Winavr Programmer's notepad v2

these are the errors i am getting


main.c:20: warning: 'WDT_vect' appears to be a misspelled signal handler
main.c: In function 'main':
main.c:40: error: 'WDTCSR' undeclared (first use in this function)
main.c:40: error: (Each undeclared identifier is reported only once
main.c:40: error: for each function it appears in.)
main.c:40: error: 'WDCE' undeclared (first use in this function)
main.c:41: error: 'WDIE' undeclared (first use in this function)
main.c:41: error: 'WDP3' undeclared (first use in this function)

when compiling the below code


#include  
#include 
#include  
#include  
 
 void PortInit(void) 
 
 {         
 PORTD|=(1<<PD2);       
 DDRD|=(1<<PD2); 
 } 
 
 ISR(WDT_vect)
 
 {     
 for (uint8_t i=0;i<4;i++)     
   {                 
 PORTD|=(1<<PD2);                 
 _delay_ms(20);                 
 PORTD&=~(1<<PD2);         
 _delay_ms(80);     
   } 
 } 
 
 int main (void)
 
 {    
     
 PortInit();    
 cli(); 
 wdt_reset();  
 MCUCR &= ~(1<<WDRF) ;
 WDTCSR |= (1<<WDCE)|(1<<WDE); 
 WDTCSR |= (1<<WDIE)|(1<<WDE)|(1<<WDP3); 
 sei();  
 _delay_ms(500);     
 while(1)     
   {      
 PORTD|=(1<<PD2);     
 _delay_ms(20);         
 PORTD&=~(1<<PD2);             
 _delay_ms(500);     
   } 
 } 

Thank you.

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

The mega32 does not have a WDT_vect

It's WDT special function registers have differently spelled names.

No. I have not read the mega32A data sheet.
There are often some 'added features' in the A version of a chip. e.g. Tiny2313A and Tiny2313.

Make sure that you read the data sheet relevant to the actual AVR you are using.

It is sensible and often cheaper to use the more modern AVR. e.g. mega324PA

David.

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

Ohh Yes I see David.... you are right.
I actually have both Datasheet in my pdf and i didn't realize i was actually looking into the Atmega324p one !!

Yeah the Atmega32 doesn't surely have the ISR (WDT_vect)
and does this means we can't use its WDT as an interrupt to periodically wake the mcu up? or is there another alternative ways to do this?

Cheers David.

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

Which AVR do you want to use?

The mega32 has a poorer power consumption than the mega324PA.

Look at mega32: "Table 14. Active Clock Domains and Wake Up Sources in the Different Sleep Modes"

Or mega324PA: "Table 9-1. Active Clock Domains and Wake-up Sources in the Different Sleep Modes."

David.

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

I was aware of this david yes indeed the 324 is actually one of the pico-power ones
which is an alternative newer one,
but i havent' always been aware that the 32 doesn't actually have the WDT associated ISR! anyways
Thank you for your clarification.

I have both of them i will surely be using the mega324p
in some of my upcoming projects.

Thanks David.

Cheers

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

The 32 is about 10 years old, the 324 (and even more so the 324P then 324PA) are much younger than this so have benefitted from a lot of design enhancements. If power usage is a concern it would be madness to consider using the 32. While the 32A helps a bit it doesn't help like a 324PA does and nothing will add "modern" features like watchdog interrupt to the old chip design.

WF1903 (aka clawson)

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

Hmmm ...
Someone is "working undercover" ..... :-)

Has the postcounter reached it's max on the other ID , and cant go further

/Bingo