- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a DMA setup to capture 4095 8-bit samples from an ADC and then send it via UART to my PC. All of this is done in one procedure :
void pulseAndReg() { // uint16 PulseSampleNo = SAMPLES_IN_BUFFER; ADC_Mag_StartConvert(); pulseEndFlag = 0;
// transmit the pulse
WaveDelayProducer_setGlobalEnable(1);
CyDelayUs(PULSE_LENGTH_US);
WaveDelayProducer_setGlobalEnable(0);
// start collecting data
isr_PulseEnd_Enable();
CyDmaChEnable(DMA_1_Chan, 1);
// wait for end of collection
while(!pulseEndFlag)
{
//block until collection finished
}
isr_PulseEnd_Disable();
UART_PC_PutArray(samplesBuffer8, SAMPLES_IN_BUFFER);
CyDmaChDisable(DMA_1_Chan);
ADC_Mag_StopConvert();
}
Before the procedure runs a bunch of stuff is being initialized before main():
#define SAMPLES_IN_BUFFER (uint16)(0x0FFF)
#define PULSE_LENGTH_US 300u
/* Variable declarations for DMA_1 */
/* Move these variable declarations to the top of the function */
uint8 DMA_1_Chan;
uint8 DMA_1_TD[1];
/* DMA Configuration for DMA_1 */
#define DMA_1_BYTES_PER_BURST 1
#define DMA_1_REQUEST_PER_BURST 1
#define DMA_1_SRC_BASE (CYDEV_PERIPH_BASE)
#define DMA_1_DST_BASE (CYDEV_SRAM_BASE)
uint8 samplesBuffer8[SAMPLES_IN_BUFFER] = {0};
and in main():
ADC_Mag_Start();
UART_PC_Start();
DMA_1_Chan = DMA_1_DmaInitialize(DMA_1_BYTES_PER_BURST, DMA_1_REQUEST_PER_BURST,
HI16(DMA_1_SRC_BASE), HI16(DMA_1_DST_BASE));
DMA_1_TD[0] = CyDmaTdAllocate();
CyDmaTdSetConfiguration(DMA_1_TD[0], SAMPLES_IN_BUFFER, DMA_1_TD[0], DMA_1__TD_TERMOUT_EN | TD_INC_DST_ADR);
CyDmaTdSetAddress(DMA_1_TD[0], LO16((uint32)ADC_Mag_DEC_SAMP_PTR), LO16((uint32)samplesBuffer8));
CyDmaChSetInitialTd(DMA_1_Chan, DMA_1_TD[0]);
CyGlobalIntEnable; /* Uncomment this line to enable global interrupts. */
isr_PulseEnd_Start();
isr_PulseEnd_Disable();
My problem is, all that seems to be inhabitting the samplesBuffer8 after the procedure is run is a bunch of ones, nothing else. I've been trying to debug this problem for ages now and I can't seem to figure out the reason why the program behaves this way. Any ideas anyone?
- Labels:
-
PSoC 5LP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sanuuu,
it is always advisable to post a complete project showing the error, even when you do not want to show everything a reduced project will help us (me at least) using the IDE to follow up everything. I cannot compile your code-snippet and I cannot debug it, so please provide us with a complete project.To do so, use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I looked at your project, but the DMA setting seems to be ok, except ths I would use CY_DMA_DISABLE_TD as the next TD in CyDmaTdSetConfiguration().
So I would concentrate on ADC conversion. Did you test your ADC configuration before you connected the DMA?
Bob