Adafruit is open and shipping! Let's build back better, together!
0

Deploying AVR libc code?
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Deploying AVR libc code?

by Jaanus on Sat Feb 16, 2008 3:27 am

Hi,

I built myself a nice little Boarduino and am now trying to program it. Everything works perfect in the Arduino development environment when using the Arduino's own system calls (the stuff from http://www.arduino.cc/en/Reference/HomePage). I can upload code to board, run programs etc.

I would like to move on to AVR libc and deploy more low-level code, but I am having trouble figuring out how exactly the development toolchain works. As far as I understand, I can just #include the relevant avr libraries and enter the code directly in the Arduino dev. environment. However, when I enter the following code...


Code: Select all | TOGGLE FULL SIZE
#include <avr/io.h>

const int ledPin = 13;                // LED connected to digital pin 13

void setup()                    // run once, when the sketch starts
{
  pinMode(ledPin, OUTPUT);      // sets the digital pin as output
  digitalWrite(ledPin, LOW);  // make sure it's low before going to use the
                            // libc calls
 
  DDB |= 0b100000;   // pinMode(13, OUTPUT)
  PORTB |= 0b100000; // digitalWrite(13,1);

}

void loop()                     // run over and over again
{

}


The Arduino compiler says: "error: invalid suffix "b100000" on integer constant In function 'void setup()':"

I am sure it's something simple I'd need to do... any hints? :roll:
Last edited by Jaanus on Sat Feb 16, 2008 1:36 pm, edited 1 time in total.
Jaanus
 
Posts: 12
Joined: Sat Feb 16, 2008 3:16 am

by adafruit on Sat Feb 16, 2008 12:42 pm

you need a more recent compiler

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm
Location: nyc

by Jaanus on Sat Feb 16, 2008 1:03 pm

Hmm... I'm using Arduino 0010 which is the integrated environment and seems to be the newest ver. Should I install anything on top of that?
Jaanus
 
Posts: 12
Joined: Sat Feb 16, 2008 3:16 am

by adafruit on Sat Feb 16, 2008 1:35 pm

arduino wasnt built with a recent compilre, so dont use 0b notation and you're fine

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm
Location: nyc

by Jaanus on Sat Feb 16, 2008 1:47 pm

Thanks! :) I converted to hex and now I'm not getting this particular error any more.
Jaanus
 
Posts: 12
Joined: Sat Feb 16, 2008 3:16 am

by Jaanus on Sun Feb 17, 2008 5:23 pm

Maybe this helps someone else... I figured it out with external help. The code I posted has two bugs:

1) instead of 0b100000 notation, use B100000 notation

2) it should be DDRB, not DDB

and then it works :)
Jaanus
 
Posts: 12
Joined: Sat Feb 16, 2008 3:16 am

Please be positive and constructive with your questions and comments.