Week 7. Embedded programming: Synchronous laser detector
Installing avr-libc etc
I used Homebrew to install avr-libc as described here. In particular, from Terminal I ran brew tap osx-cross/avr
then I ran sudo chmod 777 /usr/local/share/info
brew link gmp
brew link mpfr
brew link libmpc
to resolve an error message Error: Could not symlink share/info/gmp.info; /usr/local/share/info is not writable, then I ran brew install avr-libc
Before I found the Homebrew option, I struggled to follow the instructions here. I confirmed that I have GCC by running gcc -v but did not realize AVR-GCC is not included in GCC. I also confirmed I have GNU Binutils (Binary Utilities) by running ld -v
I often used the GND and VCC pads to align the 2x3 pin header between the ISP and the board to be programmed. Note that MOSI (master output, slave input) is between GND and VCC. I was a bit confused why the MOSI pin on Brian's FabISP board does not correspond to MISO (master input, slave output) on the board to be programmed, but the orientation is determined by matching GND or VCC.
In the Makefile I replaced avrisp2 with usbtiny with the FabISP or atmelice_isp with the Atmel-ICE programmer.
Note the programmer works even though it does not show in the list of devices in the /dev directory. Upon programming the board, the laser diode started to turn on and off! Additionally, the Python terminal program worked and indeed showed the absolute measurements on the phototransistor with the lights on and off, as well as the more discernible differential measurement below!
Some failure modes I encountered
- Board not powered. Seems the board needs to be powered in order to program it. I am not yet sure if this is true in general. When the board was not powered, I got the error message Initialization failed, rc=-1 Double check connections and try again, or use -F to override this check
- Wrong programmer in the Makefile. See note above.