Hi, Janos       Thanks a lot. I use an external pulldown resistor.        
Following your suggestion  I changed the line 96 in Atm128I2CMasterPacketP.nc 
to "call I2C.init(TRUE)". But  the problem still exists. In 
Atm128I2CMasterPacketP.nc after the first I2CPacket.write() starts, the state 
variable changes into I2C_STARTING. When this operation finishes,the state does 
not change. Then  the second  I2CPacket.write()  operation can not continue. 
Reasonably, it should send a command to change the state variable. In the 
I2C.commandComplet() function of Atm128I2CMasterPacketP.nc, there state 
variable is changed. Track the HplAtml128I2CBusP.nc, and find in  
I2C.commandComplet() function, AVR_ATOMIC_HANDLER(SIG_2WIRE_SERIAL) signals the 
I2C.commandComplet() event.I don´t know which event calls the 
I2C.commandComplet() function(in HplAtml128I2CBusP.nc file).                 
Jianxin Chen 

Date: Wed, 8 Oct 2008 13:15:45 -0500From: [EMAIL PROTECTED]: [EMAIL PROTECTED]; 
[EMAIL PROTECTED]: Re: [Tinyos-help] I2C communication in tinyos2.0
If you use an external pulldown resistor, you need to change line 96 in 
Atm128I2CMasterPacketP.nc to "call I2C.init(TRUE)". By default I2C init is 
called with FALSE, assuming no external pulldown.Let me know if it helps.Janos
2008/10/8 songangel <[EMAIL PROTECTED]>

Dear all,     In my system a compass is added to MICAz node by I2C 
communication mode in tinyos 2.0.     Now I want to obtain the compass output 
periodically.     The program follows, but I can not obtain the compass output. 
In the configuration file  {      ......   Compass.Resource  -> 
ATM128I2CMasterC.Resource;   Compass. I2CPacket -> ATM128I2CMasterC.I2CPacket;  
 } In the main fie we define module Compass{    ..... Interface Resource;  
Interface  I2CPacket<TI2CBasicAddr>}    In the Timer function we request the 
resource:    Timer.fire(){        Resource.request();        .....      } In 
the! resource granted function we read the compass output by I2C  as following  
  Resource.granted(){           if(call 
I2CPacket.write(I2C_START,C0,.....)==SUCCESS)                 {                 
    // delay(100);                      if(call 
I2CPacket.write(I2C_START,C1,.....)==SUCCESS)                        call 
I2CPacket.read(I2C_START,C1,.....);                   }       &! nbsp;    
Resource.release();   &nbsp ;   }     Even I add the delay(100), it still does 
not  work. When I track the program, and find the second ``call 
I2CPacket.write(I2C_START,C1,.....)`` is not successful. After careful analysis 
of the I2C driver, I found in the program Atm128I2CMasterPacketP.nc, when the 
I2CPacket.write begins, the variable " state" changes intoI2C_STARTING.  When 
this function call I2C.sendCommand() function and finishes, the variable state 
still is I2C_STARTING. Track  the I2C.sendCommand() in the HplAtm128I2CBusP 
file and found, there is only one operation TWCR=current.       It appear weird 
that there  is no event to change the state variabe in  
Atm128I2CMasterPacketP.nc. It is evident, after the writing operation is done, 
there should exist an operation to change the state. But I can not find  it.    
  Does anyone give me help?      Th! anks a lot!             Jianxin Chen       
 

"七件武器,七种完美" 立刻体验!_______________________________________________Tinyos-help 
mailing [EMAIL 
PROTECTED]://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

轻松把Hotmail下载到本地,试试 Windows Live Mail。 立即尝试! 
_________________________________________________________________
新年换新颜,快来妆扮自己的MSN给心仪的TA一个惊喜!
http://im.live.cn/emoticons/?ID=18
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to