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