9. Embedded programming¶
Assignments for the Week:¶
Group Assignment:
Use the test equipment in your lab to observe the operation of a microcontroller circuit board. You can view our results of this week’s group work here.
For this week’s group work, Barbara Morrow and I worked with the multimeter on the ATtiny412 boards we made previously in the lab.
Individual Assignment:
Redraw an echo hello-world board. Add (at least) a button and LED (with a current-limiting resistor).
Check the design rules, make it and test that it can communicate
Extra credit: Simulate its operation
Programming the Button Board¶
In week 7 we redrew a board designed by our electronics instructor, Adam Harris. During that week, I was also able to get the LED to blink using my SAMD programmer.
This week, I focused on programming the button on my Button ATtiny412. During this process, I discovered that my SAMD updi programmer had stopped working for some reason. See below for the troubleshooting on this issue. So, I tried to use an Arduino to program the 412 to complete this assignment. You can find the file for this board in the Week 7 files.
Issues with the SAMD11C¶
At some point after using my SAMD udpi programmer to program my button board, it had stopped working. I absolutely could not figure out why. Our school’s spring break was also during this week, so it would be a almost a full 3 weeks before we were able to work with Adam Harris again.
Our lab ran out of 3.3 converters so I had to wait to stuff another board. Once they came in, I grabbed enough components the second half of spring break week to work on the new boards at home. Unfortunately, even these boards did not work. I couldn’t even get the bootloader on them. At this point I was confident in my soldering skills, especially on a board that I received from a pcb house. So I decided to wait to meet with Dr. Harris to find out what was going on.
In school the next day, we found out that one of our students, Aaron Logan, was having the same problem I was, but his original board never worked. Aaron also created two new boards once the new components came in and came across the same issue. I was even more confident now that this issue wasn’t something we were necessarily doing on our end.
Once I was able to meet with Dr. Harris, I explained to him what had happened. The board was working fine up until about a week ago and then every time I would plug it in, the ports on my computer would disappear. While trying to troubleshoot on my own, I read that this is a common problem in Arduino and even discovered (purely by accident) that if you unplug the programmer, plug in an Arduino Uno and then remove the Uno, the COM ports will show up again. You can also pull up your device manager and watch this happen.
However, with Dr. Harris, even the device manager wouldn’t register the SAMD. Luckily, he had his own boards with him and we used his free-DAP board to reprogram mine. It worked and I mentioned to him that was never the problem. I could load the bootloader and updi code to it. It’s when I tried to use it to program my 412 where it started to have issues.
Going back and forth between boards, and with still nothing working, Dr. Harris decided to pull out the multimeter and check our connections. He showed us how to meaure for the voltage across the components. Interestingly, my new boards were only pulling a little over 2 volts, instead of closer to the 3.3 we would have expected. Aaron’s boards, one of which wouldn’t even turn on, only pulled in 1 volt. After working one last time on my board again, as he handed it back to me, I dropped it because it was so hot! We didn’t realize the boards were heating up at the regulator since Aaron’s never turned on.
Immediately, Aaron and I both let him know that we had used the new regulators the lab ordered. So we pulled the datasheet from the manufaturer. The link was for the same components our lab and Dr. Harris’ lab had ordered before. What no one checked, or noticed until we pulled it up, was that the pins on the regulators had been changed by the manufaturer! Because of this, the regulators would not be able to work correctly in the current board design.
Dr. Harris had me pull off the new regulator from my last board so he could use a method to bypass the switch. Using this method for this board still didn’t work, and he believes it was because with the wrong regulator on the board we had probably already messed up the chip with the wrong voltage. I learned earlier that when programming the SAMD, you need to use 3.3 volts, but once programmed you can toggle the switch to 5 volts.
With all of this knowledge, he suggested that since at one point my original board was working and I documented that, I could use the board from the pcb house through the rest of my project. I did stuff and program it, so I would be ok. I had already programmed this board to be a free-DAP, so we reprogrammed it to be a updi one again so I could continue to use it to program other chips.
There was a lot going on this evening, but I was most impressed with Dr. Harris’ ability to walk us through the troubleshooting. I might not have understood all of what he was saying, but I could follow along in his reasoning and I learned valuable lessons in using the multimeter to troubleshoot my boards in the future!
Continuing in 2023¶
As a continuing student for this cycle, I needed to go back and rework a few of the weeks I didn’t complete. Embedded programming was one of them. It was a crazy week during the time last year and with all of the issues we had with the regulators and waiting for components, things got away from me early on! Because of going back to previous weeks to finish them up, there is a lot of overlap between what I worked on in 2023 for this week and week 15 - Embedded Networking!
So, to continue the embedded programming for this week, I began by reviewing the datasheet for the XIAO RP2040 microchip. At 646 pages, it was quite lengthy, but I knew I had certain parts I needed to look for because we had already done so much work last year reading datasheets every time we used a new chip.
Chapter 1 provided great detail on the parts of the chip, but I found useful information for me starting on page 467 for I2C Protocols, which I will need during Embedded Networking week! Chaper 5 was also very useful as it defines the pin types and then goes into detail listing each one in the pin list.
I also pulled a pinout from the internet that shows the the pins I can connect to.
Armed with my pinouts, I was able to use what I learned previously to find the information needed to set up my board and get it ready to use. This website was a big help in getting me started with the XIAO. In the beginning, I couldn’t get the computer to recognize my board. After working through their tutorial, I learned it was because I needed to use the BOOT button to have it cleared and recognized by the computer.
Once I had that pressed and plugged in, I could release it. And finally it showed up in my Finder as RP1-RP2. I continued following the workflow to add libraries and .json files as we learned to do previously when we used new chips in Arduino IDE. Once I had everything set, I used Arduino and uploaded a basic blink code. According to the tutorial, pin 25 is where the built-in LED is, so I made the appropriate changes in the code and uploaded it. It worked!
After this point, I also wanted to make sure I could use it to do something else. I was really excited that the board also has an RGB LED built into it. I decided to give that one a try. I used the tutorial again, and remembered we will need to add another library. I searched for the Adafruit_Neopixel one and added it as instructed.
I then added the code provided and it worked!
In order to complete this week, I actually needed to create the new XIAO board everyone was using. Dr. Taylor had provided files of a board based off of Adrian Torres’ FabXIAO board. I helped mill a batch of these boards to review my electronics production week. Once I had a board, I grabbed the compnents and stuffed it. This was all more of a review, after the numerous board I’ve created over the last year of Fab!
Click the link for the file below to download all of the files I used in this week’s assignments. Files