Giter Club home page Giter Club logo

infineon / mtb-example-xmc-dma-ring-buffer Goto Github PK

View Code? Open in Web Editor NEW
1.0 17.0 0.0 110 KB

This code example demonstrates how to receive data using DMA via a Universal Serial Interface Channel (USIC) and synchronize the processing with an OS task through a ring buffer. For simplicity, the OS task is emulated inside this example with a SysTick Timer interrupt.

Makefile 43.61% C 56.39%
kit-xmc47-relax-v1 peripherals kit-xmc-plt2go-xmc4200 kit-xmc-plt2go-xmc4400 kit-xmc43-relax-ecat-v1 kit-xmc45-relax-v1 kit-xmc48-relax-ecat-v1

mtb-example-xmc-dma-ring-buffer's Introduction

XMC™ MCU: DMA ring buffer

This code example demonstrates how to receive data using DMA via a universal serial interface channel (USIC) and synchronize the processing with an OS task through a ring buffer.

For simplicity, the OS task is emulated inside this example with a SysTick timer interrupt.

Requirements

Supported toolchains (make variable 'TOOLCHAIN')

  • GNU Arm® embedded compiler v10.3.1 (GCC_ARM) - Default value of TOOLCHAIN
  • Arm® compiler v6.16 (ARM)
  • IAR C/C++ compiler v9.30.1 (IAR)

Supported kits (make variable 'TARGET')

Hardware setup

This example uses the board's default configuration. See the kit user guide to ensure that the board is configured correctly.

Additionally, an USB-to-UART serial adapter is required to test the code example on the XMC4500 relax kit.

Software setup

Install a terminal emulator if you do not have one. Instructions in this document use Tera Term.

This example requires no additional software or tools.

Using the code example

Create the project and open it using one of the following:

In Eclipse IDE for ModusToolbox™ software
  1. Click the New Application link in the Quick Panel (or, use File > New > ModusToolbox™ Application). This launches the Project Creator tool.

  2. Pick a kit supported by the code example from the list shown in the Project Creator - Choose Board Support Package (BSP) dialog.

    When you select a supported kit, the example is reconfigured automatically to work with the kit. To work with a different supported kit later, use the Library Manager to choose the BSP for the supported kit. You can use the Library Manager to select or update the BSP and firmware libraries used in this application. To access the Library Manager, click the link from the Quick Panel.

    You can also just start the application creation process again and select a different kit.

    If you want to use the application for a kit not listed here, you may need to update the source files. If the kit does not have the required resources, the application may not work.

  3. In the Project Creator - Select Application dialog, choose the example by enabling the checkbox.

  4. (Optional) Change the suggested New Application Name.

  5. The Application(s) Root Path defaults to the Eclipse workspace which is usually the desired location for the application. If you want to store the application in a different location, you can change the Application(s) Root Path value. Applications that share libraries should be in the same root path.

  6. Click Create to complete the application creation process.

For more details, see the Eclipse IDE for ModusToolbox™ software user guide (locally available at {ModusToolbox™ software install directory}/ide_{version}/docs/mtb_ide_user_guide.pdf).

In command-line interface (CLI)

ModusToolbox™ software provides the Project Creator as both a GUI tool and the command line tool, "project-creator-cli". The CLI tool can be used to create applications from a CLI terminal or from within batch files or shell scripts. This tool is available in the {ModusToolbox™ software install directory}/tools_{version}/project-creator/ directory.

Use a CLI terminal to invoke the "project-creator-cli" tool. On Windows, use the command line "modus-shell" program provided in the ModusToolbox™ software installation instead of a standard Windows command-line application. This shell provides access to all ModusToolbox™ software tools. You can access it by typing modus-shell in the search box in the Windows menu. In Linux and macOS, you can use any terminal application.

This tool has the following arguments:

Argument Description Required/optional
--board-id Defined in the <id> field of the BSP manifest Required
--app-id Defined in the <id> field of the CE manifest Required
--target-dir Specify the directory in which the application is to be created if you prefer not to use the default current working directory Optional
--user-app-name Specify the name of the application if you prefer to have a name other than the example's default name Optional

The following example will clone the DMA ring buffer application with the desired name "DMARingBuffer" configured for the KIT_XMC47_RELAX_V1 BSP into the specified working directory, C:/mtb_projects:

project-creator-cli --board-id KIT_XMC47_RELAX_V1 --app-id mtb-example-xmc-dma-ring-buffer --user-app-name DMARingBuffer --target-dir "C:/mtb_projects"

Note: The project-creator-cli tool uses the git clone and make getlibs commands to fetch the repository and import the required libraries. For details, see the "Project creator tools" section of the ModusToolbox™ software user guide (locally available at {ModusToolbox™ software install directory}/docs_{version}/mtb_user_guide.pdf).

In third-party IDEs

Note: Only VS Code is supported.

  1. Follow the instructions from the In command-line interface (CLI) section to create the application, and import the libraries using the make getlibs command.

  2. Export the application to a supported IDE using the make <ide> command.

    For a list of supported IDEs and more details, see the "Exporting to IDEs" section of the ModusToolbox™ software user guide (locally available at {ModusToolbox™ software install directory}/docs_{version}/mtb_user_guide.pdf).

  3. Follow the instructions displayed in the terminal to create or import the application as an IDE project.

Operation

  1. Connect the board to your PC using a micro-USB cable through the debug USB connector.

  2. Open a terminal program and select the J-Link CDC UART COM port. Configure the terminal with baud rate of 115200, data bits of 8, stop bits of 1, and with parity and flow control set to none.

  3. Program the board using Eclipse IDE for ModusToolbox™ software:

    1. Select the application project in the Project Explorer.

    2. In the Quick Panel, scroll down, and click <Application Name> Program (JLink).

  4. After programming, the application starts automatically. Confirm that the welcome message ("DMA Ring Buffer example") is displayed on the UART terminal.

    Figure 1. DMA ring buffer example in terminal

  5. Type inside the terminal.

  6. Confirm that the text you type is echoed on the terminal.

Debugging

You can debug the example to step through the code. In the IDE, use the <Application Name> Debug (JLink) configuration in the Quick Panel. For more details, see the "Program and Debug" section in the Eclipse IDE for ModusToolbox™ software user guide.

Design and implementation

The code consists of two parts as follows:

  • Part 1: Defines and configures the DMA channel. The source address configured in the DMA is the 'RBUF' register (XMC_UART0_CH0->RBUF), where the data should be read from. The destination address is the address of the first element in the ring buffer array ring_buffer[0]. The data received via the UART and saved in the ring buffer is echoed to the UART. This task takes over the SysTick_Handler() interrupt function, which calls the uart_transmit() function to transmit the data from the ring buffer when new data is written by the DMA to the ring buffer.

  • Part 2: Initializes and enables the DMA module in the main function using the configuration from Step 1. It also configures the system time using the SysTick_Config() function, which calls the SysTick_Handler() function every 1 ms.

Resources and settings

The project uses a custom design.modus file because the following settings were modified in the default design.modus file.

Figure 2. USIC channel


Related resources

Resources Links
Code examples Using ModusToolbox™ software on GitHub
Device documentation XMC4000 family datasheets
[XMC4000 family technical reference manuals](https://www.infineon.com/cms/en/product/microcontroller/32-bit-industrial-microcontroller-based-on-arm-cortex-m/32-bit-xmc4000-industrial-microcontroller-arm-cortex-m4/#document-group-myInfineon-44
Development kits XMC™ eval boards
Libraries on GitHub mtb-xmclib-cat3 – XMC™ MCU peripheral library (XMCLib) and docs
Tools Eclipse IDE for ModusToolbox™ software – ModusToolbox™ software is a collection of easy-to-use software and tools enabling rapid development with Infineon MCUs, covering applications from embedded sense and control to wireless and cloud-connected systems using AIROC™ Wi-Fi and Bluetooth® connectivity devices.

Other resources

Infineon provides a wealth of data at www.infineon.com to help you select the right device, and quickly and effectively integrate it into your design.

For XMC™ MCU devices, see 32-bit XMC™ industrial microcontroller based on Arm® Cortex®-M.

Document history

Document title: CE232572XMC™ MCU: DMA ring buffer

Version Description of change
1.0.0 New code example
1.0.1 Updated README
1.1.0 Added support for more kits
2.0.0 Updated to support ModusToolbox™ software v3.0. This CE is not backward compatible with previous versions of ModusToolbox™ software.
2.1.0 Added support for DMA personality

All other trademarks or registered trademarks referenced herein are the property of their respective owners.

© 2022 Infineon Technologies AG

All Rights Reserved.

Legal disclaimer

The information given in this document shall in no event be regarded as a guarantee of conditions or characteristics. With respect to any examples or hints given herein, any typical values stated herein and/or any information regarding the application of the device, Infineon Technologies hereby disclaims any and all warranties and liabilities of any kind, including without limitation, warranties of non-infringement of intellectual property rights of any third party.

Information

For further information on technology, delivery terms and conditions and prices, please contact the nearest Infineon Technologies Office (www.infineon.com).

Warnings

Due to technical requirements, components may contain dangerous substances. For information on the types in question, please contact the nearest Infineon Technologies Office.

Infineon Technologies components may be used in life-support devices or systems only with the express written approval of Infineon Technologies, if a failure of such components can reasonably be expected to cause the failure of that life-support device or system or to affect the safety or effectiveness of that device or system. Life support devices or systems are intended to be implanted in the human body or to support and/or maintain and sustain and/or protect human life. If they fail, it is reasonable to assume that the health of the user or other persons may be endangered.


mtb-example-xmc-dma-ring-buffer's People

Contributors

cy-msur avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mtb-example-xmc-dma-ring-buffer's Issues

Problem create DMA Ring Buffer application for XMC4800 Relax Kit

Prerequisites

Can you reproduce the problem reliably? Yes

Did you check current release notes for known issues? Yes

If this is not the latest release, have you checked newer releases?

Description:

A clear and concise description of what the bug is.

Steps to Reproduce:

1.Initializing build: mtb-example-xmc-dma-ring-buffer Debug APP_KIT_XMC48_RELAX_ECAT_V1 GCC_ARM

Prebuild operations complete

Auto-discovery in progress...
ERROR:# 0: Code generator 'device-configurator-cli' finished - FAILED

ERROR: Generating code failed. Code generation errors:
ERROR: - Errors exist in the project's configuration:
ERROR: The signal 'Service Request 0' on 'USIC0_CH0 (CYBSP_DEBUG_UART)' must not have connections when hidden.

ERROR:make: *** [../mtb_shared/core-make/release-v3.2.2/make/core/search.mk:45: C:/Users/xxxx/mtw/DMA_Ring_Buffer/build/APP_KIT_XMC48_RELAX_ECAT_V1/Debug/cyforcebuild.mk] Error 1

ERROR:Failed to export the "DMA_Ring_Buffer" application to Eclipse IDE for ModusToolbox™.

6 error(s), 0 warning(s)

Summary:

ERROR:Failed to create and export "DMA_Ring_Buffer" application.

Expected Result:

Actual Result:

Frequency (1/1, 1/50, 1/100):

Build/Commit:

Please specify the release, like 1.4.1. If there is no release, give us the commit for the code you used.

Target:

The chip or kit you are working with

Host OS and Version:

MacOS, Windows, Linux

Compiler:

Include the version!

Environment

Provide the context surrounding this problem. Perhaps an IDE, a debug probe, an RTOS, etc. (and versions)

THANKS!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.