cancel
Showing results for 
Search instead for 
Did you mean: 

DMA on two chan SSP0 and SSP1

jnalasco2
Associate
Posted on January 23, 2008 at 15:09

DMA on two chan SSP0 and SSP1

1 REPLY 1
jnalasco2
Associate
Posted on May 17, 2011 at 09:49

I need to use two DMA channels on the STR912. I am trying to become familiar with the part by programming SSP0 to output data using DMA while SSP1 receives data using DMA.

I can not get the program to function unless I configure SSP1 (the slave in this case) for DMA flow control as: ''DMA_FlowCntrl_Perip2''. I would like to configure SSP1 as ''DMA_FlowCntrl2_DMA''. This would presumably halt the channel after all the data is transferred. Does anyone know if this is an allowable configuration for the DMA controller? I’ve enclosed the code if you would be so kind as to review it.

/****Enable SSP DMA request******/

SSP_DMACmd(SSP1, SSP_DMA_Receive, ENABLE);

SSP_Cmd(SSP1, ENABLE);

SSP_DMACmd(SSP0, SSP_DMA_Transmit, ENABLE);

SSP_Cmd(SSP0, ENABLE);

/*****DMA configuration***********/

DMA_DeInit();

DMA_SyncConfig(DMA_SSP1_RX_Mask, ENABLE);

DMA_StructInit(&DMA_InitStruct);

/*No linked lists used*/

DMA_InitStruct.DMA_Channel_LLstItm=0;

/*Source address*/

DMA_InitStruct.DMA_Channel_SrcAdd=(u32)((&SSP1->DR));

/*Destination address*/

DMA_InitStruct.DMA_Channel_DesAdd=(u32)(&SSP1_Buffer_Rx[0]);

/*Source width of one byte*/

DMA_InitStruct.DMA_Channel_SrcWidth= DMA_SrcWidth_Byte;

/*Destination width of one byte*/

DMA_InitStruct.DMA_Channel_DesWidth= DMA_DesWidth_Byte;

/*The flow controller is: Transfer type = Peripheral-to-memory, flow controller:Pherip */

DMA_InitStruct.DMA_Channel_FlowCntrl = DMA_FlowCntrl2_DMA; //DMA_FlowCntrl_Perip2

DMA_InitStruct.DMA_Channel_Src = DMA_SRC_SSP1_RX;

/*Transfer size of 4bytes*/

DMA_InitStruct.DMA_Channel_SrcBstSize = 32;

/*We increment the source not the destination*/

DMA_ChannelDESIncConfig (DMA_Channel0, ENABLE);

DMA_Init(DMA_Channel0,&DMA_InitStruct);

DMA_ChannelCmd (DMA_Channel0,ENABLE);

DMA_StructInit(&DMA_InitStruct);

/*No linked lists used*/

DMA_InitStruct.DMA_Channel_LLstItm=0;

/*Source address*/

DMA_InitStruct.DMA_Channel_SrcAdd=(u32)(&SSP0_Buffer_Tx[0]);

/*Destination address*/

DMA_InitStruct.DMA_Channel_DesAdd=(u32)((&SSP0->DR));

/*Source width of one byte*/

DMA_InitStruct.DMA_Channel_SrcWidth= DMA_SrcWidth_Byte;

/*Destination width of one byte*/

DMA_InitStruct.DMA_Channel_DesWidth= DMA_DesWidth_Byte;

/*The flow controller is the DMAC*/

DMA_InitStruct.DMA_Channel_FlowCntrl= DMA_FlowCntrl1_DMA;

DMA_InitStruct.DMA_Channel_Des = DMA_DES_SSP0_TX;

/*Transfer size of 32 bytes*/

DMA_InitStruct.DMA_Channel_TrsfSize = 32;

/*We increment the source not the destination*/

DMA_ChannelSRCIncConfig (DMA_Channel1, ENABLE);

DMA_Init(DMA_Channel1,&DMA_InitStruct);

DMA_ChannelCmd (DMA_Channel1,ENABLE);

/***********Master to slave transfer procedure**************/

DMA_Cmd(ENABLE);/* Send data to SSP0 using DMA capability instead of CPU*/

GPIO_WriteBit(GPIO3, GPIO_Pin_0, Bit_RESET);

while(!(DMA_GetChannelActiveStatus(DMA_Channel0)));

GPIO_WriteBit(GPIO3, GPIO_Pin_0, Bit_SET);

/* Check the received data with the send ones */

/* TransferStatus1 = PASSED, if the data transmitted from SSP0 and

received by SSP1 are the same */

/* TransferStatus1 = FAILED, if the data transmitted from SSP0 and

received by SSP1 are different */

TransferStatus1 = Buffercmp(SSP0_Buffer_Tx, SSP1_Buffer_Rx, 32);

while(1);

}