Skip to content

Commit

Permalink
WIP: dma runs but is pass through is distorted
Browse files Browse the repository at this point in the history
* sanity checked most constants
* fixed incorrect NDSIZE
* pulled constant DMA registers out of descriptor
  • Loading branch information
ngwese committed Feb 1, 2016
1 parent 3b4da21 commit 7cd798a
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 20 deletions.
2 changes: 1 addition & 1 deletion dsp-block-test/audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* to switch buffers and perform deinterleaving.
* otherwise, copy and deinterleave in the ISR
*/
#define DMA_DEINTERLEAVE_PINGPONG 0
#define DMA_DEINTERLEAVE_PINGPONG 1

//! channel count
#define CHANNELS 4
Expand Down
44 changes: 30 additions & 14 deletions dsp-block-test/dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@
#include "dma.h"

#if DMA_DEINTERLEAVE_PINGPONG
// use descriptor mode to perform pingpong and deinterleave
// use large descriptor mode to perform pingpong and deinterleave

typedef struct {
void *next;
void *start;
short config;
short x_count;
short x_mod;
short y_count;
short y_mod;
void *next; // NDPL, NDPH
void *start; // SAL, SAH
/*
short config; // DMACFG
short x_count; // XCNT
short x_mod; // XMOD
short y_count; // YCNT
short y_mod; // YMOD
*/
} dma_desc_t;

// for deinterleaving, inner loop over number of channels
Expand All @@ -27,15 +29,16 @@ typedef struct {
// each outer-loop increment, jump back to the next frame in the first channel
#define Y_MOD (((1 - CHANNELS) * BLOCKSIZE + 1) * SAMPLESIZE)

#define DMA_FLOW_DESC 0x7700
// large descriptor list, first 4 registers only (NDPL, NDPH, SAL, SAH)
#define DMA_FLOW_DESC 0x7400
// NB: need interrupt on both TX and RX to ensure correct process order
#define DMA_CONFIG ( WDSIZE_32 | DMA_FLOW_DESC | DI_EN | DMA2D )
#define DMA_CONFIG ( DMA_FLOW_DESC | WDSIZE_32 | DI_EN | DMA2D )

dma_desc_t descRx1 = { NULL, inputChannels1, WNR | DMA_CONFIG, X_COUNT, X_MOD, Y_COUNT, Y_MOD };
dma_desc_t descRx0 = { &descRx1, inputChannels0, WNR | DMA_CONFIG, X_COUNT, X_MOD, Y_COUNT, Y_MOD };
dma_desc_t descRx1 = { NULL, inputChannels1 }; //, DMA_CONFIG | WNR, X_COUNT, X_MOD, Y_COUNT, Y_MOD };
dma_desc_t descRx0 = { &descRx1, inputChannels0 }; //, DMA_CONFIG | WNR, X_COUNT, X_MOD, Y_COUNT, Y_MOD };

dma_desc_t descTx1 = { NULL, outputChannels1, DMA_CONFIG, X_COUNT, X_MOD, Y_COUNT, Y_MOD };
dma_desc_t descTx0 = { &descTx1, outputChannels0, DMA_CONFIG, X_COUNT, X_MOD, Y_COUNT, Y_MOD };
dma_desc_t descTx1 = { NULL, outputChannels1 }; //, DMA_CONFIG, X_COUNT, X_MOD, Y_COUNT, Y_MOD };
dma_desc_t descTx0 = { &descTx1, outputChannels0 }; //, DMA_CONFIG, X_COUNT, X_MOD, Y_COUNT, Y_MOD };


void init_dma(void) {
Expand All @@ -49,8 +52,21 @@ void init_dma(void) {
descRx1.next = &descRx0;
descTx1.next = &descTx0;

*pDMA1_X_COUNT = X_COUNT;
*pDMA1_X_MODIFY = X_MOD;
*pDMA1_Y_COUNT = Y_COUNT;
*pDMA1_Y_MODIFY = Y_MOD;
*pDMA1_NEXT_DESC_PTR = &descRx0;
//*pDMA1_START_ADDR = descRx0.start;
*pDMA1_CONFIG = DMA_CONFIG | WNR;

*pDMA2_X_COUNT = X_COUNT;
*pDMA2_X_MODIFY = X_MOD;
*pDMA2_Y_COUNT = Y_COUNT;
*pDMA2_Y_MODIFY = Y_MOD;
*pDMA2_NEXT_DESC_PTR = &descTx0;
//*pDMA2_START_ADDR = descTx0.start;
*pDMA2_CONFIG = DMA_CONFIG;
}

#else // 1d, autobuffer mode (no de-interleave, no pingpong
Expand Down
Binary file modified dsp-block-test/dsp-block-test
Binary file not shown.
7 changes: 3 additions & 4 deletions dsp-block-test/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ void init_codec(void) {
void enable_dma_sport0(void) {
*pDMA2_CONFIG = (*pDMA2_CONFIG | DMAEN);
*pDMA1_CONFIG = (*pDMA1_CONFIG | DMAEN);
*pSPORT0_TCR1 = (*pSPORT0_TCR1 | TSPEN);
*pSPORT0_RCR1 = (*pSPORT0_RCR1 | RSPEN);
*pSPORT0_TCR1 = (*pSPORT0_TCR1 | TSPEN);
*pSPORT0_RCR1 = (*pSPORT0_RCR1 | RSPEN);
}


Expand All @@ -93,11 +93,10 @@ int main(void) {
init_interrupts();
init_dma();


module_init();

enable_dma_sport0();

// reset the codec
init_codec();

Expand Down
2 changes: 1 addition & 1 deletion dsp-block-test/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ void module_process_block(buffer_t *inChannels, buffer_t *outChannels,
}
}

osc_process_block(outChannels, numChannels, numFrames);
//osc_process_block(outChannels, numChannels, numFrames);
}

0 comments on commit 7cd798a

Please sign in to comment.