Go Down

Topic: [SOLVED] Identifying the chip at compile time (Read 5400 times) previous topic - next topic

wanderson

Jun 06, 2012, 06:09 pm Last Edit: Jun 06, 2012, 07:47 pm by wanderson Reason: 1
I am attempting to modify some code I created to take into account different register definitions for an attiny85.  I found the following #ifdef in the tiny library so I thought this would work:

Code: [Select]

#if defined( __AVR_ATtinyX5__ )
 WDTCR |= _BV(WDCE) | _BV(WDE); // WDT control register, This sets the Watchdog Change Enable (WDCE) flag, which is  needed to set the
 WDTCR = _BV(WDIE);             // Watchdog system reset (WDE) enable and the Watchdog interrupt enable (WDIE)
#else
 WDTCSR |= _BV(WDCE) | _BV(WDE);// WDT control register, This sets the Watchdog Change Enable (WDCE) flag, which is  needed to set the
 WDTCSR = _BV(WDIE);            // Watchdog system reset (WDE) enable and the Watchdog interrupt enable (WDIE)
#endif


However, when I attempt to compile the library using the board="ATtiny85@8MHz (Internal oscillator. BOD disabled)" I get an error message : "home/wandrson/sketchbook/libraries/Entropy/Entropy.cpp:51:3: error: 'WDTCSR' was not declared in this scope" which seems to indicate that it is executing the else condition rather than the ATtiny code...  I've searched and can't find a reference to what I should find defined for each of the AVR chips...  Any suggestions on where I can find that information, or if something is wrong with my syntax above?

Coding Badly


__AVR_ATtinyX5__ is defined by and specific to the Tiny Core...
http://code.google.com/p/arduino-tiny/source/browse/trunk/hardware/tiny/cores/tiny/core_build_options.h#97

core_build_options.h is also specific to the Tiny Core and disappears in the next version so I suggestion using this...

Code: [Select]
#if defined( __AVR_ATtiny25__ ) || defined( __AVR_ATtiny45__ ) || defined( __AVR_ATtiny85__ )

wanderson

CodingBadly:

Thanks for the information.  Could you give me a reference to where I could find what macros are defined for what processors, in case I incorporate other processor types.  I've search the AVR-LIBC documentation and haven't found any information.  Would prefer not to find and grep the source for the library.

Coding Badly

#3
Jun 06, 2012, 07:44 pm Last Edit: Jun 06, 2012, 07:47 pm by Coding Badly Reason: 1
Could you give me a reference to where I could find what macros are defined for what processors, in case I incorporate other processor types.


I'm not aware of such a reference.  I do know that the pattern for the which-processor macro is always the same...

[font=Courier New]  __AVR_ATtiny45__[/font]

Where...
[font=Courier New]  "__AVR_"[/font] is always the prefix
[font=Courier New]  "ATtiny45" [/font]is the exact model name from Atmel's documentation
[font=Courier New]  "__" [/font]is always the suffix

You will have to consult the datasheet(s) for which processors are in which families.  There are no [font=Courier New]__AVR_ATtinyX5__[/font] like macros available from AVR-GCC or Libc.

Or did I misunderstand.  By "what macros are defined for what processors" do you also mean the "register macros"?

Quote
Would prefer not to find and grep the source for the library.


That's the route I've always taken.


Go Up