Embedded programming



Task to do-In this week task is to learn Microcontrollers through datasheets, embedded programming languages and make something with Hello world board in as many as different languages. its a continuation of last assignment consisiting programming and opearation of Hello world board.

To do this I prepared following things.

Arduino UNO board: My fabisp is not functionalso I'm using arduino as a programmer.
Hello world printed board

Softwares and drivers :

Software: Arduino IDE 1.6.3

Drivers:Attiny drivers for Arduino 
Arduino never works directly with Attiny ;forthis we have to download drivers.After downloading go inside documents -->Arduino -->Make new folder HARDWARE--> Put downloaded Attiny folder inside.

Learning through datasheet:

To write a programm for any microcontroller its must to read datasheet first and then write as per. Datasheet helps to understand process and working of that controller . Here I used Attiny 44 microcontroller of AVR family. 



PIN Description: 




VCC : Supply Voltage. 
GND : Ground. 
Port B (PB3:PB0) 4-bit bi-directional I/O port with internal pull-up resistors. 
RESET (PB3 when RSTDISBL fuse = 1) low level (with longer > minimun pulse length) will generate Reset. 
Port A (PA7:PA0) 8-bit bi-directional I/O port with internal pull-up resistors. 


For programming we have to note that

Here inside hello world board pin 4 (reset)connected with button and set as logically high.Port A-pin 2 is used as output and LED is connected to this with 1K resistor.Given supply to attiny44 as per datasheet. 



Programming and process:


Defined pins inside header file. Inside source code -- 

const int numDelys_ms = 500;

    // LED has been connected over Port A, Pin 2 (PA2). Set this pin to be Output pin.
    PORT_DIR_LED = 1<<PIN_LED;

    //Pull Down all the pins of PORTA.
    PORT_LED = 0;

    while (1)
    {
        //Change the state of PA2 to opposite of previous state (toggle).
        PORT_LED ^= 1<<PIN_LED;

        //add delay to take this toggled state ahead for a while.
        _delay_ms (numDelys_ms);
    }

    return 0;
}


To upload this programm on hello world board I used Arduino as a programmer.

For this open Arduino IDE -->connect arduinoUno board--> Go inside file -->Examples-->Arduino as ISP. Load this programm on board to make arduino as a programmer.




Now connect following pins between hello board and arduino.

Attiny 44--Arduino UNO
VCC-- 5V
GND--GND
MISO--Pin12
MOSI--Pin11
SCK--Pin13
RST--Pin10
Now copy header file inside Arduino home folder and source inside Arduino IDE.Go inside tools select port first for arduino UNO board. After this inside tools select board--> Attiny44;clock20MHZ. Under tools go inside programmer-->select arduino as a ISP. Compile and burn a code.


Program by using arduino 

If we are going to use arduino IDE then we have to consider following pin diagram

 

here we can see that pin 11 of attiny44 is pin no 2 for arduino.So I made programm for pin 2 and download in helloword board using fabisp.For arduino I put 2 seconds of delay.  




source code
arduino code
youtube video link