[Tinyos-help] Accessing particular digital I/O pins in Tmote Sky

Ankur Kamthe akamthe at ucmerced.edu
Tue Jan 30 18:51:40 PST 2007


Hi all,

I was trying to use the pins on the expansion connector for Tmote Sky
on a project. I started by writing a simple program that would toggle
one of the "Exclusive Digital I/O" pins but was not sure how to
address/indentity a particular pin in TOS. In the program, I set a
particular port for the ADC, set the pin as an output pin and toggle
it. Everytime my pin toggles, one of the LEDs also toggles. When I try
Port23 : Pin 3 of the 6-pin expansion connector toggles and for Port
26: pin 4 of the 6pin expansion connector toggles.

Could someone point me to any resource which explains the pin mapping
or explain this behavior? My aim is to toggle pin 7/10 on the 10 pin
expansion connector, which are dual purpose pins (primary: analog
input 2, secondary: exclusive digital i/o). I am pasting the program I
used to test the pins after this email.

TestAppC.nc: Top Level Configuration File
BlinkC.nc: Main Section which toggles the timer, leds and pins
HplUserButtonC.nc: Wiring for I/O pin

thanks,
ankur


1. Makefile
COMPONENT=TestAppC
include $(MAKERULES)

2. TestAppC.nc
configuration TestAppC
{
}
implementation
{
  components MainC, BlinkC, LedsC;
  components new TimerMilliC() as Timer0;
  components new TimerMilliC() as Timer1;
  components new TimerMilliC() as Timer2;

  BlinkC -> MainC.Boot;

  BlinkC.Timer0 -> Timer0;
  BlinkC.Timer1 -> Timer1;
  BlinkC.Timer2 -> Timer2;
  BlinkC.Leds -> LedsC;

  components HplUserButtonC;
	BlinkC.GeneralIO -> HplUserButtonC.GeneralIO;
}

3. BlinkC.nc
#include "Timer.h"

module BlinkC
{
	uses interface GeneralIO;
	
  uses interface Timer<TMilli> as Timer0;
  uses interface Timer<TMilli> as Timer1;
  uses interface Timer<TMilli> as Timer2;
  uses interface Leds;
  uses interface Boot;
}
implementation
{
	
  event void Boot.booted()
  {
    call GeneralIO.makeOutput();
    if(call GeneralIO.isOutput()){
    	call Timer2.startPeriodic( 5000 );
    }
    else{
    	call Timer1.startPeriodic( 1000 );
    	call Timer0.startPeriodic( 2000 );
    }
  }

  event void Timer0.fired()
  {
    dbg("BlinkC", "Timer 0 fired @ %s.\n", sim_time_string());
    call GeneralIO.toggle();
    call Leds.led0Toggle();

  }

  event void Timer1.fired()
  {
    dbg("BlinkC", "Timer 1 fired @ %s \n", sim_time_string());
    call GeneralIO.toggle();
    call Leds.led1Toggle();
  }

  event void Timer2.fired()
  {
    dbg("BlinkC", "Timer 2 fired @ %s.\n", sim_time_string());
    call GeneralIO.toggle();
    call Leds.led2Toggle();
  }
}

4. HplUserButtonC.nc
configuration HplUserButtonC {
  provides interface GeneralIO;
}
implementation {

  components HplMsp430GeneralIOC as GeneralIOC;

  components new Msp430GpioC() as TogglePinC;
  TogglePinC -> GeneralIOC.Port23;
  GeneralIO = TogglePinC;

}


More information about the Tinyos-help mailing list