I have been coding and using Arduinos for quite some time now. However I am ready to move up to using straight AVR chips without the arduino bootloader. My question is what are resources to do this?
I want to use linux / mac so winavr is out of the picture as is avrstudio. If there is no such thing as what I am after I will settle for a windows virtual machine. But until I know for sure. What I want is some type of IDE that uses avr-gcc.
As a bonus to this question does anyone have any good resources on learning C for avr? Specifically how to configure Makefiles etc for the various different chips?
Answer
I agree with zklapow but check the projects section on AVR Freaks too. That's how I learnt back in the day before arduinos. Also, you will almost certainly have to read the datasheet for your chip to get anything useful done. There are no nice functions that, for example, read an analog pin in because there are so many parameters that the arduino environment hides from you. Let me give you an example:
int ledPin = 13; // LED connected to digital pin 13
// The setup() method runs once, when the sketch starts
void setup() {
// initialize the digital pin as an output:
pinMode(ledPin, OUTPUT);
}
// the loop() method runs over and over again,
// as long as the Arduino has power
void loop()
{
digitalWrite(ledPin, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(ledPin, LOW); // set the LED off
delay(1000); // wait for a second
}
is roughly similar to the following C (not tested):
int main(void) {
// I just randomly picked pin 6 on PORTB, this may not be the same on an arduino
DDRB = (1<<6); // set pin to output in data direction register
int i; // have to do this outside the for loop because of C standard
while(1) {
PORTB |= (1<<6); // send pin 6 high and leave other pins in their current state
for (i=0; i<10000; i++); // delay
PORTB &= ~(1<<6); // send pin 6 low
for (i=0; i<10000; i++); // delay
}
}
Sure, there are delay functions in some libraries and there may be output functions in other ones, but get used to writing code like this. The only way you can possibly know what all this PORTB and DDRB stuff means is to read the datasheet. I'm sorry to drone on about this but not enough people realize that the datasheet is a goldmine for information.
No comments:
Post a Comment