Embedded programming

This week we had to fullfill two individual assignment and one group assignment. First we had to read the datasheet of a microcontroller. Then we had to program our board with as many different languages as possible.
At last we had to compare different development workflows for other architectures as group.

The datasheet


For my hello-world-board I used an ATmega328p. It's a 8-bit AVR Microcontroller created by Atmel:

Quick Specs
Operating voltage 2.7V to 5.5V
ISP Flash memory 32Kbytes
EEPROM memory 1Kbytes
SRAM memory 2Kbytes
Features 6 PWM channel / 10-bit ADC

I used this Datasheet for all the informations. It's a great way to get to know your microcontroller and to find informations before using it in a project.
In the datasheet you can find informations about the AVR Architecture as a block diagram, which can help you to understand, how this microprocesser works:

Fixing my hello-world-board (short version)


Due to our pcb-milling-machines malefunction in the electronics design week I had to recreate my hello-world-board, as it did not work.
You can find detailed information on what I had to do in the "Update Section" of my Week 6.
Here is a short version of my way to a working hello-world-board:

At first I had to mill a circuit board, as the pcb-mill didn't work the last time.
I then manually placed solder-paste onto every pad and the put every component on the board.
The I put the PCB into our PCB oven, where the solder-paste would liquify and the component would be soldered to the PCB
While in the oven the ATmega328p came lose and didn't attach to the board, so I had to do it manualy afterwards.
Somehow the ATmega got lose every time I tried to use the board.

As you can see I also had no connection between two part of my general ground, for which I soldered a cable from one ground to the other.
Because of that I tried to remove all of the old solder paste and add new one to the PCB, to get a clean solder connection.
While trying to remove the old solder-paste I riped off traces of my PCB -.-

I then milled a new PCB, three to be exact, because our pcb-milling-machine somehow milled to deep and removed my tracec completly

Maybe you can see the difference between my old PCB and the now one, which was milled to deep...
(Note: the Board on the right is the state after harvesting all of the old components for the new PCB^^)
After adjusting the machine and changing the trace width to 0.4mm I finaly got a good looking new PCB:

I then did the same as last time, aplied solder-paste to the PCB and added the components, put it in the PCB oven and recieved a nearly good looking PCB. Only the Pin header went missing while in the PCB oven, so I had to solder them afterwards.

Programming the Board


To connect my board to my pc I used a USB to UART adapter, which only needs four connectiones and is very easy to use.
Only thing I had to do was to install the right driver for the CP2102 Module for it to show up as COM-Port in my device manager.
You can find the needed driver here.

After having everything set up it was time to programm the first example. For that I used the classic Arduino IDE, as it has a lot of examples and features allready build in.
I wrote down a quick and easy blink example, where my onboard LED on Pin 13 is turned on and off with a delay of 1 second:

I then selected the board as "Arduino Duemilanove or Dieicimila", the processor as "ATmega328p" and the Port corresponding to the one I've plugged the USB to UARt module in:

After verifying the code it was uploaded. I was so happy after seeing the "Upload succsesfull" message and the LED turning on and off as it should!!

Other programing methods


As second programming mehtod / IDE I wanted to try out Platform IO in Visual studio Code. Visual Studio Code has been a long time my go to IDE, but I never moved away from the Arduino IDE when it comes to programming an AVR based microprocesser like the ATmega328P or the ATtiny85.
First I had to use the extantion manager in Visual Studio Code to install the Platform IO extension:

After installing I used the quick start guide HERE to get everything working.
I clicked on the little "house" symbol in the bottom left corner (1) and then clicked on new project (2):

Then I had to give the name a project and select the ATmega328p as processor:

You can find the main.cpp file in the source-folder:

For better comparison I used the same blink-example code, that I used for the Arduino IDE:

I then connected the programmer, in this case a USBasp, because my FABTinyISP was not at hand, and flashed the code onto my board:

Everything worked and the LED at pin 13 started blinking as expected!

Group Assignment


For our group assignment we had to compare the performance and development workflow for different microcontroller families. As I used the AtMega328p as microcontroller, we decided to test out the ESP8266 as comparison.
You can find the documenation of our testing and programming on the page of our groupmember lars HERE>.

Downloads:


Arduino Blink sketch
PlatformIO blink sketch