08.EMBEDDED PROGRAMMING
Mar 16, 2016
This week's assignment are reading a microcontroller data sheet, and programming my board to do something, with as many different programming languages.
08-1.Setting up
First, set up the board that I made in week 6.[Tool]
Software: CotEditor / Arduino
Components: FabISP (that I made in week4.) / Mini USB Cable / FTDI Cable / 6 Wire Ribbon Cable with Sockets ...And my original board!
[Data]
- hello.ftdi.44.echo.c
- hello.ftdi.44.echo.c.make
[Proccess]
1.Coloring the board
2.Create the folder
3.Writing the program
4.Check the board with Arduino
08-2.Programming the board to do 'something'
1.Learning about the ATTINY44A2.Programming
I edited Neil's program so that the board’s led will flash when it receives one character. And I used Yumi Nishihara's archive below as reference.
The following is what I changed and added in Neil’s program. ( Full data > hello.44.led.c )
---
- How long the led will blink
#define led_delay()_delay_ms(100)
---- Setting the ports
#define led_port PORTA
#define led_direction DDRA
#define led_pin (1 << PA2)
---- Blinking function of the LED
void blink() {
static int i;
i = 0;
while(i < 10) {
set(led_port, led_pin);
led_delay();
clear(led_port, led_pin);
led_delay();
i++;
}
}
---- Blinking function of LED and Reading of characters
index = 0;
while (1) {
get_char(&serial_pins, serial_pin_in, &chr);
buffer[index++] = chr;
if (chr =='t')
{
put_string(&serial_port, serial_pin_out, "Traffic cone!");
index = 0;
blink();
put_char(&serial_port, serial_pin_out, 10); // new line
}
else
{
put_string(&serial_port, serial_pin_out, "hmm...");
index = 0;
put_string(&serial_port, serial_pin_out, buffer);
put_string(&serial_port, serial_pin_out, "? ( )raffic cone?");
put_char(&serial_port, serial_pin_out, 10); // new line
}
}
}
3.Running