I would think this question has been asked thousands of times, I simply cannot find many resources on the subject.
I would like to program my Arduino Uno (ATmega328P) using Atmel Studio and the C language, minus the Arduino Libraries. What I mean by this is that I would like to write code as follows:
int main(void) {
/* set pin 5 of PORTB for output*/
DDRB |= _BV(DDB5);
while (1) {
/* set pin 5 high to turn led on */
PORTB |= _BV(PORTB5);
_delay_ms(BLINK_DELAY_MS);
/* set pin 5 low to turn led off */
PORTB &= ~_BV(PORTB5);
_delay_ms(BLINK_DELAY_MS);
}
}
Rather than code that is riddled with the oh so convenient Arduino functions. I want to get under the hood and get dirty with Arduinos!
That being said, I'm looking for any great learning sources that you may be able to offer so that I can expand my knowledge!
So far, the only somewhat useful source that I've managed to find is this page: https://hekilledmywire.wordpress.com/2010/12/04/22/
However, the images are missing and it seems minimalistic, anyways.
Provided you are familiar with C, I recommend to
...\Atmel Toolchain\AVR8 GCC\Native\[#.#.####]\avr8-gnu-toolchain\avr\include\avr
)*.h
's providing space for things you may/may not need)Be aware that the libraries coming with Atmel Studio and the toolchain support the m328P, but the UNO board per se is not supported by the ASF. However, for basic programming you will be fine.
adding ... on PORTB
PORTB
is defined in your processor's specific...io.h
(1st bullet above) which is automatically included by including<io.h>
and choosing the correct processor in AVR Studio. In the library of your processor you findLooking up the processor guide (4th bullet above) page 615 you see that PORTB is at I/O address
0x05
(q.e.d.)._SFR_IO8(..)
by itself is a macro defined in<avr/sfr_defs.h>
to convert from I/O to memory address (yes the lower registers are double mapped as I/O and Memory, whereby Memory address is by 0x20 higher because the lowest Memory addresses are occupied by R0 to R31).By including
<io.h>
you get from the AVR libraryAll these
...h
's (and some more) finally let you program in C using the register/port/pin names you find in the processor manual.There are some more usefull libs like
you will find libs to support reading/writing from/to program and flash memory etc. etc.