HomeAbout
##week7: embedded programmning
####Objective
Then, read the data sheet for your microcontroller and program your board to do something.
I was previously struggling to have my chip read for bootloading. As a result, I decided to redo the PCB design (twice) and ended up with testing the LED-Button functions on SAMD11C.
####Metrics
**A. Designing part**
* Base design: USB-D11C-serial using ATSAMD11C14
* Software: Eagle in Fusion 360 (electronics design)
**B. Milling part**
* Milling machine: Roland MonoFab SRM-20
* Endmills: 1/64 endmill for cutting the copper, 1/32 endmill for cutting out the PCB
* Material: Single-sided copper board
* Software: mod
**C. Coding part**
* Software: Arduino IDE (embedded programming)
####Protocols and results
**A. Design part**
1. Pick up a basic design, onto which I put an LED and a button. I chose "hello.D11C.serial.5V.1.1" from [here](http://academy.cba.mit.edu/classes/embedded_programming/D11C/hello.D11C.serial.5V.1.1 "test").
The one I did two week ago did not work, so I had to redo the schematic design.
2. Draw a skematic design on Eagle. This time, I made the board as simple as possible; for example, I did not make the wider copper layer for heat decipation or use the 5V-3V regulator with two extra capacitors, or use pullup resistor. I basically followed the simplest path i.e. putting LED and resistor in between one pin of D11C and GND, and a button in between another pin of D11C and GND.
3. Complete the routing on PCB, using zero-ohm bridges where necessary.
4. Export the trace design and the outer design. I did not know there was a critical mistake at this point...
**B. Milling part**
1. Use the above-mentioned sketches.
2. Pick up a copper board.
3. Put the copper board onto the milling machine. Now that I am becoming used to this process, I decided to use a smaller copper board to minimize waste.
4. Mill the copper layer of the circuit (trace with 1/64 endmill and line with 1/32 endmill).
7. Cut out the PCB.
**C. Stuffing part**
1. After milling, first cut the unneccesary copper foils with knife.
2. solder the components one by one.
**D. Bootloading part aka where I struggled the most**
1. I used the bootloader for D11C, but the PC never seemed to be reading my chip.
There were two mistakes:
* I was initially using a wrong regulator with wrong direction; after several failed attempts to bootload this chip, I realized the component was wrong (thanks Nathan for figuring it out). I changed it to the right 3.3V regulator (1mA one).
* I thought it should work after putting a smaller one. Instead, it melted with smoke! I could not figure out at this point, but when I finally gave up and decided to make a new board design and mill it, I realized that there was small area where the 1/64 endmill could not cut, therefore shortcutting the circuit. I cut this part apart by knife and voila, it worked.
**E. Coding part**
1. I used Arduino. Initially I could not install the board definition with the link `https://raw.githubusercontent.com/qbolsee/ArduinoCore-fab-sam/master/json/package_Fab_SAM_index.json`, but after several more attempts on Tuesday, it worked. (Thanks for the fix!)
2. There were a few more errors (port was not read, or it took forever to update the chip, etc.). Rob suggested that I uninstall and reinstall the IDE. After going over the same procedure written on MTM, it finally worked!
3. For the programming part, I made use of the basic design from "File" command of the IDE. I checked the mapping of the pins, and accordingly chose the port on IDE using `const int` rather than hard-code the port number every time.