Freescale, the Freescale logo, CodeWarrior, ColdFire, C‐Ware, the Energy Efficient Solutions logo are trademarks of Freescale Semiconductor, Inc., Reg. U.S. Pat. & Tm. Off. ColdFire+, CoreNet,
Flexis, Kinetis, MXC, Platform in a Package, Processor Expert, and Xtrinsic are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective
Purpose This lab document will familiarize you with TWR‐K20D50M board and development tools. You will learn the full features of the TWR‐K20D50M demos that are pre‐programmed onto your Tower module. You will learn how to access the source code using development tools IAR 6.3 or the CodeWarrior 10.2 Getting known the board Main components of the TWR‐K20D50M are shown in following picture. Download and Install Software and Tools Get the installation software and documentation under “Jump Start Your Design” at www.freescale.com/TWR‐K20D50M Install the P&E Micro Kinetis Tower Toolkit to install the OSJTAG and USB‐to‐Serial drivers. pemicro_osbdm_osjtag_tower_toolkit.exe Note: Please follow instructions on section 12 before using of CW or IAR tools. TWR‐K20D50M Quick Start Demo Lab Guide Page 3 of 23 ...
Configure Hardware 1) Make sure jumpers are set in default position as shown in following picture, for more details see TWR‐K20D50M Jumper options 2) Connect one end of the USB cable to the PC and the other end to the Power/OSJTAG mini‐B connector on the TWR‐K20D50M module. Allow the PC to automatically configure the USB drivers if needed. llow the PC to automatically configure the OSJTAG drivers used for debugging and the serial‐to‐ USB feature. TWR‐K20D50M Quick Start Demo Lab Guide Page 4 of 23 ...
Run the Demos TWRK20D50M Demo software This code is pre‐programmed in your TWRK20D50M, and shows some of the features of the K20 family and the TWRK20D50M board. Following table show how different modules are used in this application Table 1 K20 Modules used on TWRK20 Demo software Module Function Details ADC Reads 2 signals 12 bits mode Potentiometer Hardware triggered Microphone PDB Creates a sampling frequency of 8 kHz for the ADC Continous mode converter at 8 Khz Triggers ADC0 DMA Store microphone readings in a double buffer of Interrupt when 128 samples are 128 samples each sampled and perform calculation of FFT, and filters. DSP Calculates FFT of 128 samples and magnitude of Uses CMSIS integrated library in each harmonic IAR 6.3 I2C Reads accelerometer, acceleration in each axes x, y, K20 calculates tilt angle and fall ...
5.1 Buzzer Demo Press reset button, the board will sound 3 tones. Note: Different tests use the buzzer as feedback; you can disable the buzzer by removing jumper J1 (BUZZER). 5.2 Switch Demo Press SW3, a tone is generated and red led glows Press SW2, a tone is generated. 5.3 Touch Demo Touch Electrode 2, a tone is generated and orange LED glows. Touch Electrode 3, a tone is generated and yellow LED glows. 5.4 Accelerometer Demo Tilt the board slowly back and forth to hear different tones depending on tilt angle. 5.5 Microphone Demo ...
Press reset button. The terminals will display a RESET message and prompt: TWRK20D50M Demo Software Rev 1.4 In the terminal program, there will be a shell prompt after you hit the Enter key. Type “help” to see the list of commands. 5.6.1 Display command Most of the commands included in this demo can be displayed with command “disp” and a number, as shown below. K20_Demo >disp N Table 2 List of available options for “disp” command Command display Description disp 0 Cancel display > Abort current display and prompt for new command disp 1 rtc Rtc nnn Shows RTC second counter disp 2 Buttons B nn Show buttons/electrodes that are pressed ...
5.6.2 RTC Demo Type command: K20_Demo >disp 1 Terminal will display seconds since last reset, and seconds elapsed since VBAT has been powered. RTC 953 ; elapsed time with Vbat 1955 5.6.3 ADC Demo (Potentiometer) Type command: K20_Demo >disp 6 Terminal will display the value of the ADC connected to the potentiometer. ADC POT = 1425 5.6.4 LED Demo Type command: K20_Demo >disp 3 Terminal will display a counter and the 4 leds will be turning on/off according to the counter. LEDs n 5.6.5 Tilt detection / Accelerometer Demo Buzzer beeps at different tones depending on how tilt is the board, and terminal display the angle and magnitude respect with gravity “g” xy=[ 3]< 0, xz=[ 65]< 0, yz =[ 65]< 0 , where: [magnitude] relative magnitude Angle in degrees*10 from ‐90.0 to 90.0 degrees 5.6.6 Infra Red port Demo (IR demo) Terminal will display a counter and every time the counter increase, the number is transmitted by the IR ...
J7 ON (default OFF) J4 OFF(default ON) Note: remember to re-place jumpers at default configuration once this demo is completed. Type command: K20_Demo >disp 5 IR port: Tx = 002, Rx= 000 ; IR signal is not being received, IR port: Tx = 005, Rx= 005 ; IR signal being received. 5.6.7 FFT Microphone is sampled at 8000Hz, every 128 samples a FFT is performed, the result of the FFT is used for tone detection, first harmonics of FFT are shown with following command Type command: K20_Demo >disp 7 fft[ 1] 0,[ 2] 0,[ 3] 0,[ 4] 0,[ 5] 0,[ 6] 0,[ 7] 0,[ 8] 0, where: XX[n] [n] number of harmonic. XX magnitude of harmonic n. Note: FFT is based on CMSIS library integrated in IAR embedded workbench, because of that this demo is only available with IAR.
Toolchain Support Currently the IAR 6.30 and CW10.2 tool chains are supported. 7.1 IAR Embedded Workbench IAR workspace, project, linker, and support files are provided in kinetis‐sc\build\iar. Each example has its own directory and within that directory is a workspace file (.eww) that will load the supported projects (usually one project for each supported hardware platform). Each project contains several configuration options that can be selected using a drop menu. The configuration support different link targets for different Kinetis memory configurations (e.g. RAM_16KB or FLASH_128KB_PFLASH). 7.2 CodeWarrior 10.2 CodeWarrior 10.2 project files can be found in the kinetis‐sc\build\cw folder. Again, each example has its own directory. Other Examples There are many example projects that highlight the operation of different modules. The "hello_world" demo is the simplest example, and this project is the baseline used for developing other examples. The hello_world project will perform basic initialization for the board and then display the device configuration information on the terminal (default baud rate is 115200). Each example includes a readme.txt file in the workspace or project directory that gives a description of what the project does and describes any configuration needed to use it. Update OSJTAG The TWR‐K20D50M includes the OSJTAG circuit. By default all of the demo projects are setup to use OSJTAG to download and debug code. The OSJTAG circuit is also used as the primary serial communication port. Open Source JTAG (also known as OSBDM on ColdFire tower boards) allows a user to program, debug, and get serial data from Kinetis devices via a USB cable. The firmware runs on a Freescale MCFS08JM60 on the underside of the Kinetis tower board. To ensure compatibility between the drivers, firmware, and terminal window, the latest versions of each need to be installed. ...
Page 11
Make sure your tower board is plugged in, and run the P&E Firmware Updater Utility to use the OSJTAG boot loader to upgrade to the latest OSJTAG version. Under “Select Hardware Type” make sure OSBDM/OSJTAG is selected. It should automatically detect your board settings and fill out the rest of the fields automatically. Click on “Update Firmware” to update the firmware. It will prompt you to disconnect the USB cord from your computer, and then short the JM60 boot loader jumper header. It is J34. Then re‐connect the board to your computer. The firmware will then be updated on your board. When it is finished, it will prompt you again to disconnect the USB cable, remove the jumper, and then re‐connect the board again. OSJTAG is now updated. TWR‐K20D50M Quick Start Demo Lab Guide Page 11 of 23 ...
10 Configure Hardware The hello world example can be run using a TWR‐K20D50M stand‐alone. No other tower boards/components are required for this example. 1) Note that the default jumper settings are in section TWR‐K20D50M Jumper options. If you want to change back to the default settings after you are done running the demo. 2) Connect a mini‐AB USB cable between the TWR board and the USB port on your computer. 3) Allow the PC to automatically configure the OSJTAG drivers used for debugging and the serial‐ to‐USB feature. 11 Launch the Terminal 1) Open the P&E Terminal Utility by clicking on Start Menu‐>Programs‐>P&E Kinetis Tower Toolkit‐ >Utilities‐>Terminal Utility 2) Make sure USB COM is selected with 115200 baud, and click on the “Open Serial Port” button. 12 Development Software and Programming the Board The following instructions describe how to build and flash the hello world demo using CodeWarrior MCU 10.2 or IAR 6.30. 12.1 CodeWarrior for Microcontrollers v10.2 1) Follow the directions in Section 9 to update the OSJTAG firmware and drivers. 2) Install CodeWarrior for Microcontrollers 10.2. ...
Page 13
5) If you already have CW10 open, you can change the workspace by going to File‐>Switch Workspace 6) The first time you open CW10, you will be taken to the Welcome screen. Click on “Go To Workbench” in the lower left hand side. 7) The workbench view will open up. To ensure all the windows are properly set, go to Window‐> Reset Perspective 8) Click on File‐>Import in the menu bar. In the dialog box that comes up, select “Existing Projects into Workspace” under the General folder. Then click Next 9) On the next screen, select the “Select root directory:” option, and click on Browse 10) Navigate to the ..\ kinetis_50MHz_sc\build\cw\hello_world directory and hit OK. 11) Select the projects to import. Then select Finish. TWR‐K20D50M Quick Start Demo Lab Guide Page 13 of 23 ...
Page 14
12) Select the link configuration that you would like to build. 13) Build the project by clicking on the Hammer icon in the toolbar 14) Click Run‐>Debug Configurations… in the menu bar, and select the debug configuration appropriate for the project, build configuration, and hardware connection you are using. For example, if you are building the hello_world project to run from the internal RAM and using TWR‐K20D50M Quick Start Demo Lab Guide Page 14 of 23 ...
Page 15
OSJTAG as your debugger, then you would select the FLASH_OSJTAG configuration. Then hit the debug button in the bottom of the window 15) If this is the first time you’ve used CW10.2 with your board, you may get a dialog box asking to update the OSJTAG firmware. Unplug your board, put a jumper on J34 (JM60 BOOT), and plug the board back in. Hit “OK” on the dialog box, and the board OSJTAG firmware will update. When it is done, unplug the board, remove the jumper on J34, plug the board back in and hit “OK” again on the dialog box. If you do not have a spare jumper, you can temporarily use the one on J7. 16) The code will then be downloaded to the board and the debugger started. This may take a several moments. You may also see the following Warning message: This is a check introduced with a CodeWarrior compiler patch. Hit No to continue flashing the part, as the sample code is configured to ensure the part remains unsecured. 17) Once the code is done flashing, the code will pause at the start of the main() function. 18) Hit the run icon to continue the program execution. 19) On the terminal you should see the hello world message. TWR‐K20D50M Quick Start Demo Lab Guide Page 15 of 23 ...
12.2 IAR Embedded Workbench for ARM 6.30 1) Follow the directions in Section 9 to update the OSJTAG firmware and drivers. 2) Install IAR for ARM v6.30 or higher. 3) Open the workspace at ..\kinetis‐sc\build\iar\hello_world\hello_world.eww 4) Configure flash loader a. Unzip utils\iar_flash_p0_8kb_ram.zip b. Place all of the files in this zip (except this readme file) in your IAR Systems\Embedded Workbench.6.0_x\arm\config\flashloader\Freescale folder c. Open your IAR workspace file and select a flash configuration for the project (you might have to create one if you don't have one already) d. In the project options select Debugger‐>Download e. Check the "Use flash loader(s)" box f. Check the "Override default .board file box" g. Provide the path to the FlashK20Xxxx.board file. Should be: $TOOLKIT_DIR$\config\flashloader\Freescale\FlashK20Xxxx.board TWR‐K20D50M Quick Start Demo Lab Guide Page 16 of 23 ...
5) The project for the board is selected (hello_world_tower) 6) Select the link configuration that you want to build. 7) Compile the project by clicking the Make icon (or right clicking on the project and select “Make”). 8) After compilation completes, download the code to the board and start the debugger by pressing the “Download and Debug” button 9) The code will download, and the debugger screen will come up and pause at the first instruction. Hit the “Go” button to start running. 20) On the terminal you should see the hello world message. 13 Creating New Projects The kinetis‐sc\build\iar\make_new_project.exe or kinetis‐sc\build\cw\make_new_cw_project.exe files can be used to clone the hello_world project for the appropriate toolchain. The script will prompt you for a name to use for the new project, and then create copies of all needed files and folders. Note: kinetis_50MHz_sc\build\cw\make_new_cw_project.exe doesn’t clone the src\hello_world folder.
14 OSJTAG Open Source JTAG (also known as OSBDM on ColdFire tower boards) allows a user to program, debug, and get serial data from Kinetis devices via a USB cable. The firmware runs on a Freescale MCFS08JM60 on the underside of the Kinetis tower board. The latest firmware and drivers can be found at http://pemicro.com/osbdm. See the Installation and Operation document on the P&E website for details on updating the firmware and drivers. If you are having trouble connecting, try updating to the latest drivers, virtual serial toolkit, and firmware located on that website. When the tower board is plugged in, it should enumerate as a composite device, with one driver for debugging, and the other as a serial port. If you go to the Device Manager you should see the following: If you only see it enumerate as the Open Source BDM Debug Port, then your computer may automatically picking up an outdated driver. To fix this, right click on the OSBDM driver and select “Uninstall”. Then unplug and re‐plug in the board, and it should enumerate correctly. If there are still problems with enumerating correctly, you can also manually select the drivers. TWR‐K20D50M Quick Start Demo Lab Guide Page 18 of 23 ...
Page 20
• For the Open Source BDM – Debug Port, use the driver at: C:\pemicro\kinetis_tower_toolkit\Drivers\osbdm\OSJTAG_Debug_Interface_libusb.inf • For the PEMicro USB Serial Port (i1), use the driver at: C:\pemicro\kinetis_tower_toolkit\Drivers\osbdm\OSJTAG_Serial_Interface_windriver_version.inf TWR‐K20D50M Quick Start Demo Lab Guide Page 20 of 23 ...
15 15 TWRK20D50M Jumper options The following is a list of all the jumper options. The default installed jumper settings are shown in bold. Note: Default Configuration, Board powered by OSJTAG USB, RTC powered by PWR_MCU Jumper Jumper Signal Jumper Option designator V_BRD J25 V_BRD DEF: 1‐2 VBRD to MCU_PWR J23 VDDA_HDR DEF: 1‐2 VDDA to MCU_PWR VBAT J35 VBATD Enable VBAT DEF: 1‐2 ...
Page 22
Table 3 Connectors and Pin Usage Module Jumper name Options Signal Designator USB J26 K20 USN ENA DEF: 1‐2 PTC9_EBI_AD6 J32 K20 USB FLGA DEF: 1‐2 PTC8_EBI_AD7/SSI0_CLK IRDA J9 IRDAJ open PTD7_CMT_IRO J7 CMP0_IN0 open PTC7_EBI_AD8/CMP0_IN1 Microphone J16 Microphone Enable DEF: 1‐2 ADC0_DP3 Potentiometer ...
Page 23
Module Jumper name Options Signal Designator PTA12 ‐ J28 PTA12 1 MCU_PWR This header can be used to Header 2 PTA12 power up an external 3 GND circuit/sensor Push Buttons SW2 Pushbutton1 PTC1 PTC1/UART_RTS/FTM0_CH 0/TSI0_CH14 SW3 Pushbutton0 PTC2 PTC2/UART_CTS/FTM0_CH 1/TSI0_CH15 TSI Electrodes Elec1 Electrode1 TSI0_CH0 PTB0/ADC0_SE8/TSI0_CH0 Elec2 Electrode2 ...
Need help?
Do you have a question about the TWR-K20D50M and is the answer not in the manual?
Questions and answers