The Transterpreter Project

Concurrency, everywhere.


Porting to the Tmote Sky, round 1

Porting to bare hardware is slightly more difficult than I thought it would be.

The Transterpreter recompiles to new targets with little or no effort; it's just not a big deal. The VM is written in a subset of ANSI C that ports well from one machine to another. However, running on bare hardware means that you must first initialize the hardware.

This has been my biggest battle with the Tmote Sky. I'm not particularly well versed at reading datasheets (PDF) for hardware boards, nor does everything in the MSP430 processor specification (PDF) make sense to me the first (or second, or sometimes the third) time through. I've spent a fair amount of time in the last few days just reading the lowest-level sources for TinyOS, which has taught me a great deal about how they initialize the MSP430 (and therefore, the Tmote Sky).

For example, it took some time to discover the LED initialization sequence:

#define INIT_LEDS()  P5DIR = 0x70 ; P5OUT = 0x70;

And, I'm not even sure about my setting of the P5OUT register. Certainly, those register settings ignore everything else on port 5.

The serial communications took longer; I have to admit, there's still some things going on that I don't fully understand, as my initial explorations in this area were almost the same. Granted, one bit might make a difference in this case:

#define INIT_SERIAL() \
  P3SEL |= 0xC0; \
  U1CTL = SWRST; U1CTL |= CHAR; U1CTL = SWRST; \
  U1CTL |= CHAR; U1TCTL &= ~(SSEL_0 | SSEL_1 | SSEL_2 | SSEL_3); \
  U1TCTL |= SSEL_ACLK;  U1BR0 = 0x03; U1BR1 = 0x00; \
  U1MCTL = 0x4A; ME2 &= ~USPIE1; \
  ME2 |= (UTXE1 | URXE1); U1CTL &= ~SWRST;

That code is heavily based on some of the hardware initialization code in TinyOS.

This is an important start, and not bad for three days of work. It's not as quick as I thought it would be... but it isn't terribly slow, either. Once I have the hardware initialization sequence done (the biggest pieces left are the flash and the radio), "porting" the Transterpreter is a piece of cake. That is, binding external channels to these interfaces isn't the hard part---it's just getting the mote to come to life with everything ready to go that is the trick!

(Of course, learning how to turn these devices on and off is going to be another challenge...)



Metadata

  • Posted: April 27, 2006
  • Author: Matthew Jadud
  • Comments: None
  • Tags: None