A C A D E M Y 2016
ASSIGNMENT

 

GENERAL OBJETIVE:

8

 

Embedded Programming

 

  •    Read a microcontroller data sheet
  •    Program your board to do something, with as many different programming languages

      and programming environments as possible

  •    Extra credit: experiment with other architectures

 

 

The objective of this assignment is to create a program to run tablet created in Week 06 (Electronics Design), in this case the tablet contains 3 devices: 1 input (button) and 2 output (LED's) and the program to create is: on a different lED each time the button is pressed.

 

assigment6_10_25629104725_o

 

Illustration 1 Tablet Designed in Week 6

 

To begin will be the development tool AVR Studio to create development projects for micro-controllers AVR

 

assignment8_3

 

Figure 2 Interface Home AVR Studio (New Project)

 

Once you choose to create a new project, you must select the language that is to be programmed, as shown in Figure 2. Posterior is to choose the device to be programmed.

 

assignment8_1

 

Figure 3 Selecting Device to Programming

 

The code used in assembly language is:

;

; EmbedProg.asm

;

; Week06_Embedded_Programming.asm

;

; Created: 06/04/2016 09:09:18 a. m.

; Author : Iván Hernández Sánchez

;

.include "tn44def.inc"

 

.def boton = r16

.def led1 = r17

.def led2 = r18

.def temp = r19

.def aux = r20

 

.org 0x0000  rjmp RESET

 

 

; Replace with your application code

RESET:

 LDI  aux, 0b01111111

 OUT  DDRA, aux

 

LECTURA:

 IN  boton, PINA

 MOV  temp, boton

 ANDI temp, 0b10000000

 CPI  boton, 0

 BRNE LEDROJO

 RJMP LEDVERDE

 

LEDROJO:

 LDI  led1, 0b00001000

 OUT  PORTA, led1

 RJMP LECTURA

 

LEDVERDE:

 LDI  led2, 0b00000100

 OUT  PORTA, led2

 RJMP LECTURA

 

assignment8_2

 

Figure 4 Assembly Language in AVR Studio

 

With the help of tutorial Anna Kazzihunas (See tutorial) connects the Attiny44 with the FTDI cable to program using the Arduino IDE; however, the ID Arduino 1.0.5 was used and the code used is as follows:

 

 int ledverde = 2, ledrojo = 3;

int boton = 7;

 

void setup()

{

  pinMode(ledrojo, OUTPUT);

  pinMode(ledverde, OUTPUT);

  pinMode(boton, INPUT);

}

 

void loop()

{

  int aux;

  aux=digitalRead(boton);

  if (aux==HIGH)

  {

    digitalWrite(ledrojo, HIGH);

    digitalWrite(ledverde, LOW);

  }

  else

  {

    digitalWrite(ledverde, HIGH);

    digitalWrite(ledrojo, LOW);

  }

}

 

assignment8_4

 

Figure 5 Language Arduino ID Arduino 1.0.5 with Library ATtiny

 

download codes

Assembler

Arduino

The latest drivers for the FTDI cable is here (click)

 

Once the program tablet loaded is tested, it is observed that is not working properly; however, doing a simulation of it it can be seen that the code does what it should do. The simulation was performed in Proteus 8.1

 

Download file simulation (here)

 

 

assignment8_5

 

Figure 6 Simulation Proteus 8