Pages: [1]   Go Down
Author Topic: ATmega168/ATmega328 Arduino-0014 Compiler Problem?  (Read 1009 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 3
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi All,

I am very new to the world of Ardunio, but I must tell you that so far I am having a lot of fun....

I recently purchased the ATmega328 and the Color LCD Shield from nuelectronics.com. Since Iam new to Arduino I decided to run the Demo routines first to make sure every thing was working.

I am using the Arduino-0014 IDE and started with the ATmega128. I was successful in getting the Nokia_lcd_menu.pde demo to run so I desided to install the ATmega328 and run the Demo again.

When compiling the code I get the error: "...In function 'void setup()':
error: 'PB0' was not declared in this scope...."

I have traced this down to the "LCD_BACKLIGHT(1);" function which is defined in the PCF8833.h header file. the specific definition is:

"#define LCD_BACKLIGHT(x)    PORTB= (x)? (PORTB|(1<<PB0)) : (PORTB&~(1<<PB0)"

I also noticed that there is a function prototype defined as well"

"void LCD_Backlight(unsigned char bl_state);"

I have tinkered a bit and made sure that the .H file was being accessed and even moved the definition and prototype into the body of the Nokia_lcd_menu program. (via the IDE)

So far all my attemts have failed. If I comment out the "void LCD_Backlight(unsigned char bl_state);" statement, the program will compile but it will not run..

Again, this appears to be a ATmega328 and Arduino-0014 Compiler Problem.

Can anybody shed some light for me...

Thanks in advaince.

GenOlizer
Logged

Indiana
Offline Offline
Full Member
***
Karma: 1
Posts: 234
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

See http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1237133962/4#4 for more info on PB2.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 3
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi etracer,

Thanks for the post. I'll look it over in more detail in a bit...

BTW, I see that there is a new release of the AVR libraries. Should I consider installing these?

Thanks

GenOlizer
Logged

Indiana
Offline Offline
Full Member
***
Karma: 1
Posts: 234
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
BTW, I see that there is a new release of the AVR libraries. Should I consider installing these?

I don't know.  You haven't said what platform you're running under so I'm assuming Windows.

Unless you can find some specific mention of a bugfix regarding missing definitions for PB0, PB2, etc., then probably not. At this point it's unclear why the definitions are missing for the 328 (or whether it's even a bug). Maybe those definitions have been deprecated and the library you're using needs to be updated. The 328 is almost simply a "bigger" 168, but not completely. A lot of the same kind of problems cropped up when the transition from the ATmega8 to 168 occurred. There were also some differences in the chips and many libraries had to be updated with conditional code that uses different definitions for each chip.

In looking at the header files for the different chips, the ATmega8 and ATmega168 both have PB0-PB7 defined.  The ATMega328 header file has the pin definitions named PORTB0-PORTB7. So you could either change the library to use PORTB0 in place of PB0, or add the definitions for PB0-PB7 to the header file in:
hardware/tools/avr/avr/include/avr/iom328p.h

For reference the header file used for the 8/168 is iomx8.h

Personally I'd recommend the latter as it will maintain code consistency across the different chips. I suspect it's simply a bug that the pins were renamed
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 3
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I suspect it's simply a bug that the pins were renamed

WOW, Thanks a bunch etracer, that worked perfectly. I am a little smarter now  :smiley and you have my admiration... Thanks.  smiley

GenOlizer

Logged

Pages: [1]   Go Up
Jump to: