Hello, my name is David Pello and I'm from Asturias, North Spain.

I work at LABoral arts and industrial creation centre as the manager of the production centre and labs, and will be the one in charge of the Asturias FabLAB (opening soon).

My idea for my final project is the design, construction and programming of an open source platform for high altitude balloon tracking, including structure (support, thermal isolation, etc), and electronics (MCU, radio transmission, gps, sensors, etc).

Classes > Embedded programming

For this class I wanted to use the hello world board as an output of some data coming from the serial port. Thinking on it's output devices (led and serial), I thought of using the LED to blink the morse code of the character coming from the serial port.

First, in order to test the board, I wrote a simple program in ASM (using the AVRA assembler), that turns on the LED when you press the button. The code is available at the electronics design documentation.

Then I started writing code for my exercise. At the begginning I was using serial code from the hello.bus example and it worked fine, but I wanted to have a RX buffer and to have a function to check if there is data waiting at the serial port (like you can do with hardware uart). So I rewrote my library to use input interrupts. So when the state of the RX pin changes, an interrupt raises, and then I can check for the start bit, read the input byte, and store it in the buffer. Then a serial_available() function just has to check for bytes stored in the buffer to see if we have something ready to read. The size of the buffer can be adjusted by a define.

Then for the morse code, there's a simple lookup table that translates dots and dashes to bytes. The idea is simple, if the LSB of that number is 1, dash, if it's 0 dot, then divide the number by two and repeat until we got integer 1 and stop. For the spacing and timing, standard morse code convention is used, speed is in words per minute (WPM), so length of a dot is 1200/WPM, lenght of a dash is 3*dot, space between symbols is equal to one dot, space between letters is equal to three dots and between words is equal to seven dots.

Files:

  • main.c
  • uart_ints.c
  • morse.c
  • uart_ints.h
  • morse.h
  • Makefile

    FabISP

    Back