Week 8 - Embedded programming

After making a programmer and a board it is time to write a little program and transfer it to the board. The chip, I am using, is the ATTiny 44 SSU. It is a 8 Bit chip, that is important to know for the baud rate, if communicating via serial port (USB). A baud is bits/second. For USB it is 115200 baud. In week six I figured out the right delay time of 7.85 µs to communicate with my board. For using it right now, I need to write a c-code and a make file and upload it with my programmer. I used the FABISP USBtiny and the smae routine, as for programming the helloechoworld program.

Blink

My first program was to make the LED blink. First I wanted to try interrupts but I ended up using the delay command.

Basically I turn all PORTA register into outputs, means high. On every PORTA pin is then 5V and the LED lights up for 50 ms. Then the cycle starts again until eternity, since there is no abort command.

Switch

My second program uses the switch in the board. The LED lights up, as soon as the swicht-button is pressed. What the code does, is making all A registers inputs, except PA7. In the while loop the 3rd register (button) is read and moved 4 bits to the left, to PA7. If PA3 is high, then PA7 is high and the LED is on.

Go to top