On Dec 9, 2006, at 4:03 AM, Thomas Wagner wrote:

Hello at all,

Because I haven't found a driver for the MTS300 (TOS 2). I began to wrote my one, which produces good enough values for temperature and light, but the sound value (altough I can read it) is not so satisfying so I tried to set the gain value for the microphone (I2C). With he help of the Crossbow TinyOS 1 drivers and the Datasheet for AD5242, I thought that sending the 3 Bytes Adress (0x5A) , a 0 and the Value (0x40 for example) would be enough for doing this, so I wrote something like this:

configuration TestAppC {}
implementation {
 components TestC, MainC, MicaBusC;
 components new Atm128I2CMasterC();
 TestC.Boot -> MainC;
 TestC.Leds -> LedsC;
 TestC.SoundPower -> MicaBusC.PW3;
 TestC.SoundOutpt -> MicaBusC.PW6;
 TestC.Resource -> Atm128I2CMasterC;
 TestC.I2CPacket -> Atm128I2CMasterC;
}

and:

#include <I2C.h>

module TestC {
 uses {
   interface Boot;
   interface Leds;
     interface GeneralIO as SoundPower;
   interface GeneralIO as SoundOutpt;
     interface Resource;
   interface I2CPacket<TI2CBasicAddr>;
 }
}
implementation {

 char Buffer[2];

 event void Boot.booted() {
     //call SoundPower.makeOutput();
     //call SoundOutpt.makeOutput();
     //call SoundPower.set();
     //call SoundOutpt.clr();              call Resource.request();
 }
 event void Resource.granted() {
   Buffer[0] = 0x00;
   Buffer[1] = 0x40;
if (call I2CPacket.write(I2C_START | I2C_STOP, 0x5A, 2, &Buffer [0]) == SUCCESS) {
     call Leds.led1On();
   }
 }
async event void I2CPacket.readDone(error_t error, uint16_t addr, uint8_t length, uint8_t* data) {
   call Leds.led0On();

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

 }
}

The problem is, that the write operation seems to succeed (led1 turns on), but the event are not fired (and my new gain doesn't seem to have an effect)! I've tried several version (char, uint8_t for Buffer, several tries for the 4. parameter of write, swith Pins on and off), but none of these worked.

Could someone please tell me what I'm doing wrong?

Thanks in advance for your answers

Regards,
Thomas

PS: Does someone know how to get information about the battery voltage on micaz? (just reading ADC7 does not seem to do the trick)

Your usage of the I2CPacket interface looks right. Where are you configuring the IO pins and activating the I2C device? The code there has the operations commented out. If it's not on, then you might see it hang. I've found I2C devices to be really finicky; often, the fastest way to debug them us to go into Atm128I2CMasterPacketP.nc and figure out which state the operation is failing in.

I've attached a file for the I2C driver for an ADS7823 ADC device. Hopefully it will help.

Attachment: Ads7823P.nc
Description: Binary data


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

Reply via email to