Embedded Programming

This weeks class of Fab Academy 2015 was about programing microcontrollers. It is a skill longstanding in my mind, and the opportunity is present. I am not a programmer, but have programmed and taught Arduino courses for more than 10 years. This week is a journey into the mystery behind the magic.

To quote Prof Niel Gershenfeld

This is a huge subject . It’s weeks, months and really years to come to master it.

My plan:

  • Day 1 - AVR
  • Day 2 - Blink
  • Day 3 - Alt Blink

My Fab Academy instructor Fiore Basile warned me about this lesson months before Fab Academy started. I’ve been reading Make: AVR Programming and I have to say that this is definitely a personal challenge. As of now I don’t have a working attiny44. What is on hand is the ATtiny datasheet.

Fiore just handed me the board and we already found a problem. Learning by doing it wrong never fails. I solder in the jumper to correct the missing connection to the oscilator. I was jusy about to flash when I accidently ripped up a trance and had to fix it as well.



Since 1999 the CLI has been my drug of choice, so the CrossPack Development Environment for Atmel’s AVR Microcontrollers was for me. There is a basic blink tutorial on the Crosspack page but it goes like this:

  1. 1. Create a new project: ‘avr-project helloWorld’
  2. 2. Edit the main.c file: ‘vim helloWorld/firmware/main.c’
  3. 3. Double Check everything is correct.
  4. li>
  5. 4. Move to the firmware folder ‘cd helloWorld/firmware/’
  6. 5. Make the make file ‘cd helloWorld/firmware/’
  7. 6. Make the make flash ‘make flash’
  8. 7. and send it ‘make fuse’

  10. ‘#include <avr/io.h>
  11. ’#include <util/delay.h>

’int main(void) { DDRD = 1 << 4; /* make the LED pin an output / for(;;){ char i; for(i = 0; i < 10; i++){ _delay_ms(30); / max is 262.14 ms / F_CPU in MHz / } PORTD ^= 1 << 4; / toggle the LED / } return 0; / never reached */ }

I misspelled one function and forgot the ; in another, but the error lines are identical to Arduino and I recovered quickly. The hard part was defining which ISP I was using. With my FabISP sitting in the Fab Lab Cascina I flashed with an Arduino here on hand. I uploaded the blink code and the led is blinking.



This is going to take a lot of time. I read the ‎www.atmel.com/Images/Atmel–2586-AVR–8-bit-Microcontroller-ATtiny25-ATtiny45-ATtiny85_Datasheet.pdf and have answered some very interesting questions I’ve had for a long time about arduinos. The Port B interface has a lot of power for doing things like reading all ports at once via a single line of code. I am really fascinated by the onboard Capacitive touch sensing and the idea that there is support for matrix sensing. I am sure the the timing libraries and the Interrupt handling are going to be useful. I never knew there were two kinds of interrupts.
All in all this is looking exciting.