Skip to main content
Visitor II
November 9, 2006
Question

Example of DMA and SSP

  • November 9, 2006
  • 12 replies
  • 7199 views
Posted on November 09, 2006 at 02:10

Example of DMA and SSP

    This topic has been closed for replies.

    12 replies

    md1Author
    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 09:31

    Hi,

    Does anyone have a working example of how to a transfer data from memory to SSP using burst mode?

    Marty.

    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 09:31

    Hi MD,

    Please find here attached an STR9 project shows how to make a DMA transfer between SSP0 and memory.

    This example aims to send an “SSP0_Buffer_Tx� buffer from memory to SSP0 data register and then to “SSP0_Buffer_Rx� buffer.

    If you want to verify the status of the transfer you can see the content of the “SSP0_Buffer_Rx� buffer through the watch tool and make a comparison with the source buffer.

    Regards.

    Eris.

    md1Author
    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 09:31

    Hi Eris,

    Thanks for that, works a treat. It seems the mistake I was making was calling the DMA_ChannelSRCIncConfig function after DMA_Init.

    Does this example take advantage of the burst mode?

    Also, does your code contain a slight error in the ''DMA_SyncConfig(SSP_DMA_Transmit, ENABLE);'' function? According to the softlib manual parameter 1 should be DMA_SSP0_TX_Mask? i.e

    DMA_SyncConfig(DMA_SSP0_TX_Mask, ENABLE);

    Thanks again eris...

    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 09:31

    Hi MD,

    Yes, because we can take advantages of burst mode when the transmit /receive FIFO is enabled, in this case all we have to-do is to specify the burst size in the DMA structure.

    Concerning the DMA_SyncConfig (DMA_SSP0_TX_Mask, ENABLE) you have right.

    Reagrds

    Eris.

    md1Author
    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 09:31

    Hi Eris,

    I have another DMA question, and wondered if you could help?

    The last DMA sample you sent worked great, but now I need to do something slightly different.

    The scenario above is transfering from memory to the DMA.

    Now I need to transfer memory from the a peripheral (SSP1) to memory, but keep SSP1 in master mode.

    Example: I need to transfer 512 bytes (1 sector) from an MMC card to STR9 memory.

    So as I understand it, a single DMA request is issued when the receive FIFO contains at least 1 character. A burst request will be issued when the FIFO contains 4 or more characters.

    I assume then I will have to trigger the transfer by sending data. I am trying to do this by sending 8 bytes manually. (Need to send dummy data by using another DMA channel in future..)

    Here is my code:

    // Setup STR9 SSP1 for MMC card.

    SSP_DeInit(SSP1);

    SSP_StructInit(&g_ssp);

    g_ssp.SSP_FrameFormat = SSP_FrameFormat_Motorola;

    g_ssp.SSP_Mode = SSP_Mode_Master;

    g_ssp.SSP_CPOL = SSP_CPOL_Low;

    g_ssp.SSP_CPHA = SSP_CPHA_1Edge;

    g_ssp.SSP_DataSize = SSP_DataSize_8b;

    g_ssp.SSP_SlaveOutput = SSP_SlaveOutput_Disable;

    g_ssp.SSP_ClockRate = 0xB;

    g_ssp.SSP_ClockPrescaler = 12;

    SSP_Init(SSP1, &g_ssp);

    SSP_DMACmd(SSP1, SSP_DMA_Receive, ENABLE);

    SSP_Cmd(SSP1, ENABLE); // Enable the SSP0 peripheral

    DMA_SyncConfig(DMA_SSP1_RX_Mask, ENABLE);

    DMA_ITConfig(MMC_DMA_CHANNEL, ENABLE);

    DMA_ITMaskConfig(MMC_DMA_CHANNEL, DMA_ITMask_ITC, ENABLE);

    DMA_StructInit(&g_dma);

    g_dma.DMA_Channel_LLstItm = 0;

    g_dma.DMA_Channel_SrcAdd = (u32)&SSP1->DR; g_dma.DMA_Channel_DesAdd=0;

    g_dma.DMA_Channel_SrcWidth= DMA_SrcWidth_Byte; g_dma.DMA_Channel_DesWidth= DMA_DesWidth_Byte; g_dma.DMA_Channel_FlowCntrl=DMA_FlowCntrl2_DMA; g_dma.DMA_Channel_TrsfSize = 0;

    g_dma.DMA_Channel_Src = DMA_SRC_SSP1_RX;

    g_dma.DMA_Channel_DesAdd=(u32)buffer;

    g_dma.DMA_Channel_TrsfSize = 512;

    DMA_ChannelSRCIncConfig (MMC_DMA_CHANNEL, DISABLE);

    DMA_ChannelDESIncConfig (MMC_DMA_CHANNEL, ENABLE);

    DMA_Init(MMC_DMA_CHANNEL, &g_dma); DMA_ChannelCmd(MMC_DMA_CHANNEL, ENABLE);

    Any ideas appreciated..

    Martin.

    md1Author
    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 09:31

    OK...

    Sorry, the code I posted works fine. It's just that it needs 512 bytes before a terminal count is issued, and I need to send this data out myself. So to do this job, it looks like I need 2 DMA channels. 1 for receiving the data, and 1 for sending out.

    Cheers,

    Martin.

    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 09:31

    Hi MD,

    I am going to read/write data from/to SD/MMC using 91x_lib through ssp0. Could you please give me a guide how to do that, say writing a sector data into SD/MMC and reading it back.

    Thank you.

    Yuantu

    md1Author
    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 09:31

    Hi Yuantu,

    In my application, I have used the EFSL filesystem drivers, and implemented SPI drivers using the STR9 libs. I have attached the relevant code.

    I am aware I need to re-submit this under the terms of the GNU and I will as sooon as poss.

    The GPIO setup is in another file, but if you want that as well then let me know and I will post.

    Martin.

    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 09:31

    Hi Martin,

    Your code is useful and give me a start point. I will download FESL to see what is inside. I am using IAR KickStart Kit for ARM91x and wonder whether the SD/MMC hardware of the board is working. I set P57 as output but it never goes low even if I call GPIO_WriteBit(GPIO5, GPIO_Pin_7, Bit_RESET) again and again.

    I am sure you are very welcome to publish your code under the term of GNU into this community.

    Thank you very much.

    Yuantu

    Visitor II
    May 17, 2011
    Posted on May 17, 2011 at 09:31

    Hi Martin,

    Could you please send me main.c. I have problems how to read/write SD in the main function. I am using SSP0 and have no interrupt.

    Thank you.

    Yuantu