This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Need help with ADC and DMA for CC2511 (Reposting in this forum)



Hello,

I am using Wixel from pololu as a platform. I am using timer1 in DSM mode to initiate ADC conversion and subsequently use DMA to store the results into memory. I am using three channels for three analog inputs. I am following what the datasheet is recommending but it does not appear to work. I have tried the following:

1. Repeated Single DMA

In this mode, as per the datasheet, I have addressed the following:

configure or setup the parameters, load the DMA controller (DMA1CFG) 

For each analog input, (AIN0 for example), I am using the trigger as AIN0 (ADC interrupt 21)  for channel 2 DMA, AIN1 uses channel 3 etc.

Sample configuration:

dmaConfig._2.SRCADDRH = XDATA_SFR_ADDRESS(ADCH);
dmaConfig._2.SRCADDRL = XDATA_SFR_ADDRESS(ADCL);
dmaConfig._2.DESTADDRH = ((uint16)adcOutputX >> 8);
dmaConfig._2.DESTADDRL = (uint16)adcOutputX ;
//dmaConfig._2.LENL = sizeL;
//dmaConfig._2.VLEN_LENH = 0x1F & sizeH;
dmaConfig._2.LENL = 0b00000000;
dmaConfig._2.VLEN_LENH = 0b00000001;
dmaConfig._2.DC6 = 0b11010101; // Bit 4:0 Trigger on 21,

I arm the DMA when I enable DSM as follows

DMAARM = (DMAARM | (DMA_CHANNEL_2 | DMA_CHANNEL_3 | DMA_CHANNEL_4));
DMAIE = 1;

I do enable all the interrupts.

The data buffer size is 128 words. As per the data sheet, with this configuration, when I start ADC conversion, which is a sequence (AIN0, AIN1 and AIN2), for AIN0, Trigger 21 should initiate a DMA transfer and when the transfer count for this channel reaches 128, there should be an interrupt and DMA will be rearmed.

I dont think this is working since I get 260+ timer1 interrupts and there should be atleast two DMA interrupts to indicate that twice the configured count has reached. I see only one count for DMA interrupt for a specific channel. Secondly, you can see that I am hardcoding the LEN field as splitting the size into two different bytes did not work (as shown by the printf.. when I use 128, and print the variable, I see something else like 0x300) 

In the DMA interrupt subroutine, I only increment the counters. I have tried rearming the channel also.

2. I have also tried using single transfer which requres the DMA to be rearmed when the transfer count has reached. I did not see any change in behavior. I still see that DMA interrupt counter is only when I should have a minimum of 2.

Some more details: Timer1 is programmed to generate about 170 interrupts in a period of 100 msecs. So when I start ADC conversion in a sequence (3 analog ports), there is enough time for each ports data to be converted and stored in the buffer.

Would really appreciate any input. I really suspect that the LEN, even when hardcoded is not right.

Looking forward for a response.

Regards

Vinay

  • I will have someone from my team get back to you shortly.

    /TA
  • Thanks for your help. Really appreciate it. I did get a message from your team member. That was very helpful. I was doing what was suggested. But I think the problem is with the length. I say this because, whatever I did earlier did not work with the length set to 128 words. I tried single and repeated single. But when I changed the length to 64 words with single mode, I can confirm that I got an interrupt everytime the count reached 64 words. I went back to 128 words and I get 1 interrupt after 260 ADC conversion. This I suspect is because of splitting the length (128 -- 1 0000 0000). I can live with 64 for some time. But eventually I may need to change the buffersize. I am thinking any size less than 128 might work. Is there something special I need to do when addressing sizes 128 or more words?

    Thanks

    Vinay

  • Thanks for your help. Problem solved.

    Regards

    Vinay