Rapid Design of TMS320LF2407 Program Based on Matlab

Publisher:RadiantRiverLatest update time:2011-08-09 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

TMS320LF2407 is a high-performance, low-cost DSP processor promoted by TI. Its processing speed reaches 30 MIPS. In addition to the integrated RAM, Flash and timer, it also integrates A/D converter, PWM controller and CAN bus controller modules. It is particularly suitable for control systems with high real-time requirements such as motors and power conversion. However, the usual method of designing DSP programs is to use C language in the DSP integrated development environment CCS, which takes a lot of time to write and input program codes. Designing DSP programs in a graphical way in Matlab can shorten the product development time.

1 Introduction to Embedded Target for T1 C2000 DSP

At present, the new version of Matlab software (Matlab7.O) has integrated the development toolkit of TI's C2000, C5000, and C6000 series DSPs, which can be used to design and simulate DSPs in a graphical way in the Matlab/Simulink environment. And it can directly convert the designed graphic file (.mdl) into a C language program. Among them, the development tool of the C2000 series is EmbeddedTarget for TI C2000 DSP. This toolkit

It is a product jointly developed by TI and Math-Works. The eXpressDSP toolbox is embedded in Matlab/Simulink and supports C24x and C28x series DSP processors. The C24x series DSP toolbox includes modules such as analog/digital conversion (ADC), CAN transmission and reception, and PWM control in DSP processors. Users can call these graphical function modules and other modules in Simulik in Matlab to build a digital signal processing model, and can simulate and verify the model, and then generate TMS320C2000 C language code and CCS project files. After modification and compilation in CCS, they can be downloaded to the DSP target board for operation.

2 Design of ADC conversion and FIR filtering processing program

The following are the steps to design ADC conversion and FIR filtering using the Embedded target for TI C2000 toolkit.

Step 1: In the newly created Simulink file (.mdl), place the LF2407 eZdsp function block in C2000 Target Preferences for parameter initialization. The dialog box settings are shown in Figure 1. The DSP timer clock prescaler can be selected from I to 128, and the corresponding timer sampling time is:
formula

Click to see the original image


Where Timer Period is the maximum clock count period of DSP. LF2407 is a 16-bit fixed-point processor, so the Timer Period is 216-1. The Timer Clock Prescaler value set in Figure 1 is 2. When the operating frequency (CPU Clock Speed) of LF2407 is 40MHz, the sampling time of the fixed-point processor calculated by the above formula is 0.003 2 S. Since data processing requires a certain amount of running time, it is necessary to select an appropriate timer sampling time through experiments.

Setting the Timer Clock Prescaler

Click to see the original image


The functional block for implementing A/D conversion is C24x ADC, and its parameter settings are shown in Figure 2. The A/D conversion channel can select any channel in module A or B, or multiple channels, and the sampling time of A/D conversion is set to 64/80 000.

ADC Design Dialog Box

Click to see the original image

Step 2, design the FIR filter. In the Signal Processing Bloekset of Simulink, put the filter design tool (FDATool1) into the file, double-click the icon, and the filter design dialog box shown in Figure 3 pops up.

In Figure 3, select the filter type as FIR low-pass filter, the sampling frequency is 6kHz, the low-pass frequency is 1kHz, and the cut-off frequency is 2 kHz. First click Design Filter in the dialog box, then click the Realize Model icon in Figure 3 to enter the model realization dialog box, select Over-write generated "filter" block, and a functional block diagram of an FIR filter named "Filter" is generated in the design block diagram. Then delete the FDATool icon originally placed, and connect Filter to the diagram. The completed design is shown in Figure 4.

Filter Design Dialog Box

Click to see the original image


The gain module (Gain) added in Figure 4 is to achieve data type conversion. Since the ADC conversion output is 16-bit integer data, and the filter input requires double-precision floating-point data, the data type parameter (Signal datatypes) of Gain is set to float ("double"). Gainl converts floating-point numbers to integers, so the data type parameter is set to uint (16). The register (C24x To Memory) module is added in Figure 4 to make the design complete. In the generated C program, the output of the gain module Gainl is rth-Gainl, which can be called by other applications.

Step 3, generate C program from the graphic file. In Figure 4, run the Configuration Parameters item under the Simulation menu, the configuration dialog box pops up, select the Real-Time WorkShop item, click the Build button, and the block diagram of Figure 4 is converted into the C language code of TI C2000DSP, and the CCS2 software is automatically called to compile and run the program. The generated C language program includes: interrupt vector file vectors.asm, interrupt service program MW_c24xx_csl.c, ADC conversion control testADC.c, main program TestADC_main.c, etc.

3 Modify and improve the program

The program directly generated by Matlab can realize ADC conversion and digital filtering functions, but there are still some problems in the running process because many default settings are used in the program. In the program generated by the above method, only the timer interrupt is processed in the interrupt handler. When other interrupts are caused by interference signals, the DSP will shut down. Therefore, an invalid interrupt (_nothing) should be defined in the interrupt vector, and an interrupt service program should be added to the interrupt response program. In the modified program, the italic part is the modified code. The modified program is as follows:

Interrupt vector file vectors.asm:

Interrupt vector files vectors

Click to see the original image


Click to see the original image

In the ADC conversion processing program, the DSP sequencer pointer is not reset after each ADC conversion. Although the program is set to perform A/D conversion on only one channel, the result is a cyclic conversion of 16 channels, causing incorrect input data to the digital filter. Therefore, the program needs to be modified. Add in testadc_c:

TestADC_B.C24xADC=MMREGS[RESULT0]>>6; /*A/D conversion result is shifted right by 6 bits*/
MMREGS[ArN2TRL2]=MMREGS[ADCTRL2]l0X4242; /*Reset the sequencer pointer and clear the A/D interrupt flag*/

If you need to output the result through the t/o port, you can define an I/o (portl00) in testadc_c, and then output the FIR filtered data rtb-Gainl. The program is as follows:

The FIR filtered data rtb

Click to see the original image


4 Experimental results and conclusions

The program designed by the above method can run normally on the TMS3201LF2407A processor. The experimental results show that the anti-interference ability of ADC conversion has been significantly improved after the FIR filter is used. The method of quickly establishing the TI DSP model and directly generating the C language program with Matlab simplifies the development of DSP software. The Embedded target for TI C2000 toolbox also contains other tools, such as PWM control, CAN bus control and general I/O control. These tools combined with other tools in Simulink can complete the design of DSP programs with complex functions, and only a small amount of modification is required to achieve the design of functionally correct C language programs, saving program writing and input time.

Reference address:Rapid Design of TMS320LF2407 Program Based on Matlab

Previous article:Design of OSD application platform based on BES7456 chip
Next article:Design of RTAI Kernel Scheduler Based on CBS Algorithm

Latest Industrial Control Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号