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:
- 51:43143a3fc2d7
- Parent:
- 50:33524a27e08c
diff -r 33524a27e08c -r 43143a3fc2d7 dma.cpp
--- a/dma.cpp Sat Jan 31 19:46:00 2015 +0000
+++ b/dma.cpp Sat Jan 31 20:17:58 2015 +0000
@@ -8,9 +8,12 @@
uint16_t sample_array0[TOTAL_SAMPLES];
uint16_t sample_array1[TOTAL_SAMPLES];
uint16_t angle_array[TOTAL_SAMPLES];
-//DigitalIn AMT20_A(PTB18); // FTM2_QD_PHA, apparently the k64f has a quadrature decoder. look into this (page 264)
-//DigitalIn AMT20_B(PTB10); // FTM2_QD_PHB
+
+
+/* DMA0 and DMA1 are triggered by ADC0 and ADC1 (which are triggered
+ * by the PDB). However, DMA2 is triggered directly by the PDB. This
+ * is becuase DMA2 is reading FTM2, which cannot trigger the DMA. */
void dma_init()
{
// Enable clock for DMAMUX and DMA
@@ -22,12 +25,10 @@
DMAMUX_CHCFG0 |= DMAMUX_CHCFG_ENBL_MASK | DMAMUX_CHCFG_SOURCE(40); // ADC0
DMAMUX_CHCFG1 |= DMAMUX_CHCFG_ENBL_MASK | DMAMUX_CHCFG_SOURCE(41); // ADC1
DMAMUX_CHCFG2 |= DMAMUX_CHCFG_ENBL_MASK | DMAMUX_CHCFG_SOURCE(48); // Set trigger source to PDB (Don't set DMA Trig Enable because that is for the PIT)
- /* Source number Source module Source description
+ /* Source number Source module
40 ADC0
41 ADC1
- 30 FTM2 Channel 0
- 31 FTM2 Channel 1
- 48 PDB -
+ 48 PDB
*/
@@ -85,9 +86,17 @@
DMA_TCD0_CSR = 0;
DMA_TCD1_CSR = 0;
DMA_TCD2_CSR = 0;
-
-
- /*pc.printf("DMA_CR: %08x\r\n", DMA_CR);
+}
+
+void dma_reset() {
+ // Set memory address for destinations back to the beginning
+ dma_init();
+}
+
+
+
+
+/*pc.printf("DMA_CR: %08x\r\n", DMA_CR);
pc.printf("DMA_ES: %08x\r\n", DMA_ES);
pc.printf("DMA_ERQ: %08x\r\n", DMA_ERQ);
pc.printf("DMA_EEI: %08x\r\n", DMA_EEI);
@@ -101,10 +110,4 @@
pc.printf("DMA_CINT: %02x\r\n", DMA_CINT);
pc.printf("DMA_INT: %08x\r\n", DMA_INT);
pc.printf("DMA_ERR: %08x\r\n", DMA_ERR);
- pc.printf("DMA_HRS: %08x\r\n", DMA_HRS);*/
-}
-
-void dma_reset() {
- // Set memory address for destinations back to the beginning
- dma_init();
-}
+ pc.printf("DMA_HRS: %08x\r\n", DMA_HRS);*/
\ No newline at end of file
