|
Tone detector Interrupt on micaz
|
|
By FabienD, Section Blogs Thu Oct 13th, 2005 at 02:02:28 AM PST
|
Hello, I'm a student in Geneva Engineering school, and I must for my work use the tone detector. I tried tu use it with interrupt but it jsut don't work. I can use it by reading values buts it is really to slow. Can someone help me in realising tone detector interrupt for micaz Z.
the code I tested is :
The module MicDetectM
includes sensorboard;
module MicDetectM{
provides {
interface StdControl;
}
uses{
interface StdControl as MicControl;
interface Mic;
interface MicInterrupt;
interface ADC as MicADC;
interface Leds;
}
}
implementation {
command result_t StdControl.init () {
call Leds.init();
call MicControl.init();
call Mic.gainAdjust(255); // Set the gain of the microphone at his max.
call MicInterrupt.enable();
return SUCCESS;
}
command result_t StdControl.stop (){
call Leds.init(); // turn all Leds OFF
call MicControl.stop();
}
async event result_t MicInterrupt.toneDetected(){
call Leds.greenToggle();
return SUCCESS;
}
async event result_t MicADC.dataReady (uint16_t data){
return SUCCESS;
}
}
The related Configuration
includes sensorboardApp;
configuration MicDetect{}
implementation{
components Main, MicDetectM, LedsC,MicC;
Main.StdControl -> MicDetectM.StdControl;
MicDetectM.Leds -> LedsC;
MicDetectM.MicControl -> MicC.StdControl;
MicDetectM.Mic -> MicC.Mic;
MicDetectM.MicInterrupt -> MicC.MicInterrupt;
MicDetectM.MicADC -> MicC.MicADC;
}
I Have a mote that uses the buzzer so I should be able to dectect it every time the chirp is genereted. The event ToneDetected is only called once at the beginning. I also made another code that call Mic.readToneDetector() every time a timer is fired this one works.
|
|
|