Week 8
Embedded Programming
The objective :
1.Read a microcontroller data sheet.
2.Program your board to do something, with as many different programming languages and programming environments as possible.
Tools :
|
Name |
Uses |
1 |
Hello world board |
Board already produced in week 6 |
2 |
Arduino |
Software |
3 |
Ebot |
Software for testing |
4 |
Ebot kit |
Testing and programming |
A. READING DATASHEET :
I never tried or even think about programming before I joined Fabacademy and the maximum action I have ever had with any device or machine is reading the user guied or how to start only. This is the first time ever I have read the data sheet of such subjects.
I read ATtiny24A/44A/84A Data sheet that FabAcademy suggested on the website. And to be honest i couldn't understood all of this huge amount of information ,but I did my best and try to grab as much as I can from this data sheet along with other references and select the most important information that I need to know in this stage.
•Definition : (Data sheet, wikipedia and other references)
Microcontroller is a very small electronic chip designed for embedded applications. It contains one or more CPUs (processor cores) along with programmable input/output peripherals and memory. The memory in a microcontroller divided into 3 types :
1.SRAM is the type of memory where data must be read and written to repeatedly. This is the data will change the different code being uploaded to the AVR microcontroller circuit. By default, this is the most common and used type of memory.
2.Flash memory is the memory that normally stores data that does not change. This is the program memory. It stores the part of the microcontroller program that is fixed and will always stay permanent.
3.Registers are small memory elements in microcontrollers with 8 bits capacity. Registers can be accessed quickly by the ALU (Arithmetic and Logic Unit) of microcontrollers
For Programming ATtiny 44,84 using six pins here is a very useful information that we need to know :
Short form |
Long form |
Function |
SCK |
Serial Clock |
Programming clock, generated by the In-System Programmer (Master) |
MOSI |
Master Out - Slave In |
Communication line from In-System Programmer (Master) to target AVR being programmed (Slave ) |
MISO |
Master In - Slave Out |
Communication line from target AVR (Slave) to In- System Programmer (Master) |
RST |
Reset |
To enable In-System Programming, the target AVR Reset must be kept active. To simplify this, the In-System Programmer should control the target AVR Reset |
GND |
Ground |
Common Ground |
B.1Programing (TEST)
As I mentioned previously I have know idea about programing or its softwares. Our local instructors advised me to start with EBOT before moving to arduino. Ebot is a Kuwaiti software prudueced by CBITS it is very simple tool for beginners in programing like me. Ebot is easy, funny, and powerful tool to implement electronic in robotics and coding its simplified the coding with a very nice interface.
As you see as in this image I generated the blinking code that I used in this assignment with ebot befor I moved to arduino.
Here is the youtube link for this test
B.2 Programing (implementation) :
In this assignment It supposed to use my hello board that I redesigned on week 6 but unfortunately my board has a short circuit. I tried to find out the causes behind this short ,but I Couldn't therefore I decided to redesign my hello board and enlarge its size to minimize the short circuit chance.
1.The new design of hello-wolrd board. (Download)
2A
2B
the privuse two images shows the First step of the programing which installing the attiny board support into arduino
3.A
3B.
3C.
3D.
the Above four images show the procedure that I follow to start programing the microcontroller. First, I select board type as ATtiny. Then I selected the Processor as ATtiny84, after that I selected the Clock as external 20 MHZ which is the Resonator that I used in my board. Then I selected "USBtinyISP" at Programer. And at the end Programmer the bootloader to the board
B.3 Programing (The code that I used) :
const int button = 2;
const int led = 3;
int buttonState = 0;
void setup() {
pinMode(led, OUTPUT);
pinMode(button, INPUT);
}
void loop() {
buttonState = digitalRead(button);
if (buttonState == HIGH) {
for(;;)
{
digitalWrite(ledPin, HIGH);
delay(1000);
digitalWrite(ledPin, LOW);
delay(1000);
}
} else {
digitalWrite(ledPin, LOW);
}
}
The followng are youtube links shows the completed assignment.