2015-07-14 12:48 AM
2015-07-22 12:01 PM
clive, can you tell me how the dma is 24?... according to my knowledge, the buffer size is the dma size... if not correct can u tell me how its
volatile uint16_t Buffer[12];
..
DMA_InitStruct.DMA_BufferSize = (uint16_t)sizeof(Buffer); // sizeof returns a BYTE count for the array, ie 24
..
DMA_InitStruct.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord; // count is in units of 16-bit HalfWords
..
for (i = 0; i < 20; i++)
{
printf(''%d
'', Buffer[i]);
}
#define ELEMENTS 12
volatile uint16_t Buffer[ELEMENTS];
..
DMA_InitStruct.DMA_BufferSize = ELEMENTS;
..
DMA_InitStruct.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord; // Buffer[] is composed of 16-bit HalfWords
..
for (i = 0; i < ELEMENTS; i++)
{
printf(''%d
'', Buffer[i]);
}
2015-07-22 12:34 PM
Are you sure 3 cycles is enough time for the conversion? What is your sample and hold circuit? Too short a conversion time and you get mostly random results. Try it with a slow time first, and then shorten it until you get a good conversion time. The ADC section in the RM explains the setup requirements before sampling.
Jack Peacock2015-07-23 12:53 AM
thank you clive..ur explanation helps me to learn.
i would like to about fifo. i have '' enabled FIFO and the threshold is full '', so it means 4 * word(32 bit) for FIFo full according to manual. how FIFO works here?Could you give some explanation ?2015-07-23 05:18 AM
The FIFO reduces memory bus contention by buffering samples into the FIFO before writing them to memory in a burst. There's less contention with the CPU and other DMA controllers when performing a single bus transaction write of 4 sequential words instead of four transactions of one word. This is significant with large, high speed DMA transfers.
With one ADC each FIFO sample is 16 bit, so it only uses half the 32 bit FIFO word. The FIFO is 4 words long so you can buffer 4 samples. With both ADCs paired you convert two samples (ADC1 and ADC2) into a 32 bit word at the same time, making full use of the FIFO. The DMA has to be word aligned to match the space used in a FIFO word (i.e. align at full word boundary for paired ADC samples, half word for single ADC). The threshold is useful when manually triggering DMA with tight buffer boundaries. The early warning when DMA will over/under flow allows you to set up more data for the DMA controller on a manual basis. The FIFO can also pack and unpack different word sizes. This gets complicated with word alignment but is very useful for certain types of DMA such as large transfers over a serial port. Jack Peacock2015-07-24 12:06 AM
clive, i am not understanding why buffer size has to be 12 bytes, why not 24 bytes. what impack it can make if its 12 bytes and what hapepns if its 24 bytes?
2015-07-24 12:29 AM
DMA_BufferSize is *NOT* a byte count, it's a transfer count in UNITS of size described in the Memory and Peripheral DataSize (width) fields.
If you tell it to write over a larger memory space than the array covers will result in the DMA HARDWARE corrupting surrounding memory variables and structures, beyond the scope of the memory you want it touching.You understand why that would be a BAD THING? Right?2015-07-24 12:34 AM
In the code I pasted yesterday, I contrasted the way you described the array in three inconsistent ways (which I pointed out in a prior response), with the uniform way you might do it to avoid picking the wrong size at each opportunity.
2015-07-24 05:08 AM
i would like to know one more thing that,
1. time difference between two samples(12 bits, 3 cycles sampling time) = conversion time (15 cycles)+ 5 cycles (''ADC_TwoSamplingDelay_5Cycles'' )..
is that correct?..2. In adc configuration, whats the need of using ''
ADC_InitStructure.ADC_NbrOfConversion = 1; '' ?...
2015-07-24 05:43 AM
1) I think it's just 15 cycles of the ADC prescaled clock. To confirm you could do 1000 samples and toggle a GPIO, and measure the period on a scope.
2) You are building an enumerate list of channels that can be scanned. You have just ONE, and it doesn't need to be scanned. At each trigger event it scans and converts the listed channels. In continuous mode every set completes and it retriggers.