cancel
Showing results for 
Search instead for 
Did you mean: 

I2S DMA

kjepsen9
Associate II
Posted on March 06, 2009 at 15:26

I2S DMA

1 REPLY 1
kjepsen9
Associate II
Posted on May 17, 2011 at 13:05

Hello,

I have been strugling on getting DMA to I2S on SPI3 to work...

I can't get it to work in the primer2 or in the keil simulator, i am not sure how the simualtor shows DMA transfers, or if it is not capable of that.

here is my code, can anyone see some errors?

Code:

DMA_InitTypeDef DMA_InitStructure;

I2S_InitTypeDef I2S_InitStructure;

u16 kj[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16};

RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE);

RCC_APB1PeriphClockCmd( RCC_APB1Periph_SPI3 , ENABLE);

I2S_Cmd(SPI3, DISABLE);

I2S_InitStructure.I2S_Standard = I2S_Standard_MSB;

I2S_InitStructure.I2S_DataFormat = I2S_DataFormat_16b;

I2S_InitStructure.I2S_MCLKOutput = I2S_MCLKOutput_Disable;

I2S_InitStructure.I2S_AudioFreq = I2S_AudioFreq_44k;

I2S_InitStructure.I2S_CPOL = I2S_CPOL_Low;

I2S_InitStructure.I2S_Mode = I2S_Mode_MasterTx;

I2S_Init(SPI3, &I2S_InitStructure);

SPI_I2S_DMACmd(SPI3, SPI_I2S_DMAReq_Tx, ENABLE);

I2S_Cmd(SPI3, ENABLE);

/* DMA1 Channel7 configuration ----------------------------------------------*/

DMA_DeInit(DMA1_Channel7);

DMA_InitStructure.DMA_PeripheralBaseAddr = (u32)&SPI3->DR;//0x40003c0c; // SPI3 Data register

DMA_InitStructure.DMA_MemoryBaseAddr = (u32)&kj;

DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST;

DMA_InitStructure.DMA_BufferSize = 15;

DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;

DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;

DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord; // WORD??

DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;

DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;

DMA_InitStructure.DMA_Priority = DMA_Priority_High;

DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;

DMA_Init(DMA1_Channel7, &DMA_InitStructure);

DMA_ITConfig(DMA1_Channel7, DMA_IT_TC|DMA_IT_HT, ENABLE);

DMA_Cmd(DMA1_Channel7, ENABLE);

Br Kasper

(pst. I will possible post this on the STM32Circle forum as well)