Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of Impedance_Fast_Circuitry by
Diff: dma.cpp
- Revision:
- 35:df40c4566826
- Parent:
- 34:44cc9b76a507
- Child:
- 36:07d8a3143967
--- a/dma.cpp Sun Jan 25 02:45:58 2015 +0000 +++ b/dma.cpp Sun Jan 25 06:32:11 2015 +0000 @@ -14,7 +14,7 @@ * @adc_reads = the length of buffer and the number of reads the DMA completes * */ -void dma_init(uint16_t* buffer,int adc_reads) +void dma_init(uint16_t* buffer,int len) { // Enable clock for DMAMUX and DMA SIM_SCGC6 |= SIM_SCGC6_DMAMUX_MASK; @@ -41,12 +41,13 @@ DMA_TCD0_NBYTES_MLNO = 0x02; // Current major iteration count (a single iteration of 5 bytes) - DMA_TCD0_CITER_ELINKNO = DMA_CITER_ELINKNO_CITER(adc_reads); - DMA_TCD0_BITER_ELINKNO = DMA_BITER_ELINKNO_BITER(adc_reads); + DMA_TCD0_CITER_ELINKNO = DMA_CITER_ELINKNO_CITER(len); + DMA_TCD0_BITER_ELINKNO = DMA_BITER_ELINKNO_BITER(len); // Adjustment value used to restore the source and destiny address to the initial value + // After reading 'len' number of times, the DMA goes back to the beginning by subtracting len*2 from the address (going back to the address of 'buffer') DMA_TCD0_SLAST = 0x00; // Source address adjustment - DMA_TCD0_DLASTSGA = -0x10; // Destination address adjustment + DMA_TCD0_DLASTSGA = -(len*2); // Destination address adjustment // Setup control and status register DMA_TCD0_CSR = 0;