• Join
  • Sign In with my.TI Login
Texas Instruments
  • Products
  • Applications
  • Tools & Software
  • Support & Community
  • Sample & Buy
  • About TI
Sample & Purchase Cart Sample & Purchase Cart
  • Search
  • Advanced
TI E2E™ Community
  • Support Forums
  • Blogs
  • Groups
  • Videos
  • 简体中文
  • More ...
TI Home » TI E2E Community » Support Forums » Microcontrollers » Stellaris® ARM® Microcontrollers » Stellaris® ARM® LM3S Microcontrollers Forum » Some questions about uDMA and I2S
Share
Stellaris® ARM® Microcontrollers
  • Forum
Options
  • Subscribe via RSS
Helpful Stellaris® LM4F Series Links
  • LM4F Series
  • Stellaris PinMux Utility
  • Stellaris® LM4F120 LaunchPad
  • LM4F MCU Applications
  • LM4F MCU Video
  • ARM Cortex-M4F Whitepaper
  • Stellaris MCU Brochure
  • LM4F232 Eval Kit
  • Some questions about uDMA and I2S

    Some questions about uDMA and I2S

    This question is not answered
    Andre Marianovich
    Posted by Andre Marianovich
    on May 09 2012 07:53 AM
    Intellectual975 points
    main.c

    Hi

    I've some comprehension questions for using the uDMA with the I2S. I have set the uDMA to serve the I2SRx channel in ping-pong mode. I set the fifo level of the I2SRx and the arbitration level of the uDMA to 4, so with a datasize of 24 bits per sample (the data were in two's complement) in mono mode of the I2S, I will get two samples every time the uDMA reads the fifo.

    Might this be efficient enough or should I raise the trigger level?

    In the case, my code will work right, the uDMA releases an I2S interrupt and the I2S int handler occurs. In this handler I'll check if the uDMA has done all the transfers and switch the ping-pong buffers. The buffers are two static signed long arrays. The size is 16 so far. I set the uDMA size and the buffer destination increment to 32 bit so I expect every 24 bit I2S sample will assign one array entry.

    What will the uDMA do when buffer1 will be filled again. Will it start filling the array by the first adress again and overwrite the previous samples? In this case it wouldn't be necessary to make the buffers bigger than the number of transfered sample, wouldn't it? Then it would make more sense to have more little arrays and build a ring buffer?

    I attach my code I wrote. So far it's just hardware configuration but if someone has a little time it would be very nice to take a look at if and tell me if there could be something wrong.


    Thanks for your reply

    EDIT: I use the LM3S9B92 Kit with the code composer studio

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    All Replies
    • Craig Giglio94760
      Posted by Craig Giglio94760
      on May 09 2012 18:47 PM
      Intellectual860 points

      Hello Andre,

      In your code you have the alternate buffer set the same as the primary buffer.  Typically you would allocate two separate buffers (it looks as though you have them already defined, but it may be a typo).  When the first one fills up the DMA transfers to the alternate control block.  At this point the second buffer begins to fill.  While this second buffer fills you can be moving the data from buffer 1 to whatever handling process you have.  Once the secondary transfer is complete then it will go back to buffer1. 

      As far as the DMA sizing goes you can retrieve up to 8 mono samples from the FIFO so if you set the level to 4 as you mention you would get 4 mono samples. Four samples is a good mid-point.  As far as the system timing goes, the interrupt is generated upon completion of the DMA transfer not the FIFO level setting.  In your case the transfer size is 16 bytes which means you get an interrupt after 16 samples.  You can increase the DMA transfer size (increase the buffer sze) to increase the time between services to the DMA buffers.  Overall timing is going to be dependent on what processing and throughput you require.

      Hope this helps.

      Regards,

      Craig

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Andre Marianovich
      Posted by Andre Marianovich
      on May 10 2012 12:23 PM
      Intellectual975 points

      Hi Craig,

      thank you for your reply. If I understand you correctly, then the first buffer will be filled until it is full and only then the control structur switch to the alternate and then the second buffer will be filled? And I get an interrupt, after any of the buffers were full, in my case after 16 samples because of the buffer size of 16?

      I changed the part of my code where I switch the buffers. Is this code better now?



      static signed long ulBuffer1[4][BUFFER_SIZE];
      static signed long ulBuffer2[4][BUFFER_SIZE];
      
      static signed long ul_Buf1Index = 0;
      static signed long ul_Buf2Index = 0;
      
      
      //#################################################################################################
      
      void I2SIntHandler(void)
      {
          unsigned long ulStatus;
          unsigned long ulMode;
      
          // Interruptstatus abfragen
          ulStatus = ROM_I2SIntStatus(I2S0_BASE,1);
      
          //Interruptquelle löschen, damit der Handler am Ende nicht erneut aufgerufen wird
          ROM_I2SIntClear(I2S0_BASE, ulStatus);
      
          // Status des uDMA I2S Kanals abfragen, primäre Kontrollstruktur
          ulMode = ROM_uDMAChannelModeGet(UDMA_CHANNEL_I2S0RX | UDMA_PRI_SELECT);
      
          // Wenn der uDMA den Transfer abgeschlossen hat, stoppt er automatisch
          if(ulMode == UDMA_MODE_STOP)
          {
          	/*
          	 * Konfiguriert die Übertragungsparamter für den nächsten Transfer des I2SRx Kanals für den uDMA
          	 * Primäre Kontrollstruktur (Ping Pong Modus, Buffer1), Datenquelle ist der I2SRx FIFO
          	 */
          	ROM_uDMAChannelTransferSet(UDMA_CHANNEL_I2S0RX | UDMA_PRI_SELECT,
          							UDMA_MODE_PINGPONG, (void*) I2S_SOURCE,
          							ulBuffer1[ul_Buf1Index], sizeof(ulBuffer1[ul_Buf1Index]));
      
          	if(ul_Buf1Index >=3)
          	{
          		ul_Buf1Index = 0;
          	}
          	else
          	{
          		ul_Buf1Index++;
          	}
          }
      
      
          // Status des uDMA I2S Kanals abfragen, primäre Kontrollstruktur
          ulMode = ROM_uDMAChannelModeGet(UDMA_CHANNEL_I2S0RX | UDMA_ALT_SELECT);
      
          // Wenn der uDMA den Transfer abgeschlossen hat, stoppt er automatisch
          if(ulMode == UDMA_MODE_STOP)
          {
          	/*
          	 * Konfiguriert die Übertragungsparamter für den nächsten Transfer des I2SRx Kanals für den uDMA
          	 * Primäre Kontrollstruktur (Ping Pong Modus, Buffer1), Datenquelle ist der I2SRx FIFO
          	 */
          	ROM_uDMAChannelTransferSet(UDMA_CHANNEL_I2S0RX | UDMA_ALT_SELECT,
          							UDMA_MODE_PINGPONG, (void*) I2S_SOURCE,
          							ulBuffer2[ul_Buf2Index], sizeof(ulBuffer2[ul_Buf2Index]));
      
          	if(ul_Buf2Index >=3)
          	{
          		ul_Buf2Index = 0;
          	}
          	else
          	{
          		ul_Buf2Index++;
          	}
          }
      }
      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Andre Marianovich
      Posted by Andre Marianovich
      on May 10 2012 12:47 PM
      Intellectual975 points

      One additional question:

      The I2S reads the incoming datastream beginning with the MSB one SCK cycle after the word select edge. How is the positioning in the FIFO and in the buffer? Were they filled from left to right respectively from the MSB 24 bits down to the LSB? In that case I have to right shift every buffer entry 8 positions, didn't I?

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Craig Giglio94760
      Posted by Craig Giglio94760
      on May 11 2012 07:44 AM
      Intellectual860 points

      Hello Andre,

      Going back to your first post I believe you have a good understanding of the DMA operation now.  Back to your code, in the original initialization for the DMA you have buffer 1 also used as the alternate and it should be changed ot the buffer 2.

      As far as your second post goes all data in the FIFO is stored MSB aligned.  Check out "Table 16-8. I2S Receive FIFO Interface" for more information on the data alignement.

      Hope this helps.

      Regarrs,

      Craog

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Andre Marianovich
      Posted by Andre Marianovich
      on May 12 2012 08:45 AM
      Intellectual975 points
      main.c

      Hello Craig

      thank you for your help. Maybe you could help me once again. The attached file contains the latest version of my program. Unfortunately, it ends up in the FaultISR() Handler. At this point I don't exactly know the reason, but I think it's something with the uDMA or my I2S Handler. I would be very nice if you could take a look at my code.

      Regard

      André

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Andre Marianovich
      Posted by Andre Marianovich
      on May 12 2012 10:52 AM
      Intellectual975 points

      I made some tests that show the I2SIntHandler will be reached. But after that line

      ulStatus = ROM_I2SIntStatus(I2S0_BASE , 1)

      the error occurs.

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Andre Marianovich
      Posted by Andre Marianovich
      on May 13 2012 06:55 AM
      Intellectual975 points

      If I use I2SIntStatus(I2S0_BASE , 1) instead of the the ROM_ function, I don't get an error. But it seems that the I2SIntHandler would be reached only one time and not anymore.

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Andre Marianovich
      Posted by Andre Marianovich
      on May 13 2012 09:38 AM
      Intellectual975 points

      UPDATE:

      I forgot to reenable the uDMA channel in the interrupt handler.... but now the I2SIntHandler seems to work. Unfortunately there will be no real data coming from the I2S device. I only get zeros although the oscilloscope shows some bits on the SD line.

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Andre Marianovich
      Posted by Andre Marianovich
      on May 14 2012 04:24 AM
      Intellectual975 points

      I heard about some problems with the uDMA and core speed above 50 MHz, so I set the speed down to 40 MHz but it doesn't fix the problem. Then I tried to do without the uDMA, to avoid that there are any problems with it. But I still get only zeros from the fifo.

      After over one week I realy need a solution, so I would be happy about any help.

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Andre Marianovich
      Posted by Andre Marianovich
      on May 14 2012 09:13 AM
      Intellectual975 points

      I've written a "quick & dirty" program without uDMA. If I use I2S_CONFIG_MODE_DUAL instead of I2S_CONFIG_MODE_MONO I get data that is different from zero. But I don't know why?

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Craig Giglio94760
      Posted by Craig Giglio94760
      on May 14 2012 09:21 AM
      Intellectual860 points

      Hello Andre,

      In the Stellarisware boards directory for the lm3s9B96 there is a drivers directory.  Located in that directory is a file called sound.c which contains some initialization routines for the I2S module.  This may help with you configuration.

      C:\StellarisWare\boards\dk-lm3s9b96\drivers

      If it doesn't let me know.

      Regards,

      Craig

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Andre Marianovich
      Posted by Andre Marianovich
      on May 14 2012 11:36 AM
      Intellectual975 points

      Well, I already know the code for the b96, but it doesn't bring me further. Till now, it works with        

      I2SRxConfigSet(I2S0_BASE, I2S_CONFIG_FORMAT_I2S
                                      | I2S_CONFIG_MODE_DUAL
                                      | I2S_CONFIG_CLK_MASTER
                                      | I2S_CONFIG_SAMPLE_SIZE_24
                                      | I2S_CONFIG_WIRE_SIZE_32);

      and it doesn't with

      I2SRxConfigSet(I2S0_BASE, I2S_CONFIG_FORMAT_I2S
                                      | I2S_CONFIG_MODE_DUAL
                                      | I2S_CONFIG_CLK_MASTER
                                      | I2S_CONFIG_SAMPLE_SIZE_24
                                      | I2S_CONFIG_WIRE_SIZE_32);

      First I got only zeros in the mono mode but now I don't get any output anymore. In dual mode I always get an output. Is there a coupling between the WS signal and the readout? In fact, I just have one microfone. Maybe it wouldn't make any difference between mono and dual mode, didn't it?

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    TI E2E™ Community
    • Support Forums
    • Blogs
    • Videos
    • Groups
    • Site Support & Feedback
    • Settings
    TI E2E™ Community Groups
    • TI University Program
    • Make the Switch
    • Microcontroller Projects
    • Motor Drive & Control
    Other Communities
    • Deyisupport
    • Designsomething.org
    • beagleboard.org
    • TI on Element 14
    • TI on TechXchangeSM
    Other Technical & Support Resources
    • WEBENCH® Design Center
    • Product Information Centers
    • Technical Documents
    • TI Design Network
    • TI Technical Articles
    • TI Training

    All content and materials on this site are provided "as is". TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with regard to these materials, including but not limited to all implied warranties and conditions of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with respect to these materials. No license, either express or implied, by estoppel or otherwise, is granted by TI. Use of the information on this site may require a license from a third party, or a license from TI.

    Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms of Use of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms of Use of this site. TI, its suppliers and providers of content reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

    Follow Us Texas Instruments on Facebook Texas Instruments on Twitter Texas Instruments on LinkedIn Texas Instruments on Google+
    TI Worldwide | Contact Us | my.TI Login | Site Map | Corporate Citizenship | mobile m.ti.com (Mobile Version)

    TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs and
    embedded processors, along with software, tools and the industry’s largest sales/support staff.

    © Copyright 1995-2013 Texas Instruments Incorporated. All rights reserved.
    Trademarks | Privacy Policy | Terms of Use