diff --git a/docs/Embedded Programming.md b/docs/Embedded Programming.md index caaa906d00d4499c318b4c6e78b2e40bcb0be6f7..0aadd728b36e42d18797e2fa442a64ad45e343c8 100644 --- a/docs/Embedded Programming.md +++ b/docs/Embedded Programming.md @@ -110,12 +110,38 @@ So after uploading the blink code + serial, connect the ftdi board to hello boar 4. Programming with avr-gcc --- -http://archive.fabacademy.org/archives/2016/doc/makefile.html +I used Arduino IDE and the same physical setup (FabISP+ribbon cable+ hello board) and wrote the code in avr-gcc. +Arduino IDE operates avr-gcc in the background. And has an interface over it. So it works easily. +This is the [code file](docs/images/empro/t45-blink-avr-gcc.zip). +``` +#include <avr/io.h> +#include <util/delay.h> + +const int led=PB4; +const int sw=PB3; + + int main(){ + DDRB |= (1<<led); + DDRB &= ~(1<<sw); + + while (1){ + if (!(PINB & (1<<sw))) + PORTB |= (1<<led); + else + PORTB &= ~(1<<led); + } + } +``` + +Basically you inlcude avr/io and delay libraries so that you can use the arduino commands. +Also, the pin numbers are recognised by their ports PB# instead of pin #. + + 5. Programming with Atmel Studio --- - +can't in mac. will do this later on a windows system... 5. References diff --git a/docs/images/empro/gif.gif b/docs/images/empro/gif.gif new file mode 100644 index 0000000000000000000000000000000000000000..b4c9c960de0c18005f7b1b15e7347dec56243197 Binary files /dev/null and b/docs/images/empro/gif.gif differ diff --git a/docs/images/empro/t45-blink-avr-gcc.zip b/docs/images/empro/t45-blink-avr-gcc.zip new file mode 100644 index 0000000000000000000000000000000000000000..60d3461c72cd17e3baec8b69f1bb84e95d19724f Binary files /dev/null and b/docs/images/empro/t45-blink-avr-gcc.zip differ