Thanks for your reply. I am using a recently updated TinyOS-2.x version from CVS and I think the hardware arbiters work fine so far.
I have managed to implement I2C communications between my ultrasound sensor and the MICAz mote and I did this by adding some delay after the I2C write and read functions to allow the respective signals to be sent on the I2C bus. Spent quite a lot of time tweaking the delay parameters and I am still unsure how to explain why this works, but it does. :)
regards,
Mingding
-----Original Message-----
From: Kevin Klues [mailto:[EMAIL PROTECTED]]
Sent: Wed 12/12/2007 3:42 AM
To: Han Mingding
Cc: [email protected]
Subject: Re: [Tinyos-help] interfacing ultrasonic sensor to MICAz over I2C bus
What version of tinyos are your using? There was a bug in the
arbiters from about mid august ujtil mid spetember, so if you checked
out from cvs during this time period, but never updated since, you may
have the bug still.
Kevin
On Dec 11, 2007 3:37 AM, Han Mingding <[EMAIL PROTECTED]> wrote:
>
>
>
> Hi all,
>
> I am facing some difficulties interfacing an SRF02 ultrasound sensor to
> MICAz using I2C bus in TinyOS-2.x. My program allows the MICAz mote to write
> to the bus but it is unable to read the measurements from the sensor. It
> seems the readDone() event is never triggered.
>
> I have attached the main code for reference. The delay function is to
> allow the mote application some time to write to the bus, and 0xE0 is the
> sensor's I2C address. Pls help.
>
>
> /*********************************************************************************************/
>
> event void I2CResource.granted() {
>
> if (state == 0){//send measure command
>
> bufferPtr->cmd=0x00; //real ranging mode in centimeters
> bufferPtr->data="">
> call I2CPacket.write(I2C_START, 0xE0, 2,
> (uint8_t*)bufferPtr);
> delay(150); //equivalent to 1ms
>
> call I2CPacket.write(I2C_STOP, 0xE0, 0,
> (uint8_t*)bufferPtr);
> delay(500);
>
> state = 1;
> }
> else if (state == 1){//send get_measurement command
>
> readPtr->cmd=0x00;
> readPtr->data="">
>
> delay (100000);//delay for more than 66ms to wait for ranging
>
> bufferPtr->cmd=0x02; //real ranging mode in centimeters
> call I2CPacket.write(I2C_START, 0xE0, 1,
> (uint8_t*)bufferPtr);
> delay(50);
>
> call I2CPacket.read(I2C_START, 0xE0, 2, (uint8_t*)readPtr);
> delay(250);
>
> call I2CPacket.read(I2C_ACK_END, 0xE0, 0,
> (uint8_t*)readPtr);
> delay(500);
>
> state = 0;
>
> }//end state
>
> call I2CResource.release();
> call I2CResource.request();
> }
>
>
> /*********************************************************************************************/
> _______________________________________________
> Tinyos-help mailing list
> [email protected]
> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
>
--
~Kevin
_______________________________________________ Tinyos-help mailing list [email protected] https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
