Although I was able to get some communication with the packet sniffer from SmartRF Studio 7, I couldn't pick up anything using our code to Tx while using the same SmartRF register settings.
This could be a separate question, but I think they're related so let's continue...
Now consider this fact: Our code with our hardware at both ends has very poor range and could be causing what I call a stutter (locks up for a second, then continues fine... about every 15 sec). Eliminating hardware issues, I loaded SmartRF on 2 computers and I can walk outside with my laptop with zero packet loss, and at 250K BR!
So I've got a feeling we're doing something wrong in our code. Does any of this sound familiar? Anything to check first? Any other code you'd like to see?
ALL RADIO CODE IS UNCHANGED FROM the TI SAMPLES. THIS IS NOT A PROPRIETARY PROTOCOL, so it should work, right?
Thanks,
21
TRANSMITTER CODE (mostly transmits)
// init...
//setup the watchdog timer to expire every 100 ms. Use this to drive data collection and
// transmit data. Enter low power state afterwards
// setup WDT timer and set LED to yellow. Set it to green after link status becomes active
WDTCTL = WDT_MDLY_32; //WDT_ADLY_16; // WDT_ADLY_1000;
SFRIE1 |= WDTIE; // Enable WDT interrupt
//int event_index = 0;
//__bis_SR_register(GIE );
while( true ) {
__bis_SR_register( LPM3_bits + GIE );
}
/*
// check if any interrupts needs servicing and service them
// __bis_SR_register( GIE );
for (event_index = 0; event_index < EVENT_COUNT; event_index++) {
if (radio->intrEvt[event_index].evt != (INT_EVENT_HANDLER)NULL) {
radio->intrEvt[event_index].evt((int)radio->intrEvt[event_index].evtArg);
radio->intrEvt[event_index].evt = (INT_EVENT_HANDLER)NULL;
}
}
}
WATCHDOG (Tx about every 32ms)
#pragma vector=WDT_VECTOR // Watchdog Timer interrupt service routine
__interrupt void watchdog_timer(void)
{
// Begin sampling and transmitting continuously
accel->sampleData();
radio->receiveOff();
radio->receiving = 0;
radio->transmit((unsigned char*)accel->getData(), sizeof(Accel::AccelData));
radio->transmitting = 1;
// save off the accelerometer data for toe analysis, or do the analysis here
//__bic_SR_register_on_exit(LPM3_bits);
RECEIVER CODE (mostly receives):
while( true ) {
// check if any interrupts needs servicing and service them
if (radio->pendingEvents) {
for (event_index = 0; event_index < EVENT_COUNT; event_index++) {
if (radio->intrEvt[event_index].evt != (INT_EVENT_HANDLER)NULL) {
radio->pendingEvents--;
radio->intrEvt[event_index].evt((int)radio->intrEvt[event_index].evtArg);
radio->intrEvt[event_index].evt = (INT_EVENT_HANDLER)NULL;
}
}
}
// Toggling the radio receive with a delay is necessary.
// 4000 is about the minimum value to for the receiver to settle
radio->receiveOff();
radio->receiveOn();
__delay_cycles(5000);
// read the fsr, curve, gain
if (++potSampleCount > 2) {
potSampleCount = 0;
ADC12CTL0 |= ADC12SC; // Start adc conversion - software trigger
__delay_cycles(100);
pot->potFsr = (0xFFF - ADC12MEM0)>>4; // Move A0 results, IFG is cleared
pot->potCurve = (ADC12MEM1)>>4; // Move A1 results, IFG is cleared
pot->potGain = (ADC12MEM2)>>4; // Move A2 results, IFG is cleared
if (pot->potFsr >= Util:: FootSwitchDelta) {
processFootSwitchEvent(0);
}
}
}