Audio player on KwikStik



Similar documents
TWR-KV31F120M Sample Code Guide for IAR Board configuration, software, and development tools Rev.0

Building and Debugging a project using Keil MDK-ARM Eclipse plug-in

USB to SPI Device Driver Installation Instructions

HVP-KV31F120M Quick Start Guide

How to Run the MQX RTOS on Various RAM Memories for i.mx 6SoloX

UART Boot Loader Design on the Kinetis E Series

Designing an Induction Cooker Using the S08PT Family

CodeWarrior Development Studio for Freescale S12(X) Microcontrollers Quick Start

How To Use A Watt Saver On A Microcontroller (Watt Saver) On A Cell Phone Or Mp3 Player

How To Build A Project On An Eclipse Powerbook For Anarc (Powerbook) On An Ipa (Powerpoint) On A Microcontroller (Powerboard) On Microcontrollers (Powerstation) On Your Microcontroller 2 (Powerclock

MED-AFEs Design Reference Manual

MQX Lite Real-Time Operating System User Guide

Installing Service Pack Updater Archive for CodeWarrior Tools (Windows and Linux) Quick Start

Production Flash Programming Best Practices for Kinetis K- and L-series MCUs

76-77 GHz RF Transmitter Front-end for W-band Radar Applications

AN3998 Application note

Quick Start Guide. USB Packet Sniffer/Dongle for Kinetis MKW22D and MKW24D Wireless MCUs USB-KW24D512

QorIQ espi Controller Register Setting Considerations and Programming Examples

MP3/WMA Player + Digital Voice Recorder + USB Flash Drive

APPLICATION. Using the PB-100 to Make Calls and Announcements From a Database. Using the PB-100 for All-Call Dialing

Getting Started with Kinetis SDK (KSDK)

Processor Expert Software Microcontrollers Driver Suite Getting Started Guide

MPR121 Serial Communication

UM1727 User manual. Getting started with STM32 Nucleo board software development tools. Introduction

How To Develop A Toolstick

Freescale MAC Security Setup

Programming Audio Applications in the i.mx21 MC9328MX21

AN3997 Application note

Windows 7: Using USB TAP on a Classic CodeWarrior Installation (MGT V9.2 DSC V8.3)

Quick Start Guide. MRB-KW01 Development Platform Radio Utility Application Demo MODULAR REFERENCE BOARD

etpu Host Interface by:

Freescale MQX USB Device User Guide

An introduction to nxpusblib. March 2012

UM1680 User manual. Getting started with STM32F429 Discovery software development tools. Introduction

PC Base Adapter Daughter Card UART GPIO. Figure 1. ToolStick Development Platform Block Diagram

Initializing the TSEC Controller

CodeWarrior Development Studio Floating Licensing Quick Start

Using WinUSB in a Visual Studio Project with Freescale USB device controller

Installing Service Pack Updater Archive for CodeWarrior Tools (Windows and Linux) Quick Start

USBSPYDER08 Discovery Kit for Freescale MC9RS08KA, MC9S08QD and MC9S08QG Microcontrollers User s Manual

AN LPC1700 timer triggered memory to GPIO data transfer. Document information. LPC1700, GPIO, DMA, Timer0, Sleep Mode

Installation of the MMA955xL CodeWarrior Service Pack Author: Fengyi Li Application Engineer

Flexible Active Shutter Control Interface using the MC1323x

Configuring CoreNet Platform Cache (CPC) as SRAM For Use by Linux Applications

AVR115: Data Logging with Atmel File System on ATmega32U4. Microcontrollers. Application Note. 1 Introduction. Atmel

Quick Start Guide. TWR-MECH Mechatronics Board TOWER SYSTEM

UM1790 User manual. Getting started with STM32L053 discovery kit software development tools. Introduction

UM0985 User manual. Developing your STM32VLDISCOVERY application using the IAR Embedded Workbench software. Introduction

Software Real Time Clock Implementation on MC9S08LG32

UM1727 User manual. Getting started with STM32 Nucleo board software development tools. Introduction

YAMAHA ASIO DirectKS Driver for Windows Owner's Manual

Welcome to the tutorial for the MPLAB Starter Kit for dspic DSCs

Embedded Component Based Programming with DAVE 3

Kanguru Micro MP3 PRO USB2.0 User s Manual

Single Phase Two-Channel Interleaved PFC Operating in CrM

Genesi Pegasos II Setup

AN655 R ANGE TEST APPLICATION FOR EZRADIO AND EZRADIOPRO. 1. Introduction. 2. Supported Radio Types

USER GUIDE EDBG. Description

Hardware Configurations for the i.mx Family USB Modules

AN3252 Application note

Figure 1. 8-Bit USB Debug Adapter

Performance Monitor on PowerQUICC II Pro Processors

SMARTCARD XPRO. Preface. SMART ARM-based Microcontrollers USER GUIDE

Java Embedded Applications

AN111: Using 8-Bit MCUs in 5 Volt Systems

UM1969 User manual. Getting started with STM32F746G discovery software development tools. Introduction

Audio-Technica AT-LP60-USB, AT-LP120-USB, AT-LP240-USB & AT-LP1240-USB Turntables. Software Guide

APPLICATION NOTE. AT07175: SAM-BA Bootloader for SAM D21. Atmel SAM D21. Introduction. Features

Cubase LE 5. Installing Cubase LE 5. Trademarks. Quick Start Guide

Heterojunction Bipolar Transistor Technology (InGaP HBT) Broadband High Linearity Amplifier

Generate Makefiles from Command Line Support in Eclipse-Based CodeWarrior Software

Connecting Kinetis MCU with CMOS Sensor Interface through GPIO QQVGA image transfer to Kinetis internal SRAM

Freescale, the Freescale logo and CodeWarrior are trademarks of Freescale Semiconductor, Inc., Reg. U.S. Pat. & Tm. Off. Xtrinsic is a trademark of

QUICK SETUP GUIDE SETUP FOR ICONNEX SOUNDCARD AND AUDACITY RECORDING SOFTWARE

Complete Integrated Development Platform Copyright Atmel Corporation

AVR1301: Using the XMEGA DAC. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

PCXpocket 440. Professional Digital Audio Card. User s manual. DU IS=A

ERIKA Enterprise pre-built Virtual Machine

Zynq-7000 Platform Software Development Using the ARM DS-5 Toolchain Authors: Simon George and Prushothaman Palanichamy

Kinetis Bootloader v2.0.0 Release Notes

32F769IDISCOVERY. Discovery kit with STM32F769NI MCU. Features

Floating License Installation Guide for Windows

RF Power LDMOS Transistor High Ruggedness N--Channel Enhancement--Mode Lateral MOSFET

Freescale Semiconductor, I

Professional 24-bit USB Audio Interface. User s Guide

STM32F4DISCOVERY. Discovery kit with STM32F407VG MCU. Features. Description

FRDM-KL25Z User's Manual Rev. 1.0

APPLICATION NOTE. AT17284: Proximetry Cloud Based Smart Plug User Guide. SMART ARM-based Microcontrollers. Introduction. Features

AN LPC1700 RTC hardware auto calibration. Document information. RTC, Hardware Auto Calibration, LPC1700, Graphic LCD

3. Programming the STM32F4-Discovery

Figure 1. Proper Method of Holding the ToolStick. Figure 2. Improper Method of Holding the ToolStick

32F072BDISCOVERY. Discovery kit for STM32F072xx microcontrollers. Features. Description

AN4646 Application note

How To Use An Atmel Atmel Avr32848 Demo For Android (32Bit) With A Microcontroller (32B) And An Android Accessory (32D) On A Microcontroller (32Gb) On An Android Phone Or

ZigBee-2.4-DK 2.4 GHZ ZIGBEE DEVELOPMENT KIT USER S GUIDE. 1. Kit Contents. Figure GHz ZigBee Development Kit

Software and Support Activation. Quick Start Guide

32-bit AVR UC3 Microcontrollers. 32-bit AtmelAVR Application Note. AVR32769: How to Compile the standalone AVR32 Software Framework in AVR32 Studio V2

IRTC Compensation and 1 Hz Clock Generation

Understanding LCD Memory and Bus Bandwidth Requirements ColdFire, LCD, and Crossbar Switch

AN10866 LPC1700 secondary USB bootloader

Transcription:

Freescale Semiconductor Application Note Document Number: AN4523 Rev. 0, 01/2014 Audio player on KwikStik by: Michael Galda Freescale Semiconductor, Inc. 1 Introduction This demo application describes an implementation of the simple Audio player on the Kinetis ARM Cortex -M4 based MCU. The audio files are stored on the SD card. Supported are.wav files containing uncompressed WAV audio samples in LPCM format. WAV format has a simple structure and is well known. When compressed audio support is needed, an audio software codec can be easily imported to the existing software application, for instance to create a true MP3/WMA player. This shows an excellent solution for those applications using message playback or voice recording. The Demo software is managed by the Freescale MQX Real-Time Operating System (RTOS). Bare-metal drivers are used for direct access to MCU peripherals like timers and DAC. The hardware of the demo is based on the Freescale KwikStik (version 5), an ultra low-cost, all-in-one development tool for evaluating, developing and debugging Kinetis MCUs. It features the K40X256VLQ100 (144LQFP) MCU with USB, an On-Board J-Link USB Contents 1. Introduction................................. 1 2. Player Demo Overview........................ 2 3. KwikStik Player application description.......... 3 4. Playback................................... 4 5. MQX BSP setup............................. 7 6. Conclusion................................. 9 7. References................................. 10 2014 Freescale Semiconductor, Inc. All rights reserved.

Player Demo Overview Programmer, Capacitive Touch Sensing, Segment LCD, Microphone, 3.5 mm Audio Output Jack, Micro SD Card slot functionality, etc. The solution may be reused for the following applications: Voice recorders Answering Machines Smart Medical Appliances Safety systems Electronic toys 2 Player Demo Overview The Demo software reads the.wav files stored on SD card, using the Freescale MQX software stationary and MFS (MQX File System). SD-card has to be formatted to FAT file system. The default SD directory location is set to \Songs it can be changed in the software. The supported.wav formats are either Mono or Stereo records, tested with 22050 khz sample rate. Audio records are stored in the raw-form as 16-bit signed integer PCM samples. DAC (Digital to Analog Converter) is used to generate the audio output. KwikStik HW supports only one DAC out channel, so it can provide single channel audio output (Mono). DAC output can generate very smooth signals. The DAC current output capability is very low (max. 1mA), so it has to be amplified externally. The DAC output register has to be periodically reloaded with the new sample by the timer channel IRQ. MCU FlexTimer (FTM0) peripheral generating the periodic IRQ with the period equal to audio sampling rate is used for triggering the DAC. In the simplest case the DAC output register is filled by the audio samples inside the timer IRQ routine. In order to offload the CPU, DMA (Direct Memory Access) peripheral can be used for filling the audio output by data with no CPU assistance needed. Moreover a Double Buffering method (known as Ping-Pong buffers) is used for the smooth playback without jamming. 2 Freescale Semiconductor

KwikStik Player application description At any one time, one buffer is actively being played (the front buffer), while the second (background) buffer is filled with the new audio samples. When playing is completed, the roles of the two buffers are switched. This is usually accomplished by switching the pointers. WAV Player SD Card Audio Out DAC output (22 khz IRQ) Buff1 Buff2 Play task MQX file system file.wav L R LCD task Control Task (TSS controls) MQX 4.0+ PLAY STOP PAUSE NEXT PREV HELP KwikStik v.5 Figure 1. Audio player block scheme 3 KwikStik Player application description The software of the application is based on the block scheme shown in Figure 2. The application is controlled by capacitive (TSS library) buttons located on both sides of the KwikStik (www.freescale.com/kwikstik). Touch buttons (E1, E3, E5) on the left side are used for the PLAY / STOP and NEXT / PREV functions and touch buttons on the other side are used for the VOLUME controls. Freescale Semiconductor 3

Playback Microphone Touch buttons (E1,E3,E5) Touch buttons (E2,E4,E6) Audio output SD Card Slot Figure 2. KwikStik HW description 1 The application demo software was tested on KwikStik HW ver.5 2 Due known HW issues the demo may not run properly on the older versions of HW 4 Playback During message playback, the audio data is read from the SD card file to one of the audio output buffers. The samples are reproduced using the internal 12-bit DAC. Audio data paths and file IO operations are double-buffered to avoid the loss of frames. So that once the first buffer (containing the processed audio data) has been played, the application switches to the second buffer and reuses the first one for reading. Audio output (DAC) is driven via the FTM interrupt handler which is periodically fired based on the audio sample rate (tested with 22050 khz, stereo records). The Freescale MQX Real-Time Operating System (RTOS) provides real-time performance within a small, configurable footprint. The easy-to-use API and out-of-box experience ensure that first-time RTOS users can start developing their applications on the day the software is installed. The MQX RTOS is targeted 4 Freescale Semiconductor

Playback mainly at embedded applications supporting most of the Freescale 32-bit MCUs. By using MQX, we can run several parallel tasks on a single CPU core. Moreover, MQX includes a complete file system (MFS) and peripheral drivers, such as the SD-card driver used in this demo application. MFS is an embedded FAT file system compatible with the Microsoft Windows and MS-DOS file systems. It can format, read, write and exchange files with any operating systems running a FAT-12, FAT-16 or FAT-32 file system. It is fully re-entrant and uses the Freescale MQX RTOS file device driver to access disk devices. See freescale.com/mqx for detailed information on MQX. Bare-Metal software routines are used for direct access to some MCU peripherals in order to save CPU cycles and take control over the HW during the time critical tasks. TSS: Freescale Touch Sensing software library is now fully integrated to MQX BSP package, precompiled and delivered in library tss.lib with the MQX installation. Freescale Semiconductor 5

Playback Playback FTM IRQ Handler (22kHz) Open file for reading Fill DAC out register Start playing n++ EOF or STOP n > READBUF_SIZE No Yes Read from File PlayingBuff == 0 Yes OutBuff0 == EMPTY Yes Read to Outbuff0 OutBuff0 = EMPTY Yes No No OutBuff1 == EMPTY Yes Read to Outbuff1 No PlayingBuff = 1 No OutBuff = FULL OutBuff1 = EMPTY STOP playing, Disable outputs, FCLOSE PlayingBuff = 0 END END Figure 3. Playback block diagram 6 Freescale Semiconductor

MQX BSP setup 5 MQX BSP setup The demo software project uses the MQX BSP and file system. Before the Player software project can be compiled under the KEIL environment, the MQX BSP, PSP and MFS libraries has to be compiled. Then the precompiled libraries have to be imported to the project. The project considers the MQX default installation location is: c:\freescale\freescale_mqx_4_0\. When the MQX path is different, the compiler / linker paths have to be changed in the Player software project settings. Follow the steps below. The procedure is valid for KEIL uvision-4 compiler IDE, but it will be analogical for IAR EWARM or CodeWarrior 1. Download the AN4523SW.zip package. 2. Install the MQX 4.0 or higher from Freescale web: www.freescale.com/mqx 3. Copy the application software demo to you MQX installation directory: C:\Freescale\Freescale_MQX_4_0\demo\ 4. Find the MQX build libraries workspace directory located in: MQX_DIR\ config\kwikstikk40x256\uv4\ For instance: C:\Freescale\Freescale_MQX_4_0\config\kwikstikk40x256\uv4\ 5. Open the MQX build_libs project (file: build_libs.uvmpw ) bsp_kwikstikk40x256 Debug has to be selected as active target -Figure 4. 6. Set bsp_kwikstikk40x256 as the active project (right click on the selected item Figure 5. 7. Recompile the bsp project. 8. Repeat the procedure for psp and mfs projects as well. (i.e. recompile: bsp, psp and mfs) You can also run the Batch build for all MQX library projects (Project->Batch Build ) 9. Now open the Player project. If you can see the libs already imported under the MQX Libraries group (See Figure 6), you can skip that step. 10. (This step is optional.) When needed, import the precompiled MQX libraries to the Player project (you may have to remove the old ones).the pre-compiled libraries are placed in the: MQX_DIR\lib. For instance: C:\Freescale\Freescale_MQX_4_0\lib\kwikstikk40x256.uv4\debug\bsp\bsp.lib. 11. Import the bsp, tss, psp and mfs lib files: from the debug location which means the debug target. See Figure 6. 12. Finally, recompile the Player project. For more details about the MQX usage under the KEIL compiler read the MQX-uVision4-Getting-Started.pdf, located in: c:\freescale\freescale_mqx_4_0\doc\tools\uv4\. 13. Go to the section MQX-Viewer TAD Debugger Plug-in. 14. If needed, install the uvision4 TAD, continue per the instructions in the document. See Figure 7 with the MQX TAD tool screenshot. Freescale Semiconductor 7

MQX BSP setup 15. The.wav files have to be placed on SD card (formatted with FAT or FAT32 system) and located in the SD:\Songs\ directory. The default song location can be changed in file filemenu.h. Figure 4. Building MQX libraries Figure 5. Set the Active project 8 Freescale Semiconductor

Conclusion Figure 6. Import the MQX libraries to the player project Figure 7. MQX TAD tools 1 MQX TAD tool may be very useful for tuning and debugging the MQX application like this. For instance you can see the periodical switching of the tasks, which task is active and which are blocked or in error state. 6 Conclusion This Application Note presents the simple solution for uncompressed Audio playback based on Kinetis ARM Cortex-M4 MCU with CPU core running @100MHz under the MQX RTOS. The CPU provides enough processing performance, so the application can be additionally extended by audio de-compression codec. Freescale Semiconductor 9

References 7 References freescale.com/mqx freescale.com/kwikstik freescale.com/tss freescale.com/webapp/sps/site/prod_summary.jsp?code=k40_100 https://ccrma.stanford.edu/courses/422/projects/waveformat/ 10 Freescale Semiconductor

How to Reach Us: Home Page: freescale.com Web Support: freescale.com/support Information in this document is provided solely to enable system and software implementers to use Freescale products. There are no express or implied copyright licenses granted hereunder to design or fabricate any integrated circuits based on the information in this document. Freescale reserves the right to make changes without further notice to any products herein. Freescale makes no warranty, representation, or guarantee regarding the suitability of its products for any particular purpose, nor does Freescale assume any liability arising out of the application or use of any product or circuit, and specifically disclaims any and all liability, including without limitation consequential or incidental damages. Typical parameters that may be provided in Freescale data sheets and/or specifications can and do vary in different applications, and actual performance may vary over time. All operating parameters, including typicals, must be validated for each customer application by customer s technical experts. Freescale does not convey any license under its patent rights nor the rights of others. Freescale sells products pursuant to standard terms and conditions of sale, which can be found at the following address: freescale.com/salestermsandconditions. Freescale, the Freescale logo, and Kinetis are trademarks of Freescale Semiconductor, Inc., Reg. U.S. Pat. & Tm. Off. All other product or service names are the property of their respective owners. ARM and Cortex are the registered trademarks of ARM Limited. 2014 Freescale Semiconductor, Inc. Document Number: AN4523 Rev. 0 01/2014