The development of TMS320C32 can be done in assembly language or C language. The advantage of using assembly language is that it runs fast and can fully utilize the hardware features of the chip, but the development speed is slow and the program is poorly readable. The advantage of C language is that it is easy to program, fast to debug, and readable, which can be greatly shortened. Development cycle, but C language can not operate on its on-chip special function registers without mapped addresses, such as IF and IE, AR0 ~ AR7. The interrupt programming and BOOT files in the C language environment (when the TMS320C32 works in the microcomputer mode, the program is stored in the off-chip EPROM) are different from the assembly language. In view of these characteristics of TMS320C32, the author puts forward a C language-based interrupt programming method and BOOT function implementation, and has been applied in real-time data acquisition and signal processing systems.
1 TMS320C32 interrupt and interrupt (including trap) vector table In TMS320C3X series DSP, TMS320C30 and TMS320C31 have an address-fixed interrupt-trap vector table, but for TMS320C32, the interrupt vector table can be relocated according to users' own needs. of. The first pointer of the interrupt-trap vector table is ITTP (the Interrupt-trap Table Pointer), which is composed of 31 to 16 bits of the interrupt flag register IF. The pointer is shifted to the left by 8 bits (zero shift in) to form the table header base address EA (ITTP) of the interrupt-trap vector table, as shown in FIG.
Therefore, the interrupted or trapped vector address consists of the table header base address EA(ITTP) + table header offset. For example, if the value of ITTP is 8801H, then EA(ITTP)=880100H, then the interrupt vector of the serial port is located in the storage space of address 880105H. It should be noted that the space stores the entry address of the interrupt or trap service program, instead of storing the first statement of the interrupt service routine like the 8031 ​​series microcontroller. Therefore, when an interrupt occurs, the CPU searches for the corresponding interrupt vector according to the value of EA (ITTP), and then jumps to the corresponding interrupt (trap) service subroutine until the end of the program. Need to pay special attention to, because for TMS320C32, there are 24 address lines, the addressing space is 16M, and ITTP accounts for 16 bits, so the interrupt table header offset can only be 8 bits, so the entire interrupt vector table The length will not exceed 256 words.
2 T language development of TMS320C32 The development of TMS320C32 is supported by a complete set of hardware and software development tools, including C programmer, assembler and linker. In the development process, first use the text editor to write your own C language source program, and then automatically translate the C language source program into the DSP assembly source program through the C programmer. After the source code of the assembly language is obtained, the COFF object file (*.OBJ file) can be generated by the assembler command, and then the document manager can be used to combine one or more OBJ files into one object file library, or directly in the link command. Use an OBJ file. After the link is completed, an executable COFF (*.out) file is generated. At this time, the program can be downloaded to the user's own target system through the JTAG interface by means of hardware development tools, and then debugged by means of software development and debugging tools. program. After the program has fully met the requirements, the executable COFF file (*.OUT file) can be converted to other file formats by means of the hexadecimal conversion program provided by TI, such as INEX HEX format, TEKTRONIX file format, TI-TAGGED File format or direct ASCII-HEX format, etc., in order to write the program to EPROM, because most EPROM programmers do not accept COFF file format. The C compiler compiles a C language program to generate six relocatable code and data blocks that can be allocated to memory in different ways to meet the requirements of different system configurations. These six blocks can be divided into two types: initialized blocks and uninitialized blocks. Initialized mainly includes data tables and executable code. The C compiler creates three initialized blocks: .text blocks (including executable code and strings), .cinit blocks (including initialization variables and constant tables), and .const blocks (strings and .swith tables). The uninitialized block is used to reserve memory space, which is used by the program to create and store variables. The C compiler creates three uninitialized blocks: a .bss block (used to hold global and static variable spaces) and a .stack block (which allocates memory for the system stack) and a .system block (which allocates storage for dynamic memory functions).
Since all interrupts are invalid after a hardware reset, if the interrupt function is required in the system, the corresponding interrupt must be processed accordingly. Since there is no special C statement to enable or block the interrupt, the ASM statement must be embedded. The C interrupt program uses a special function name in the format c_intnn, where nn represents a two-digit number between 00 and 99; the function names c_int01 to c_int99 are user-usable, and c_int00 is a special function, which is a C program. The entry point is reserved for system reset interrupts and is used for system initialization and calling the main function. This function is included in the runtime support library and must be linked to other C target modules. When linking, using the -CR option and including RTS30.LIB, c_int00 is automatically accessed. When linking a C program, the linker sets the entry point of the executable module to c_int00.


3 Program design example This program adopts the timer interrupt mode to retrieve the 0x810050 port, control the LED tube of the external driver to flash, and run the AD sampling subroutine to collect data. Due to space limitations, the sampling subroutine is not detailed, and the user can write it as needed. The specific procedure is as follows: /*led ioport address 810050h,810040H-81005FH.*/ #define vec_addr (volaTIle int)0x880100; /*Define the interrupt vector table header */ void c_int09(); /*Declare interrupt handler function*/ volaTIle Int *io_in = (volatile int *)0x810050; /* defines the LED interface address pointer * / volatile int *io_add = (volatile int *) 0x808000; / * defines the C32 control register table table header * / volatile int * intvec = (volatile Int *)0x880100; /* interrupt vector table table first pointer */ main() { asm("ldi 8801h,r0"); /*8801H send R0*/ asm("lsh 16,r0"); /*left shift 16 bits, becomes 88010000H*/ asm("ldi r0,if"); /*88010000H sends IF, locates the interrupt vector table, and clears all interrupt flags*/ io_add[0x28] = 0x3ffff; /* gives timer 0 cycles Register assignment */ io_add[0x20] = 0x301; /*Set the timer's control register */ intvec[9]=(volatile int)c_int09; /*Set the timer interrupt vector*/ asm("or 300h,ie") ; / * Enable timer interrupt * / * io_in = 0x00; / * LED control port initial value, LED bright * / io_add [0x20] = 0x3c1; / * start timer * / asm (" or 2000h, st" ); /* global interrupt Can */ for(;;); /*wait for interrupt*/ } void c_int09() { *io_in = ~(*io_in); /* is inverted, LED flashes */ ad_convert(); /* User's sampling subroutine */ } When using ASM embedded statements, be aware that there should be spaces or a certain amount of indentation after booting, otherwise the compiler will treat the instructions as labels and compile errors; at the same time, compile the control with -V32 instead of - V30, otherwise the linker will link the files according to other models of TMS320C3X instead of TMS320C32, so the generated BOOT files cannot be run under TMS320C32.
4 BOOT function realization After the program debugging is completed, the final COFF executable file can be made into a hexadecimal BOOT file that can be written into the EPROM. This can be achieved by the file conversion program HEX30. This article uses a one-step conversion method, the command behavior "HEX30 mych.cmd", and then the conversion program itself can generate the files that the user needs according to each option. In the system designed by the author, 8K%26; #215; 8 EEPROM, parallel boot mode, boot from 1000H, so strb0 as BOOT strobe signal, pin INT) should be low. The list of Mych.cmd files is as follows: /****************************************** ******* /*mych.cmd file list */ /********************************* ***************/ myc.out /* input file name */ -a /* output file in ASCII format */ -memwidth 8 /* system memory width */ -image / * Output file is removed from the address map * / -zero / * unused is filled with 0 * / -e 0x881029 / * The start address of the program execution after the boot succeeds * / -bootorg 1000h / * Boot from 1000H * / - iostrb 0F8h /*Configure iostrb*/ -strb0 0x000F10F8 /*Configure strb0*/ -strb1 0x000010F8 /*Configure strb1*/ ROMS { EPROM: org=001000h, len=02000h, romwidth=8, /*8K%26;#215;8 EPROM*/ files={myc.hex} /*output file name*/ } SECTIONS { .text:BOOT .data:BOOT .cinit: BOOT .const:BOOT /* Each file block is located in the BOOT area*/ } Requires special There are two points in the description. One is the choice of memwidth and romwidth, which will directly affect the number of output files. If romwidth=8 and menuwidth=16, then there should be two output files, and the circuit design should use two EPROMs. If the two are equal, then the number of output files is only one, that is, the number of files = memwidth / romwidth. The second is the address selection after the -E option. This address is the address entry that the program starts executing after the system boots successfully. It can be obtained from the myc.map file generated after the link. In this design, the list of myc.map is as follows (where the address 881029 corresponding to _cint00 is the required entry address): ********************* *********************************** TMS320C3x/4x COFF Linker Version 5.11 ******** ************************************************ >> Linked Mon Jun 3 10:40:36 2002 OUTPUT FILE NAME: ENTRY POINT SYMBOL: "_c_int00"address MEMORY CONFIGURATION ......
Due to some conversion methods, the BOOT function in the C environment is completed. This example is completely capable of running independently and has been applied to the data acquisition system and has received good results.

Cat 6 Network Cable

Cat 6 Network Cable,UTP Cat 6 Network Cable,Slim Cat 6 Network Cable,Flat Cat 6 Network Cable

Shenzhen Hongyan Wire Industry Co., Ltd. , https://www.hy-cable.com