Dear all,
I'm working on a simple application with two separated ez430 DK boards.
The idea is to sample and convert continuously an input signal and to send it, via RF, to a target board which transfers the received packet via the USB on a remote PC. Only the 8 LS bits are sent to reduce the transmitted bit rate, while sampling rate is set to 20KHz.
Hereafter you can find the code i wrote to handle the ADC conversion;
void ADC_Sampling_Setup (void)
{
//ADC10CTL0 = 0x2000 + Sample_16X + ADC_ON + REF_2_5V + REF_ON + ADC_IE;
ADC10CTL0 = Sample_4X + ADC_ON + ADC_IE; // 4+13 clcok cycles are needed for each sample
ADC10CTL1 = SHsource_ADC10SC | ADCclock_DIV3 | ADC_SMCLK; // conversion is enableb by ADC10SC_bit
ADC10AE0 = 0x00;
ADC10AE1 &= 0x0F;
}
void ADC_Single_CH (unsigned short CHANNEL, unsigned short *DATA)
{
ADC10CTL0 |= Multi_Conv_ON;
ADC10CTL1 |= CHANNEL | SINGLE_CH_MULTI_CONV;
ADC10AE0 = 0x01 << (CHANNEL >> 12);
while (ADC10CTL1 & ADC_BUSY);
ADC10DTC0 &= 0x02;
ADC10DTC0 |= TWO_BLOCK_TRANSF_MODE + CONT_TRANSF_MODE;
ADC10DTC1 = BLOCK_SIZE; // block is 100 samples wide
ADC10SA = (unsigned short)DATA;
ADC10CTL0 |= (ADC_EN_CONV + ADC_START_CONV);
__enable_interrupt();
}
while the following is the routine interrupt which is run everytime a block is filled:
__interrupt void ADC10_ISR(void)
{
LED_PxOUT |= GREEN_LED; //switch on the red led each time a new block is transmitted
if ((ADC10DTC0 & BLOCK_FILLED) == 0) // check if block 2 has been filled
RFSendAdcData(ADC_DATA + BLOCK_SIZE, BLOCK_SIZE);
else
RFSendAdcData(ADC_DATA, BLOCK_SIZE);
LED_PxOUT &= ~GREEN_LED; //switch on the red led each time a new block is transmitted
}
I tested separately the ADC conversion as well as the RF data transfer, and everything works correctly. Problems come when I try to do both things simultaneously. In this case, in fact, the CC2500 sends correctly only the first two blocks (coming from the ADC conversion); after that it just stops sending data. I tried to figure out what happens and what I've seen is that the GDO pin is not set anymore when the CC2500 state is changed to TX.
I hope to get some tips from you.
Gian Nicola