Other Parts Discussed in Thread: C2000WARE
Hello,
from my point of view there is a bug on C2000Ware_4_01_00_00\training\device\f2838x\module10_direct_memory_access example, related to the PingPong buffer
if you look the DMA code, at the InitDMA function only the first buffer is set:
// Configure the destination and source address.
DMA_configAddresses(DMA_CH1_BASE,
(const void *)AdcBufRaw,
(const void *)(ADCARESULT_BASE + ADC_O_RESULT0));
However, later in the interrupt, the first time it enters (PingPongState =0), the interrupt sets again the same pointer(AdcBufRaw). So the buffer is receiving nothing (or rubbish), since it is copying AdcBufRawPtr = AdcBufRaw + ADC_BUF_LEN;.
if (PingPongState == 0) {
// Set DMA address to start at ping buffer.
DMA_configAddresses(DMA_CH1_BASE,
(const void *)AdcBufRaw,
(const void *)(ADCARESULT_BASE + ADC_O_RESULT0));
// Fill AdcBuf with contents of the pong buffer.
AdcBufRawPtr = AdcBufRaw + ADC_BUF_LEN;
for (i = 0; i < ADC_BUF_LEN; i++) {
*(AdcBufPtr++) = *(AdcBufRawPtr++);
}
} else {
// Set DMA address to start at pong buffer.
DMA_configAddresses(DMA_CH1_BASE,
(const void *)(AdcBufRaw + ADC_BUF_LEN),
(const void *)(ADCARESULT_BASE + ADC_O_RESULT0));
// Fill AdcBuf with contents on the ping buffer.
AdcBufRawPtr = AdcBufRaw;
for (i = 0; i < ADC_BUF_LEN; i++) {
*(AdcBufPtr++) = *(AdcBufRawPtr++);
}
}
// Toggle PingPongState.
PingPongState ^= 1;
Pingpong then is 1, so a copy of an empty buffer is again done (copying AdcBufRawPtr = AdcBufRaw;).
So I assume the fisrt two buffers at initialization are lost, right?
On the other hand, when are the DMA_configAddresses changes have effect on the dest address of the DMA?
I mean, I am assuming, they are the dest for the NEXT buffer, but one has already started, right? (Or is it for the current first sample?). Do you have a diagram on this?
Best Regards