Deploying AVR libc code?

For Adafruit customers who seek help with microcontrollers

Moderators: adafruit_support_bill, adafruit

Deploying AVR libc code?

Postby Jaanus » Sat Feb 16, 2008 2: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
#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 12:36 pm, edited 1 time in total.
Jaanus
 
Posts: 12
Joined: Sat Feb 16, 2008 2:16 am

Postby adafruit » Sat Feb 16, 2008 11:42 am

you need a more recent compiler
User avatar
adafruit
 
Posts: 10483
Joined: Thu Apr 06, 2006 3:21 pm
Location: nyc

Postby Jaanus » Sat Feb 16, 2008 12: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 2:16 am

Postby adafruit » Sat Feb 16, 2008 12:35 pm

arduino wasnt built with a recent compilre, so dont use 0b notation and you're fine
User avatar
adafruit
 
Posts: 10483
Joined: Thu Apr 06, 2006 3:21 pm
Location: nyc

Postby Jaanus » Sat Feb 16, 2008 12: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 2:16 am

Postby Jaanus » Sun Feb 17, 2008 4: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 2:16 am


Return to Microcontrollers

Who is online

Users browsing this forum: No registered users and 2 guests

Stuff to buy from the Adafruit store and links to product documentation!


New Products [105]

Raspberry Pi[80]
 
FLORA[23]
 
Bunnie Studios[9]
 
FPGA[1]
 
mbed[11]
Arduino[60]
 
NETduino[14]
 
BeagleBone[24]
 
Android[6]
 
XBee[10]
More Dev Boards[30]


 
BoArduino[8]
 
SpokePOV[4]
 
TV-B-Gone[4]
 
MiniPOV[3]
 
SIM reader[3]
 
Microtouch[5]
 
Clocks & Watches[18]
 
Drawdio[4]
 
Brain Machine[1]
 
Game of Life[2]
 
MintyBoost[2]
More DIY Kits[16]


 
MaKey MaKey[3]
 
Tweet-a-Watt[5]
 
Young Engineers[33]
 
Discover Electronics[2]
 
Snap Circuits[4]
 
littleBits[3]
 
Project packs[8]


 
Breakout Boards[33]
LCDs & Displays[48]
Components & Parts[69]
Batteries & Power[49]
EL Wire/Tape/Panel[52]
LEDs[108]
 
Wireless[14]
Cables[60]
 
Lasers[6]
Sensors/Parts[145]
 
Enclosures/Cases[11]
 
Solar[11]
 
RFID / NFC[13]
Prototyping[69]
 
iDevices[13]
Tools[71]
 
Wearables[39]
 
CNC[37]
 
Robotics[29]
 
3D printing[1]
 
Materials[24]


 
Stickers[41]
 
Skill badges[55]
 
Books[25]
 
Circuit Playground[7]
 
Gift Certificates[4]