Show predefined macros in Atmel Studio (specifically current device)

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

I have an AS7 project that can be compiled for multiple processors using several #define and #ifdef type segments.

The problem comes when trying to explain to someone else that they must both change the device in the project properties AND uncomment the associated #define in the code.

So, is there a predefined macro that gets set with the value of project properties device setting that I could use?

 

And is there a way (in AS7) to show all currently defined and/or predefined macros?

(I seem to remember a recent topic on this, but my google searches have not found anything valid.)

 

Edit: I found a way to list predefined macros:

avr-gcc -dM -E - < /nul > foo.txt

(There is a better way, and much more complete, see posts #2 & #4.)

This topic has a solution.

David

Last Edited: Tue. Nov 8, 2016 - 08:24 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

And is there a way (in AS7) to show all currently defined and/or predefined macros?

VAssistX->Find Symbol? 

 

 

:: Morten

 

(yes, I work for Microchip, yes, I do this in my spare time, now stop sending PMs)

 

The postings on this site are my own and do not represent Microchip’s positions, strategies, or opinions.

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

meolsen wrote:
VAssistX->Find Symbol?
THANKS!yesenlightened

David

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

So, is there a predefined macro that gets set with the value of project properties device setting that I could use?

Yes (but a bit indirectly, so not sure if Visual Assist sees it...)

 

If you look in io.h, (it's in the Dependencies folder in a built project, you can see that there's __AVR_name__ defines. Also, if you look at the bottom there's a new construct called __AVR_DEV_LIB_NAME which is the 'name' of libdev which is the library where all the device specifics are held (this came to be when we worked on being able to add device-knowledge to gcc without recompiling). There's also a __AVR_DEVICE_NAME__

 

For a list of device specific defines, you could look in the spec file. It's located in the pack folder inside the Atmel Studio install folder (i.e for the new ATtiny817 it's in C:\Program Files (x86)\Atmel\Atmel Studio 7.0\packs\atmel\ATtiny_DFP\1.1.102\gcc\dev\attiny817\device-specs\spec-attiny817 on my machine). In the bottom of this file there are some defines that are added to gcc during the build process:

*cpp:
	-D__AVR_ATtiny817__ -D__AVR_DEVICE_NAME__=attiny817 -D__AVR_DEV_LIB_NAME__=tn817

(spec files are how we can configure gcc and add libraries, defines and other command line switches on a per-device basis). Note; all of this is for Studio 7. Spec files were not used for 6 and earlier :) 

:: Morten

 

(yes, I work for Microchip, yes, I do this in my spare time, now stop sending PMs)

 

The postings on this site are my own and do not represent Microchip’s positions, strategies, or opinions.

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

@Morten, that is precisely what I was looking for! Thanks.

(I should have known this!blush)

David