Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
RajivB
Level 2
Level 2
First like received 25 sign-ins 10 replies posted

Dear Infineon,

Any example to read 32-bit I2S PCM data using XMC4500 using DMA, which is the standard way it is handled in other MCUs like Microchip, Texas Instruments, STM et al ? 

With best regards,

Rajiv.

0 Likes
11 Replies
Vasanth
Moderator
Moderator
Moderator
250 sign-ins 500 solutions authored First question asked

Hi Rajiv,

We do not have a DMA based I2S example ready made. But do checkout the app info section in the I2S dave app which do have sample code for you start using the I2S. The following DMA UART example can be used for reference too.

 

/**
 * @file main.c
 * @date 2015-07-20
 *
 * @cond
  *********************************************************************************************************************
 * XMClib v2.1.8 - DMA_UART XMC Peripheral Driver Library Example
 *
 * Copyright (c) 2015-2016, Infineon Technologies AG
 * All rights reserved.                        
 *                                             
 * Redistribution and use in source and binary forms, with or without modification,are permitted provided that the 
 * following conditions are met:   
 *                                                                              
 * Redistributions of source code must retain the above copyright notice, this list of conditions and the following 
 * disclaimer.                        
 * 
 * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following 
 * disclaimer in the documentation and/or other materials provided with the distribution.                       
 * 
 * Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote 
 * products derived from this software without specific prior written permission.                                           
 *                                                                              
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE  
 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE  FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR  
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
 * WHETHER IN CONTRACT, STRICT LIABILITY,OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.                                                  
 *                                                                              
 * To improve the quality of the software, users are encouraged to share modifications, enhancements or bug fixes with 
 * Infineon Technologies AG dave@infineon.com).                                                          
 *********************************************************************************************************************
 *
 * Change History
 * --------------
 *
 * 2015-07-20:
 *     - Initial version
 *
 * @endcond
 *
 */

#include <xmc_gpio.h>
#include <xmc_uart.h>
#include <xmc_dma.h>

#define UART_TX P1_5
#define UART_RX P1_4

#define BUFFER_LENGTH 256

uint8_t buffer1[BUFFER_LENGTH];
uint8_t buffer2[BUFFER_LENGTH];

XMC_UART_CH_CONFIG_t uart_config =
{
  .data_bits = 8U,
  .stop_bits = 1U,
  .baudrate = 115200U
};

XMC_DMA_CH_CONFIG_t dma_ch_config =
{
  .dst_addr = (uint32_t)&(XMC_UART0_CH0->TBUF[0]),
  .src_transfer_width = XMC_DMA_CH_TRANSFER_WIDTH_8,
  .dst_transfer_width = XMC_DMA_CH_TRANSFER_WIDTH_8,
  .src_address_count_mode = XMC_DMA_CH_ADDRESS_COUNT_MODE_INCREMENT,
  .dst_address_count_mode = XMC_DMA_CH_ADDRESS_COUNT_MODE_NO_CHANGE,
  .src_burst_length = XMC_DMA_CH_BURST_LENGTH_8,
  .dst_burst_length = XMC_DMA_CH_BURST_LENGTH_1,
  .transfer_flow = XMC_DMA_CH_TRANSFER_FLOW_M2P_DMA,
  .transfer_type = XMC_DMA_CH_TRANSFER_TYPE_SINGLE_BLOCK,
  .dst_handshaking = XMC_DMA_CH_DST_HANDSHAKING_HARDWARE,
  .dst_peripheral_request = DMA0_PERIPHERAL_REQUEST_USIC0_SR0_0,
  .enable_interrupt = true
};

volatile bool transfer_done = false;

void GPDMA0_0_IRQHandler(void)
{
  transfer_done = true;
  XMC_DMA_CH_ClearEventStatus(XMC_DMA0, 2, XMC_DMA_CH_EVENT_BLOCK_TRANSFER_COMPLETE);
}

int main(void)
{
  uint32_t i;
  for (i = 0; i < BUFFER_LENGTH; ++i)
  {
    buffer1[i] = i;
    buffer2[i] = 255 - i;
  }

  XMC_DMA_Init(XMC_DMA0);
  XMC_DMA_CH_Init(XMC_DMA0, 2, &dma_ch_config);
  XMC_DMA_CH_EnableEvent(XMC_DMA0, 2, XMC_DMA_CH_EVENT_BLOCK_TRANSFER_COMPLETE);

  /* Enable DMA event handling */
  NVIC_SetPriority(GPDMA0_0_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), 63, 0));
  NVIC_EnableIRQ(GPDMA0_0_IRQn);

  XMC_UART_CH_Init(XMC_UART0_CH0, &uart_config);

  XMC_GPIO_SetMode(UART_RX, XMC_GPIO_MODE_INPUT_TRISTATE);
  XMC_UART_CH_SetInputSource(XMC_UART0_CH0, XMC_UART_CH_INPUT_RXD, USIC0_C0_DX0_P1_4);

  XMC_UART_CH_EnableEvent(XMC_UART0_CH0, XMC_UART_CH_EVENT_TRANSMIT_BUFFER);
  XMC_USIC_CH_SetInterruptNodePointer(XMC_UART0_CH0, XMC_USIC_CH_INTERRUPT_NODE_POINTER_TRANSMIT_BUFFER, 0);

  XMC_UART_CH_Start(XMC_UART0_CH0);
  XMC_USIC_CH_TriggerServiceRequest(XMC_UART0_CH0, 0); /* make DMA ready */

  XMC_GPIO_SetMode(UART_TX, XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT2);

  XMC_DMA_CH_SetBlockSize(XMC_DMA0, 2, BUFFER_LENGTH);
  XMC_DMA_CH_SetSourceAddress(XMC_DMA0, 2, (uint32_t)&buffer1[0]);
  XMC_DMA_CH_Enable(XMC_DMA0, 2);

  while (transfer_done == false);

  XMC_DMA_CH_SetBlockSize(XMC_DMA0, 2, BUFFER_LENGTH);
  XMC_DMA_CH_SetSourceAddress(XMC_DMA0, 2, (uint32_t)&buffer2[0]);
  XMC_DMA_CH_Enable(XMC_DMA0, 2);


  while(1);
}

Best Regards,
Vasanth

0 Likes
RajivB
Level 2
Level 2
First like received 25 sign-ins 10 replies posted

Doesn't answer my question in any way. What should be the DMA config structure for I2S transfer, dma_ch_config ? How will I2S DMA receive 32-bits I2S PCM Data, when FIFO is 16-bit as well as RBUF is 16-bit ? PACKING 16-bits is just not a solution, as it is causing severe frame sync issues, as I2S PROTOCOL does not take care of that. So, 32-bit DMA TRANSFER solution is required. Can Infineon provide this using DMA as other vendors have already provided such solutions very readily, BE IT MICROCHIP,   TEXAS INSTRUMENTS, ESP32, STM32..But it is really very bad to see that Infineon hasn't provided a solution for such a basic important protocol which is a standard for digital audio. Should OEMs recommend Infineon, when Infineon XMC controllers are having such kinds of issues ? 

XMC_DMA_CH_CONFIG_t dma_ch_config =
{
  .dst_addr = (uint32_t)&(XMC_UART0_CH0->TBUF[0]),
  .src_transfer_width = XMC_DMA_CH_TRANSFER_WIDTH_8,
  .dst_transfer_width = XMC_DMA_CH_TRANSFER_WIDTH_8,
  .src_address_count_mode = XMC_DMA_CH_ADDRESS_COUNT_MODE_INCREMENT,
  .dst_address_count_mode = XMC_DMA_CH_ADDRESS_COUNT_MODE_NO_CHANGE,
  .src_burst_length = XMC_DMA_CH_BURST_LENGTH_8,
  .dst_burst_length = XMC_DMA_CH_BURST_LENGTH_1,
  .transfer_flow = XMC_DMA_CH_TRANSFER_FLOW_M2P_DMA,
  .transfer_type = XMC_DMA_CH_TRANSFER_TYPE_SINGLE_BLOCK,
  .dst_handshaking = XMC_DMA_CH_DST_HANDSHAKING_HARDWARE,
  .dst_peripheral_request = DMA0_PERIPHERAL_REQUEST_USIC0_SR0_0,
  .enable_interrupt = true
};

 

 

0 Likes
RajivB
Level 2
Level 2
First like received 25 sign-ins 10 replies posted

Why is 32-bit I2S PCM capture/record or Playback support via DMA which is the standard in the way audio is handled by other SOC & Micro-Controller vendors NOT provided by Infineon ?  Please provide 32-BIT I2S PCM support, as Infineon advertises XMC4500 as 32-bit controller, but intentionally is misleading OEMs & vendors by providing actual READ capability of only 16-bits, via 16-bit Receive Buffers & only 16-bit FIFOs.

0 Likes
RajivB
Level 2
Level 2
First like received 25 sign-ins 10 replies posted

Why is this UNSOLVED Question being shown as a solution for this question,

https://community.infineon.com/t5/XMC/Re-XMC4500-I2S-questions/m-p/355981#M10829

The Moderator has closed the previous Ticket by pointing to this question, which again is 

unsolved & hardly any solution is provided for this specific question, instead of posting some 

random example which is not related to the asked question in anyway, in the first place. 

Dear Infineon Team, kindly take NOTE of such kinds of malpractices which send wrong signals

to OEMs & Vendors on credibility of Infineon MCUs. 

Aashita_R
Moderator
Moderator
Moderator
50 likes received 100 solutions authored 250 replies posted

Hi @RajivB ,

We have provided the available example to start with. Meanwhile I am checking internally for the code example related to I2S. I will keep you posted as soon as I receive any input from the internal team. Also, since the duplicate threads were created, those threads were locked.

Thank you for your understanding!

Best Regards,

Aashita

0 Likes
RajivB
Level 2
Level 2
First like received 25 sign-ins 10 replies posted

The Thing is, what we need is DMA based Audio Capture/Record & Audio Playback example for 32-bit PCM. Even for 16-bit PCM DMA based approach in the example is missing. DMA is the standard way in which Audio Transfer are implemented in every MCU vendors, be it MICROCHIP PIC32, STM32, TI MSP, or even ESP32. Every major vendor provides & implements DMA as the Standard way of Audio Transfer. It is really very shocking to see a vendor like Infineon having no answer for DMA based Audio implementation, which really makes me think if Author of such examples have really worked on Audio development or not ?

If not, please check with Actual Audio Development Team in Infineon, if you have so. Audio examples provided by Infineon for I2S do not help in any way.

Plus, also mention clearly that 32-bit I2S PCM is not supported by Infineon XMC platforms clearly in your Datasheet & User Manual, instead of mentioning I2S support which leads OEMs to assume that 32-bit PCM is also supported as like 16-bit PCM via I2S. Really, very strange to see Infineon mentioning XMC45/48 as 32-BIT Micro-controllers but actually supports 16-BIT operations only, which is very misleading & bad.

RajivB
Level 2
Level 2
First like received 25 sign-ins 10 replies posted

Any updates on this ?   When can we expect something from Infineon to solve this problem in XMC45/47/48xx MCU for Audio Playback/Capture using DMA  for 16-bit & 32-bit PCM ?

0 Likes
RajivB
Level 2
Level 2
First like received 25 sign-ins 10 replies posted

Any updates from Audio Team of Infineon on this ? This is very suprising to see no reply on THREADED Audio DMA implementation for Playback & Record, which every other MCU vendor like TEXAS Instruments, STM, MICROCHIP, NXP are readily providing support for, except Infineon. Might we know the reason for this lack of support for THREADED Audio DMA example for Playback & Capture, from Infineon which forms the backbone of so many Audio Applications ?

0 Likes
RajivB
Level 2
Level 2
First like received 25 sign-ins 10 replies posted

Any updates on this ? No examples of implementation yet on THREADED Audio DMA implementation for Playback & Record for Infineon XMC4500. This is the reason why i would never recommend Infineon for any of my designs to others. Microchip, STM, TI, ESP32 are far better in providing full fledged Audio DMA implementation for Playback & Capture for 16-bit/32-bit PCM for many popular Audio codecs, which is not so in case of Infineon. Very bad support from Infineon. 

0 Likes
AlexPierotti
Level 1
Level 1
First reply posted Welcome!

Any update about this? We are also trying to use XMC4700 for I2S 32 bit

0 Likes

The DMA based Threaded implementation for I2S is not provided by Infineon in any way. Plus 32-bit PCM is not supported in any way by Infineon, which is really very strange, when Infineon states that XMC45/XMC47/XMC48 are 32-bit controllers.  Unlike other Controllers like STM32F407 or PIC32MX150F256H which are really much much better suited for Audio I2S development & provide I2S DMA support for Audio playback & capture. Better DUMP XMC4700 controller if you don't want your Project to fail miserably using XMC4700 & change your MCU in the Project to STM32F407 or PIC32MX as soon as possible. This is the only advise i can give you. XMC4700/XMC48 controllers are not meant for Embedded Audio/Video or DSP development but only for Industrial applications involving motor controllers, automation, current drivers et al. So, better be sorry than late, CHANGE your MCU for this I2S audio project. Thanks.