FABACADEMY 2019

This page covers my process through the fabacademy, illustrating my progress, discoveries, failures, reflexions and inspirations.

Week 09

Embedded Programming

Link to the class content

Assignment:

ATmega328p Data sheet

The first thing I did is understand what are the different terms used in the data sheet:

Memory: Exist different kinds of memory.

Peripherals: is everything else that is not the register instructions.

Registers: talk to the memory, the number of the bits is the word size. A processor with a bigger registers can do more work in one operation.

Data sheet

Pin configuration: Show the distribution of the pins and the orientation.

Pin Description:

Clocks

I/O ports: can be Inputs or outputs, internally we can turn on or pull up resistors. Has the next registers:

Comment:

I would learn more about how work the outputs in relationship with the micro-controller. I would like to know what happed if I turn on the internal clock and I add another external clock. I could affect the output result?

Programming language

A programming language is a formal language, which comprises a set of instructions that produce various kinds of output.

Arduino Software

It's a program with compilers that produce binary machine code for the target processor. The Arduino integrated development environment (IDE) is a cross-platform application (for Windows, macOS, Linux) that is written in the programming language Java.

Sketch

A sketch is a program written with the Arduino IDE and are saved on the development computer as text files with the file extension .ino.

Hacking Arduino Software to program a non Arduino circuit board

I did this in the week 07 check the link located above.

Blink Arduino Code

I did this in the week 07 check the link located above.

Button Arduino Code

I did this in the week 07 check the link located above.

C code

We choose to use C Programming language to program our boards.

Programming with this language was more complicated than programming with Arduino, but was a really good exercise to understand the process behind Arduino software.

Blink:

Slideshow 15: Click on the arrow to see the images!

avrdude -c usbtiny -p m328p
make -f blink.c.make
make -f blink.c.make program-usbtiny-fuses (ERROR 1)
make -f blink.c.make program-usbtiny-fuses
make -f blink.c.make program-usbyiny


Watch the video:

You can download the files:

Hello world:

You can download the files:

Fade

I try the fade example from Arduino to fade the LED from my board for that I had to check the arduino pinout in relationship with my microcontroller Atmega328p and verify the correspondent pin attached to my LED. My LED is located at the pin PB0 that correspond to the pin 8. I put the "int led = 8" and then I upload the code with the next configurations:

ALIEN PCB:

The LED doesn't fade just blink because the led has to be attached to a PWM pin so I search in the ATmega328p datasheet to know if the PB0 is a PWM pin but it doesn't so that was the problem.

You can download the files:

ARDUINO

After I can't fade the led with my AlienPCB I try to fade a LED with arduino. For that I change the "int led = 9" to "int led = 11" just to change something in the code booth of them are PWM pins. After that I upload the code with the next seethings:

This time the fade works very well. Also I found a Fade tutorial where they give a good explanation about the PWM. And this is how the code works: