Lately, I have been dabbling with AVR programming. In the process I am beginning to understand the differences between the Arduino method and for the lack of a better term the real world method. Arduino is a great device when it comes to introduction to microprocessors and controllers. And its the way I started, but Arduino is like training wheels on a bicycle you need to remove them at some point.

So what did I learn ?
First, burning code into an Arduino is simpler compared to the way its done normally. Arduino uses a small program known as bootloader. The bootloader is a small piece of software that enables code to be loaded directly into the controller without using any external hardware programmers like a USBasp. The downside is that it eats precious flash memory of your controller. The USBasp is an ICSP (Incircuit Serial Programmer) which is used to transfer the code to the non-volatile memory of the microcontroller. The device that I am using in the picture is connected to the computer by a USB. The compiled code comes to the USBasp and is sent to the controller by using a SPI interface. So it is a fairly complicated task compared to the programming method used in Arduinos. But, this is all just to save memory which is quite low in microcontrollers.
Second in the Arduino programming language the pinMode( ) and digitalWrite( ) functions are fairly easy to understand. In AVR programming in place of these functions hardware registers are used. Now this is a fairly cryptic, so let me explain.
In Atmel microcontrollers the GPIOs (General Purpose Input Output) pins are divided into ports of 8 bits or pins which are individually addressable. These ports are labelled B,C,D (Look up Atmega328p pinout) .The pinMode( ) function decides whether a pin acts as input or output.How it actually works is that a register of 8 bits on the controller's RAM is hardwired to the 8-pins of the port. Now say we want the pin 0 of port B to act as an output we give this register known as DDR( Data Direction Register ) the value 00000001. It looks something like this-
DDRB = 0b00000001 ;
(where 0b means binary)
The pins 1-7 are made input and pin 0 is output.
How is this better ? you might ask. Well its not. But its certainly faster. The Arduino uses a software command defined in a library which needs to be referred to before execution occurs. While the DDRx is integral to the hardware.
In a similar fashion the digitalWrite( ) function which toggles the output pin HIGH or LOW value is actually a function referring to a register known as PORT in AVR programming. If we want to toggle the pin 0 of port B high (5v) we write,
PORTB = 0b00000001 ;
Now some terms that I have used here maybe new to beginners and believe me I know. What I do to understand them is look them up on wikipedia and write them down and when I come across them again, I refer to what I wrote and make changes if necessary. By doing this I slowly understand what they do. Hope that helps.
until next time,
Abhijeet Dutt Srivastava

So what did I learn ?
First, burning code into an Arduino is simpler compared to the way its done normally. Arduino uses a small program known as bootloader. The bootloader is a small piece of software that enables code to be loaded directly into the controller without using any external hardware programmers like a USBasp. The downside is that it eats precious flash memory of your controller. The USBasp is an ICSP (Incircuit Serial Programmer) which is used to transfer the code to the non-volatile memory of the microcontroller. The device that I am using in the picture is connected to the computer by a USB. The compiled code comes to the USBasp and is sent to the controller by using a SPI interface. So it is a fairly complicated task compared to the programming method used in Arduinos. But, this is all just to save memory which is quite low in microcontrollers.
Second in the Arduino programming language the pinMode( ) and digitalWrite( ) functions are fairly easy to understand. In AVR programming in place of these functions hardware registers are used. Now this is a fairly cryptic, so let me explain.
In Atmel microcontrollers the GPIOs (General Purpose Input Output) pins are divided into ports of 8 bits or pins which are individually addressable. These ports are labelled B,C,D (Look up Atmega328p pinout) .The pinMode( ) function decides whether a pin acts as input or output.How it actually works is that a register of 8 bits on the controller's RAM is hardwired to the 8-pins of the port. Now say we want the pin 0 of port B to act as an output we give this register known as DDR( Data Direction Register ) the value 00000001. It looks something like this-
DDRB = 0b00000001 ;
(where 0b means binary)
The pins 1-7 are made input and pin 0 is output.
How is this better ? you might ask. Well its not. But its certainly faster. The Arduino uses a software command defined in a library which needs to be referred to before execution occurs. While the DDRx is integral to the hardware.
In a similar fashion the digitalWrite( ) function which toggles the output pin HIGH or LOW value is actually a function referring to a register known as PORT in AVR programming. If we want to toggle the pin 0 of port B high (5v) we write,
PORTB = 0b00000001 ;
Now some terms that I have used here maybe new to beginners and believe me I know. What I do to understand them is look them up on wikipedia and write them down and when I come across them again, I refer to what I wrote and make changes if necessary. By doing this I slowly understand what they do. Hope that helps.
until next time,
Abhijeet Dutt Srivastava