Embedded programming

Week 9

Assignment

This weeks project is to read the microcontroller data sheet. Program our board from the electronics design week.
The group project is to compare the performance and development workflows for other architectures.

Group project

For the group project we tested the microbit. You can see the documentation on our group website.

Data Sheet

I ran through the data sheet . The ATtiny24A/44A/84A is a low-power CMOS 8-bit microcontroller based on the AVR enhanced RISC architecture. It is really good for its size and provides many things. Including 2K/4K/8K byte of In-System Programmable Flash. 128/256/512 bytes EEPROM. 128/256/512 bytes SRAM. 12 general purpose I/O lines. 32 general purpose working registers. An 8-bit Timer/Counter with two PWM channels. A 16-bit timer/counter with two PWM channels. Internal and External Interrupts. A 8-channel 10-bit ADC. Programmable gain stage (1x, 20x) for 12 differential ADC channel pairs. A programmable Watchdog Timer with internal oscillator. Internal calibrated oscillator. an a four software selectable power saving modes.
The pins are 14, VCC, GND and eight PA pins and three PB pins. One of the PB pins is the reset pin, The PB are 4-bit-bi-directional. The PA are 8-bit-bi-directional.

There are a few clock subsystems, I/O Clock, Flash Clock, ADC Clock, and also clock sources. There is an internal clock but you have to program it so it uses the clock, you can also use external clocks.
It was important for me to know about the clock and the pins so I could program and draw new boards. I use the internal clock so I had to read about that and also what the pins do and how I should connect them.

Programming with Arduino

For the programming I used the Arduino environment. I mostly used the documentation from high-low tech and Icelandic instructions from the fab wiki.
Bas also helped me and had a lesson for us on the basics of programming with Arduino.
To program using Arduino you have to make the settings right.
Go to tools then board and pick the ATtiny24/44/84

Then the processor Attiny44

and then the clock external 20MHz

Choose the programmer you are using I was using the USBtinyISP

Then I Burn the bootloader

First think I did was make the light blink. I took an example code from Arduino and changed it so it would work for me.

My led was connected to pin number three. In the code the led was connected to pin number 13 so I changed the pin number.

Then I sent it to my board and the light blinked. I also tried making it blink faster and that worked, I just had to change the delay time.


Now I tried making the button work with the led. I also got an example code from Arduino to do that.

I changed then the ledpin to number 3 and the buttonpin to number 2.
Now I sent it to my board and it was working weird. It would turn on the light if I just touched the board at certain places
and sometimes turn of if I pressed the button and sometimes not.
I tried fixing some of my soldering and using the multimiter to check if it was correctly connected.
It did not work so I asked Bas if my drawing was wrong because the button was not working correctly and he asked if I had turned on the pullup resistor
and I had no done that. I googled how to do that and got information from Arduinos website.
After I did that the button worked. When I pressed the button the light turned off.
Then I changed the button state to low and then when I pressed the button the light turned on.

Problems and solutions

The only problem I ran into was when I was programming the button I had to turn on the pullup resistor.
To do that you have to write :

DigitalWrite (buttonPin, HIGH);


Software I used

Microsoft Photos - For photo editing.
Gimp -For photo editing and making the outline.
Windows Movie maker -For Video editing.
Arduino -For programming.

Files from this week

LED blinking.
LED blinking faster.
Button turning on LED.
Button turning off LED.