H T Ma A
week 7

Embedded Programming

For this week's assignment, we should programme the board designed in week 5 to do something. As it was my very first time working with codes, I decided to keep it simple and have programmed the board's LED to blink.

Since in week 5 I had some difficulties programming the boards in a MAC -the first one to be a programmer, and the second to be ready to be coded - I had to go back to this step.

In week 5, many of us tried to programme ours boards in a MAC and were unsuccessful. This week, I thought I would start working on a Linux, but with the support from Brian we could find out what we were doing wrong that to programme them through a MAC. We have missed one of the steps that have to be done through terminal, which is >> brew install avrdude >>

In the following lines, I have placed some notes with all the steps, from the very beginning, we have done in order to help my confused self in the future as well as others who might need it.

To programme the Programmer:

- Install homebrew (Link at Brian's webpage)
- Install cross pack (Link at Brian's webpage)
- Download the folder “fts_firmware_bdm_v1" (Brian's webpage)
- In terminal enter >> brew install avrdude
- In terminal enter >> which avrdude
- Navigate through terminal to your folder “fts_firmware_bdm_v1"
- Plug the external programmer to your computer
- Connect the programmer to your board (check the correspondence of the pins - at the board layout and at the back of the external programmer)
- On finder, navigate to your folder “fts_firmware_bdm_v1" >> Open the makefile>> change the name of the programmer you are using and save the makefile (respective names for each external programmer available at the lab can be found at Brian's webpage)
- In terminal enter >>make (In case you have already run make, run make clean, and then make again)
- In terminal enter >> sudo make flash
- In terminal enter >> sudo make fuses
- In terminal enter >> sudo make rstdisbl

The board should be programmed! If it works you can see it at the MAC system report>> USBport as USBtinySPI

The last step is to turn the board into a programmer is to remove the soldered jump

To programme the Board

- connect ISP's from both boards in the right order using the rainbow cable (check the orientation by looking at your board layout)
- using the ftdi cable connect the board to a USBport
- in your computer create a new folder called echo
- Save both files: hello.ftdi.44.echo.c + hello.ftdi.44.echo.c.make at your new folder (they are located in the class website under the embedded programming week>> host communication)
- Rename the last file( hello.ftdi.44.echo.c.make) as makefile
- In terminal enter 'cd' , than drag the just created folder to terminal after typing cd
- Open the makefile for a check up
- In terminal enter >> make
- In terminal enter >> sudo make program-usbtiny
- In terminal enter >> sudo make program-usbtiny-fuses

You are done!!! The Board is programmed! To check if it programmed, in terminal enter >> screen /dev/cu.usbserial-FTFMJ8F5 115200
(after cheking to go back to terminal type << crtl A K Y>>)

Coding the board

To code the board, I have referred myself to a ready code from a student webpage, Gary Zhexi Zang, used last year for the same assignment.

- create a new folder called blink
- duplicate the makefile from the echo folder just created to programme the board and move it to the blink folder
- create a .c file named blink with the programming code taken from Gary's page (in order to do that, you can duplicate the 'file hello.ftdi.44.echo.c' used to programme your board, move it to the blink folder, open it, delete all information, paste the code from Gary's page) Here is the code used:

- Some editions might be needed in the code. Check if the port connected to your LED is the port indicated in the code (Do that by looking at your board layout, done in week 5)
- Add the information >> #define BLINK_DELAY_MS 100 >> as indicated bellow:

- In terminal enter >> run make
- In terminal enter >> sudo make program-usbtiny
- In terminal enter >> sudo make program-usbtiny-fuses

At this point, the board should be blinking :)