hello 
I am working on a project where I attached LM75 temperature sensor through to 
my 
telosb module through I2C interface and I write the following program to read 
it 
:
BlinkToRadioC.nc file:
#include <Timer.h>
#include <I2C.h>

module BlinkToRadioC {
  uses interface Boot;
  uses interface Leds;
  uses interface Timer<TMilli> as Timer0;
  uses interface I2CPacket<TI2CBasicAddr>;
  uses interface Resource; //I2C bus resource

}
implementation {

  uint16_t counter;
 uint8_t a[2];
//a[0] = 0x00;
//a[1] = 0x00;

  void setLeds(uint8_t val) {
    if (val & 0x04)
      call Leds.led0On();
    else 
      call Leds.led0Off();
    if (val & 0x02)
      call Leds.led1On();
    else
      call Leds.led1Off();
    if (val & 0x01)
      call Leds.led2On();
    else
      call Leds.led2Off();
  }

  event void Boot.booted() {
      call Timer0.startPeriodic(1000);  }

  
  event void Timer0.fired() {
    counter++;


            if(call Resource.request() == SUCCESS){
  }

}
// the begin of writing and reading from I2c
event void Resource.granted() {
      if (call I2CPacket.read(I2C_START | I2C_STOP, 0x48, 2, a) == SUCCESS)call 
Leds.led1Toggle(); //setLeds(a[0]);//call Leds.led1Toggle();
//call Resource.release();    
  }
  async event void I2CPacket.readDone(error_t error, uint16_t addr, uint8_t 
length, uint8_t* data) {
//       call Leds.led1On();

if((call Resource.release()) == SUCCESS) call  Leds.led0Toggle() ;
call  Leds.led2Toggle();

  }
 async event void I2CPacket.writeDone(error_t error, uint16_t addr, uint8_t 
length, uint8_t* data) {
   //call Leds.led2On();
  }
}

BlinkToRadioAppC.nc file:
#include <Timer.h>
#include "BlinkToRadio.h"

configuration BlinkToRadioAppC {
}
implementation {
  components MainC;
  components LedsC;
  components BlinkToRadioC as App;
  components new TimerMilliC() as Timer0;
   components new Msp430I2CC();

  App.Boot -> MainC;
  App.Leds -> LedsC;
  App.Timer0 -> Timer0;
  App.Resource -> Msp430I2CC;
  App.I2CPacket -> Msp430I2CC;
  
}

I notice that the read operation is successful for the first time only but then 
the read operation stops. I observed it as the led0,2 is on for the first 
reading but then never changes also led one get on for 1 sec then get off and 
stays off
 also I tried to read the value of the temperature from the a register and 
after 
converting it ,it gives me correct value (29.5) deg but when I changed the 
temperature these value doesnot changed untill I restarted the mote
What I shall do ?
Mohammed



      
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to