9. Embedded programming¶
This week I worked on defining my final project idea and started to getting used to the documentation process.
Introduction¶
This week, we were given two assignments, being a group assignment and an individual assignment. The group assignment for this week was to compare the performance and development workflows for other architectures. The individual assignment for this week was to read a microcontroller datasheet and to program our board to do something using as many different programming languages and environments as possible.
Individual Assignment - Data Sheet¶
This week I decided to start with the individual assignment because the group assignment would take a bit longer to coordinate due to everyone working from home (COVID-19). The first thing I did was I read the datasheet for my Tiny 412 processor that I used on my board and down below are a few things that I thought were important from the sheet that I got.
This first image shows the different types of AT tiny chips that are produced, and also how they are labeled. I thought that this was an interesting part to these processors as I did not realize that the numbers had significance.
The second image shows the block diagram of the tiny 412, and this was interesting to look at and to see all of the parts of the MCU. I never thought that so many parts and functions could be packed inside such as small package! I also thought that one interesting part of this diagram were the placements of SRAM, Flash, and EEPROM, and how that would have an effect on the perforance of the board.
The third image shows the pin outs, which are useful when programming the board, as we have to call them in the code.
The fourth image shows the AVR CPU architecture, which was interesting to see because we can see how the processor works and the order in which information is handeled.
The fifth image shows the explanation of bitwise operations. This was important because it explained things such as PORTA, PORT.DIR, PORT.DIRSET, PORT.DIRCLR, and VPORTA, which I will use in my C Code later on.
Arduino programming¶
After I read the datasheet, I was able to start programming my board. My plan was to use an Arduino to be able to program my 412 board, so I started off by looking at some videos to find a starting point. This is when I came across this video, which gave me a general idea of what I would need to have downloaded and have hardware-wise in order for me to be able to program my board. The first thing that I did was that I downloaded a file on Spence Konde’s GitHub that allowed my Arduino to be able to program to the updi on my board.
After I completed this, I plugged in my arduino, selected the COM port, and uploaded the code to my Arduino and I was set to go.
After I completed this, I opened the blink example code, and entered my pin information on there. After I did this, But after I did this, I ran into my first issue which was that I needed a 10uF capacitor between the reset and the ground because a reset is triggered every time I upload a sketch, but I did not have the part. After some thinking, I dug through my previous boards and I was able to find a 1uF capacitor soldered on one of my boards, so I got my soldering iron, and I took off the capacitor, and was able to solder the capacitor back onto two male to male pins, which looked like this
After I did this, I made sure that I had all of my libraries, which I checked in the board manager. I found out that I had to add a library called “megaTinycore” which I did, but involved me inserting this link into the preferences -> http://drazzy.com/package_drazzy.com_index.json
After I had everything I needed, I hooked everything up, got the code, and hit upload using programmer and my board blinked!
After I completed this task in Arduino, I decided that I would work with raw C code, and decided to start off by learning some basic C code in order for me to be able to create a similar blink program. After going back and refrencing the datasheet, I created my C code which is down below.
After doing this, I decided to do some work in Atmel Studio 7, which I used a little bit when creating our programmers, but this time I would have to get the code to upload from here. The first thing I did was that I created a new executable project. After that, I selected my board that I would program, which is the tiny 412. After I did that,I inserted my code, and made a few tweaks so that it would run on Atmel. Once I did this, I compiled the file using the compile button under build.
After I got that to work, I was able to start on the external tool, which would upload the code. I found two file locations which I needed being
C:\Users\Harri\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17\bin\avrdude.exe
C:\Users\Harri\AppData\Local\Arduino15\packages\megaTinyCore\hardware\megaavr\1.1.8\avrdude.conf
After I got those two locations, I inserted the avrdude.exe location into the command box. I then moved to the arguments box, in which I entered
-P COM5 # The port your jtag2updi is plugged in
-C (PATH) # The path of your avrdude.conf file
-c jtag2updi # The programmer you are using
-p t412 # The chip you are trying to program
-U flash:w:$(ProjectDir)Debug/$(TargetName).hex:i # Memory operation specification (Don't Change)
this will all be entered as one line, and should look like this.
-P com5 -C C:\Users\Harri\AppData\Local\Arduino15\packages\megaTinyCore\hardware\megaavr\1.1.8\avrdude.conf -c jtag2updi -p t412 -U flash:w:$(ProjectDir)Debug\$(TargetName).hex:i
After everything was complete, I uploaded my code by clicking the jtag2updi, and my board blinked once again!
Group Assignment¶
The group assignment for this week was to compare the performance and development workflows for different architectures. Although this is what it said on the assessment page, Mr. Neil said to compare families in the video for this week. The link to the group assignment can be found here.
Files¶
Here are my files from this week Files