Hello all, I'm using the interface TimerJifyAsync.nc to sample one of
the ADC pins at 3KHz.
I have made a copy of the configuration file TimerJiffyAsyncC and
changed the timer to TimerB5( I have also checked with all other free
timers A2,B0,B2and B6).All though the application is getting compiled
and loading onto the mote successfuly. the event
timerJiffiyAsync.fired doesnt seem to be getting fired.
PS. I have checked the return value of call Timerjiffyasync.start().
It is retuning SUCCESS
but the event is not getting fired.
Im posting my code also. I would be great ful if somebody can have a look at it
****************** Configuration file************************
includes MyADC;
configuration Sampling {
}
implementation {
components Main,SamplingM,TimerJiffyAsyncNewC,LedsC,ADCC,FramerM,UART,TimerC;
Main.StdControl->SamplingM;
Main.StdControl -> ADCC;
Main.StdControl->TimerJiffyAsyncNewC;
Main.StdControl->TimerC;
SamplingM.UARTControl -> FramerM;
SamplingM.UARTSend -> FramerM;
SamplingM.TimerJiffyAsync->TimerJiffyAsyncNewC;
SamplingM.ADC -> ADCC.ADC[TOS_MYADC_PORT];
SamplingM.ADCControl -> ADCC;
SamplingM.Leds -> LedsC;
SamplingM.Timer->TimerC.Timer[unique("Timer")];
FramerM.ByteControl -> UART;
FramerM.ByteComm -> UART;
}
******************module***********************
module SamplingM{
provides interface StdControl;
uses {
interface Leds;
interface TimerJiffyAsync;
interface ADC;
interface ADCControl;
interface Timer;
interface StdControl as UARTControl;
interface BareSendMsg as UARTSend;
}
}
implementation{
#define TimeIncrement 333
/* one jiffy = 1000000/32768 = 30.5us apprx. So to achive a 3KHz
sampling the timer event shud
tick at every 1000000/3000 = 333 us. now 333/30.5 = 11 jiffies apprx.*/
uint32_t sampleTime=11;
/* inorder to collect 4096 samples at 3000 samples/sec, the
measurement shud be taken for a duration of
4096/3000 = 1.36 secs (1360 millisecs)*/
uint32_t samplingDuration = 1360;
norace uint16_t Time = 0;//this is the x-axis of the time domain, the
adc values will be the y-axis
norace uint16_t adc;
enum {
UART_QUEUE_LEN = 12,
PAY_LOAD_LEN = 16,
};
TOS_MsgPtr uartMsgPtr;
uint16_t payloadbuf[PAY_LOAD_LEN];
uint16_t payload[PAY_LOAD_LEN];
uint8_t payloadcount=0;
result_t result;
void failBlink() {
#ifdef TOSBASE_BLINK_ON_FAIL
call Leds.yellowToggle();
#endif
}
task void UARTSendTask(){
if (call UARTSend.send(uartMsgPtr) ==SUCCESS) {
call Leds.greenToggle();
} else {
failBlink();
post UARTSendTask();
}
}
task void DataStoreTask(){
int i,j;
if(payloadcount>PAY_LOAD_LEN){
for(i=0;i<PAY_LOAD_LEN;i++)
payload[i] = payloadbuf[i];
for(j=0;i<PAY_LOAD_LEN;j++){
uartMsgPtr->data[j*2+1] = payload[i]>>8;
uartMsgPtr->data[j*2] = payload[i];
}
post UARTSendTask();
payloadcount=0;
atomic payloadbuf[payloadcount++]=Time;
atomic payloadbuf[payloadcount++]=adc;
}else{
atomic payloadbuf[payloadcount++]=Time;
atomic payloadbuf[payloadcount++]=adc;
}
}
void dropBlink() {
#ifdef TOSBASE_BLINK_ON_DROP
call Leds.yellowToggle();
#endif
}
command result_t StdControl.init(){
call Leds.init();
call ADCControl.init();
call ADCControl.bindPort(TOS_MYADC_PORT,
TOSH_ACTUAL_MYADC_PORT);
call UARTControl.init();
return SUCCESS;
}
command result_t StdControl.start(){
call ADCControl.setSamplingRate(TOS_ADCSample30us);
call UARTControl.start();
call TimerJiffyAsync.setOneShot(sampleTime);
call Timer.start(TIMER_ONE_SHOT,samplingDuration);
return SUCCESS;
}
command result_t StdControl.stop(){
call UARTControl.stop();
call Timer.stop();
call TimerJiffyAsync.stop();
return SUCCESS;
}
async event result_t TimerJiffyAsync.fired(){
//call Leds.redOn();
call ADC.getData();
return SUCCESS;
}
event result_t Timer.fired(){
//call TimerJiffyAsync.stop();
return SUCCESS;
}
async event result_t ADC.dataReady(uint16_t data){
adc = data;
atomic Time += TimeIncrement;
call Leds.redOn();
post DataStoreTask();
call TimerJiffyAsync.setOneShot(sampleTime);
return SUCCESS;
}
event result_t UARTSend.sendDone(TOS_MsgPtr msg, result_t success) {
if (!success) {
failBlink();
}
return SUCCESS;
}
}
_______________________________________________
Tinyos-help mailing list
[email protected]
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help