Embedded Programming

During this week I have to work with the card that was made two weeks ago in the electronics production task, and I have to program it in many different programming languages as possible.

             

I divided the task of the week in 3 different programming languages:

            1.    Assembly Language

            2.    Language C

            3.    Language Arduino

1. - Assembly Language

The code used is:

  • /* LED.asm
  •  * Created: 10/05/2013 09:37:50 a.m.
  •  * Author: FABLAB México (FABMEX) */
  •  .include "tn44Adef.inc"
  •  .def conf = R16
  •  .def entrada = R17
  •  .org 0x0000 rjmp RESET
  •  RESET:
  •  ldi conf, 0b00000100//0xFF
  •  out DDRA, conf
  •  ldi conf, 0xFF
  •  out DDRB, conf
  •  clr conf
  •  INICIO:
  •  in      entrada, PINA
  •  ror  entrada
  •  out  PORTA, entrada
  •  rjmp inicio

Download files Assambly Languaje (AVR Studio 6)

2. - Language C

The code used is:

/* BotonLed.c

 * Created: 14/05/2013 11:33:06 a.m.

 * Author: FABLAB México (FABMEX) */

#include <avr/io.h>

#include <util/delay.h>

int main(void)

{

       DDRA = 0b00000100; 

       DDRB = 0xFF; 

       PORTA &= ~(1<<PA2); // PORTA = 0b0000 0100;

       while (1)

       {

             if (PINA & (1<<PA3)) //pulsado if (PINA = scanf (PORTB) & 0b0000 1000)

             PORTA = 0b00000100; //enciende el led

             else

             PORTA = 0b00000000; //0x00; //apaga el led

            

       }

}

Download files Languaje C (AVR Studio 6)

To program in these two different languages I used AVR Studio 6, which runs on Windows and has its own programming module (if using a commercial programmer ATMEL). I used it because facilitates the creation of the code C and/or the assembler that highlights and auto completes the commands.

AVR Studio 6

To verify that both of the codes in the Assembly Language and Language C were, I used a simulator (Proteus 7 "trial license") to observe that both codes were working.

Simulation without pressing the button

Simulation by pressing the button

Download files Simulation (Proteus 7)

To load the code in the Assembly Language to the microcontroller I used the AVR Studio 6 module, and the AVRISP mkii programmer, and I could not find how to load it from the avrdude; however, to program the C code I have used avrdude with the FabISP, and that is why I created the FabISP in the task 4.

        Programming Module  AVR Studio 6                                            avrdude

3. - Language Arduino

For this language I use the sample code that comes with the arduino program, changing the programmer and the card to use, for this I based in the tutorial of Anna Kaziunas

http://www.as220.org/fabacademy/tutorials/embedded_programming_arduinoIDE.php

 


And the result that I got with the 3 codes is the following: