Forum Menu




 


Log in Problems?
New User? Sign Up!
AVR Freaks Forum Index

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
ferulebezel
PostPosted: Dec 04, 2012 - 08:33 AM
Rookie


Joined: May 04, 2007
Posts: 22
Location: Hillcrest, California

I'm a complete newbie. I haven't played with C for years but I want something that no one makes and I think an AVR board will be the easiest way to make it.

Anyway I dusted off the old PRJC teensy 1.0 and managed to load the fast blinker. Yay.

Now I decided to try compiling blinky and when reading the source I saw something that might be problematic.

Code:
// Teensy 2.0: LED is active high
#if defined(__AVR_ATmega32U4__) || defined(__AVR_AT90USB1286__)
#define LED_ON      (PORTD |= (1<<6))
#define LED_OFF      (PORTD &= ~(1<<6))

// Teensy 1.0: LED is active low
#else
#define LED_ON   (PORTD &= ~(1<<6))
#define LED_OFF   (PORTD |= (1<<6))
#endif


Since I have a 1.0 I don't think that this will be a problem. But I am concerned that I can't find where these are defined. There is no comment in the code saying to define such and such if you have this or that board.

Where are these #defines (__AVR_ATmega32U4__ and __AVR_AT90USB128__)?
 
 View user's profile Send private message  
Reply with quote Back to top
snigelen
PostPosted: Dec 04, 2012 - 08:41 AM
Posting Freak


Joined: Jan 08, 2009
Posts: 1673
Location: Lund, Sweden

It is defined by the compiler when you specify -mmcu=atmega32u4 etc. (which comes from MCU = atmega32u4 in the Makefile).
 
 View user's profile Send private message  
Reply with quote Back to top
meslomp
PostPosted: Dec 04, 2012 - 11:52 AM
Raving lunatic


Joined: May 02, 2007
Posts: 3708
Location: Nieuwegein, Netherlands

Quote:
Where are these #defines (__AVR_ATmega32U4__ and __AVR_AT90USB128__)?


you know that || means OR instead of AND right????

Don't know if AS makes its own makefile or does it another way, but if you in your project you define the right processor and use the internal makefile it should all work well.

If you are not sure if things will compile as expected in the els statement add:
Code:
#error this error should never be seen during project compilation


If for any reason not one of the 2 CPUs are defined then you get an error message thus warning you that something did not go as planned/thought.

_________________
1)Datasheet and application notes checked?
2)tutorial forum
3)Newbie start here
 
 View user's profile Send private message  
Reply with quote Back to top
ferulebezel
PostPosted: Dec 04, 2012 - 04:56 PM
Rookie


Joined: May 04, 2007
Posts: 22
Location: Hillcrest, California

Great, I fount the relevant lines Makefile and uncommented and commented the relevant lines.

Yet, when I compiled, I got errors.

Code:

Compiling C: usb_debug_only.c
avr-gcc -c -mmcu=at90usb162        -I. -gdwarf-2 -DF_CPU=16000000UL -Os -funsigned-char -funsigned-bitfields -ffunction-sections -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=./usb_debug_only.lst  -std=gnu99 -MMD -MP -MF .dep/usb_debug_only.o.d usb_debug_only.c -o usb_debug_only.o
usb_debug_only.c:96:24: error: variable ‘device_descriptor’ must be const in order to be put into read-only section by means of ‘__attribute__((progmem))’
usb_debug_only.c:113:24: error: variable ‘hid_report_descriptor’ must be const in order to be put into read-only section by means of ‘__attribute__((progmem))’
usb_debug_only.c:128:24: error: variable ‘config1_descriptor’ must be const in order to be put into read-only section by means of ‘__attribute__((progmem))’
usb_debug_only.c:175:52: error: variable ‘string0’ must be const in order to be put into read-only section by means of ‘__attribute__((progmem))’
usb_debug_only.c:180:52: error: variable ‘string1’ must be const in order to be put into read-only section by means of ‘__attribute__((progmem))’
usb_debug_only.c:185:52: error: variable ‘string2’ must be const in order to be put into read-only section by means of ‘__attribute__((progmem))’
usb_debug_only.c:198:11: error: variable ‘descriptor_list’ must be const in order to be put into read-only section by means of ‘__attribute__((progmem))’
make: *** [usb_debug_only.o] Error 1


Did they just neglect to define PROGMEM as a 'const' in usb_debug_only.c or .h? or is there some switch somewhere?

Could this have something to do with the fact that I'm using avr-gcc on Ubuntu?

I'm sorry I'm being a pain in the ass but the only way I can learn this type of stuff is to start with something that works and then change one thing at a time an see what happens.
 
 View user's profile Send private message  
Reply with quote Back to top
Koshchi
PostPosted: Dec 04, 2012 - 05:23 PM
10k+ Postman


Joined: Nov 17, 2004
Posts: 14656
Location: Vancouver, BC

I believe that the const requirement was added to avr-gcc well after the code was written.

_________________
Regards,
Steve A.

The Board helps those that help themselves.
 
 View user's profile Send private message  
Reply with quote Back to top
ferulebezel
PostPosted: Dec 04, 2012 - 06:54 PM
Rookie


Joined: May 04, 2007
Posts: 22
Location: Hillcrest, California

So, should I just go ahead and add it to the relevant lines?
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT + 1 Hour
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2006 The PNphpBB Group
Credits