Notes about Dsp/bios __ios

Source: Internet
Author: User
Tags case statement memory usage numeric value
These are notes about Dsp/bios, and attention is directed at CCS3.0 and Dsp/bios 5.31.
1. A new platform must be saved as a platforms.tci rather than a special name in the Help document.
2, the thread and interrupt (including soft, hard interrupt) can not use semaphores to communicate information, because the function can not call Sem_pend in the interrupt, the task thread if you want to terminate the operation of the interrupt function, you must call the Hwi_enable, Hwi_ Disable, swi_enable, swi_disable these functions.
3. The main difference between soft interrupts and tasks (task) is that soft interrupts cannot be paused to wait for a condition to be reached and run again. When a soft interrupt is interrupted by a higher priority interrupt, it stops running and is rerun when needed, and the task is usually run in a loop and allowed to hang.
4. Soft interrupts are triggered by related functions, such as swi_post ().
5, can not call Dsp/bios defined mod_f_ This type of function, such as CLK_F_ISR, because they can only be defined as a variable.
6, the user can not define the Mod_, mod_f the beginning of the variable and function name, which is reserved by the system.
7. Objects (object) in the program using Dsp/bios defined Module (module), to be described using extern, for example: extern log_obj trace
8, in the program must include <program>.cfg.h this header file, which is automatically generated by the Dsp/bios related C header files.
9. Statically defined objects (object) cannot be purged using functions such as xxx_delete ().
10. The vast majority of the xxx_create () function receives the last argument xxx_attrs (note the case of the letter) as the property of its newly defined object, which is set according to the default property when it is empty.
11, you can use a _main function in the assembly file of the project to replace the Mian () function in C file.
12.-U _symbol (for example, –u _malloc) notifies the connector to use the Dsp/bios library instead of running the function in the support library (run Time library).
13, in assembly language,. ASG is similar to. Set usage, the difference is. Set is defined as a constant (and can no longer be redefined), and. ASG is a variable that sets a string (including constants) as a substitute for it.
14. Because the main () function does not interrupt, it can be used to make certain interrupts alone, but not hwi_enable () to break all.
15, for C5500 series DSP, allows the software to rewrite the interrupt vector table starting address through IVPD and ivph two registers. To do this, you must write the appropriate address values to both registers and then start the software (software reset) after the hardware startup (hardware reset). 1, for the C5500 series of DSP, there are three stack modes to choose from: C54x_tsk (default mode), Use_reta, No_reta. If you do not use the default mode, you must correctly configure the 28th, 29 bits of the boot vector (reset vector) through the CCS compilation tool. When to use which mode.
2. x can force the connector (linker) to find the library file again to find the function that was not found for the first time. For example, the new () and delete () functions in C + + are not supported by the Dsp/bios library and may produce a connection error when used, and you can use the-X option to avoid this error.
3. For c55x and C6X series DSP, all user functions invoked by the Dsp/bios are subject to their relevant C compiler register rules, whether using C or assembler to write these functions.
4, because the main () function is executed when the Dsp/bios is not fully initialized, so there is a considerable part of the main () function Dsp/bios API functions can not be invoked.
The initialization of Dsp/bios is composed of Dsp_init and Dsp_start, running Dsp_init before running the main () function, and then running Dsp_start.
Therefore, the modules in the Dsp_start initialization, such as interrupts, timers, scheduling (schdulers) and other modules of the related functions can not be used in main (), and memory management is initialized in the dsp_init can, for example, dynamic allocation of memory (mem_ Alloc, Mem_free), dynamically generate and Delete module objects (Tsk_create, Tsk_delete).
5, you can optimize the code volume and execution speed by not enabling the GBL module's global properties "Enable real time analysis".
6, the Log object's LogType attribute divides into: fixed (fix) and circular (circulate) two kinds, in which, fixed means that when the log object's buffer stores full data then stops continues to store Circular means that when the log object's buffer is fully stored, the previous content is automatically overwritten, and the result is that the data stored by the fixed object is the first data and the circular object stores the data as the last object.
7, the log object's buffer size can be modified according to the use needs. For example, using log_printf if the display is fast enough, the log object buffer will not cause the display of the left side of the loss of the label can be appropriate to change the small buffer.
8, in the use of Dsp/bios architecture of the DSP project, the CPU in the work performed is one of the following operations:
1 Hardware Interrupt Service Program
2 software interruption service or cycle function program
3 Tasks (Task) function
4 user-defined functions when idle loops
5 transmit data to host via HST Channel
6 Transfer real-time analysis data to the Dsp/bios Analysis tool 1, you can track the number of times it is triggered by defining a monitoring variable for a hardware interrupt. Dsp/bios automatically defines an STS object for each hardware interrupt.
2, in addition to the observation of hardware interrupts and stack pointers, you can also observe any one of the registers and variables when the hardware is interrupted. Static objects are updated every time a hard interrupt occurs, which consumes 20 to 30 instruction cycles.
3, observe the allocation of the stack is beyond the method:
1 in any one of the hardware interrupt function settings, enable implicit instrumentation.
2 in the Hwi module, select the object for the interrupt, and set its properties to Sts_delta (*ADDR).
3 Locate the interrupt-related object in the STS module and set its "Prev" property to "0xBEEF" (5000 and 2800 series DSP).
4 Load and run the program, use statistics view to see the property changes.
5 any event that exceeds the stack causes the object to appear with a value other than 0.
4, can be set to observe the delay of the timer interrupt, that is, interrupt trigger flag to enable the first interruption of the execution time between the instructions, specific settings see spru423f p84,5500 series DSP because its timer access is not in the data storage space, so can not observe.
5. Kernel Object view does not automatically update through a idle thread, and its contents must be updated either at the breakpoint or by a right key refresh.
6. The MEM option in Kernel Object view is primarily a display of heap properties. spru423f P93
7, Madu:minimum addressable data unit, for the C5000 series of DSP is 16bit Word.
8. The DSP software system based on Dsp/bios architecture includes 4 threads: Hardware interrupts (HWI, including clock functions), software interrupts (SWI, including periodic (PRD) functions), Tasks (Task), and background functions (IDL).
9. Software interrupts should be used to manage 100ms or events that require more time.
10, the choice of various threads rules:
1 hwi should be used in response function time is less than 5ms, and if not timely response, its related data may be lost situation; SWI and tsk should be used in response to a function time of 100ms or so.
2 for the relationship between the thread simple use of SWI, more complex use of tsk. Tsk can be suspended and SWI not; SWI is more efficient at using a separate stack relative to tsk memory usage. The data used by SWI must be ready before it is run, and it can be notified by the SWI object's mailbox.
3 IDL function is run when the system does not use CPU.
4) The CLK function is triggered directly using a timer interrupt. The basic CLK function: Prd_clock generates a tick for the periodic function, and the user can increase the clock function that runs at the same frequency. Because these functions are handled as HWI, you must minimize the elapsed time.
The PRD function is treated as SWI, and all PRD functions have the same SWI Priority 1, which can be prevented from running by functions such as hwi_disable, Swi_disable, tsk_disable, and when the current highest-priority thread is a task, If this task is blocked (block), then other threads will be prevented from running.
2. When using the Hwi object, if the interrupt handler function is written in C, you must not use the Interrupt keyword or interrupt pragma, because the function called by the Hwi object already contains these functions.
3. In SWI and tsk, you can disable and enable/hwi_restore of interrupt functions by calling hwi_disable () and Hwi_enable () Hwi (). These functions control global interrupts by manipulating the INTM bit. The hwi_enable () function is to enable global interrupts, and the Hwi_restore () function loads the value before the call to Hwi_disable ().
4. When the HWI is produced, it needs to be protected from the possible changes that it uses before executing its ISR, and the values should be filled back when returned. Dsp/bios provides hwi_enter and Hwi_exit macros to accomplish both functions.
When you use the C language to write an ISR program, you can use "Hwi dispatcher" to automatically complete these two steps by Dsp/bios setting the properties of its Hwi object, or you can call Hwi_enter and Hwi_exit macros in your own program to accomplish these two functions.
5, in the Dsp/bios architecture, if you do not use HWI dispatcher when processing interrupts, you should call the interrupt handler function before and after the call Hwi_enter and hwi_exit for related processing. (spru423f example 4-3, 4-4, 4-5)
6, soft interrupt (SWI) and based on some types of SWI instructions is not the same, Dsp/bios SWI interrupt is not related to the type of DSP. SWI interrupts are triggered by functions such as swi_post. SWI is suitable for tasks that occur at a low frequency or are less than HWI interrupts for real-time requirements. 1, SWI can be by: SWI_ANDN
Swi_dec
Swi_inc
Swi_or
Swi_post
These functions are triggered.
2, can trigger a SWI in Hwi, this SWI either between Hwi_enter and Hwi_exit, or by Hwi_dispather call.
3, each SWI can have two variables.
4, dynamic definition of SWI (call swi_create function) can only be at the task level, but not in Hwi and SWI.
5, the SWI priority level 0 lowest, 14 class highest.
6. The system stack saves the contents of the registers that need to be saved every time the SWI occurs, each additional level of SWI priority is allocated a portion of the memory, so the most efficient use of memory is to set all SWI to the same priority, but this is not possible, Therefore, you should try to set fewer SWI priorities to ensure that the system stack is reduced in size.
The default system stack size is 256words and can be changed by setting the properties of mem in a. tcf file (right-click), and the estimated size of the system stack is displayed in the status bar at the top of the. tcf file.
7, if the Tsk manager is enabled, then in the SWI module there will be KNL_SWI objects to manage tasks, and Knl_swi SWI priority is the lowest: level 0, other SWI objects can not be set to this lowest priority (level 0).
8, the same priority of the SWI to run the order is not set.
9. When a SWI ISR program is removed from the response list, Its mailbox value is reset to the initial value (that is, in the. The value set in TCF); If a SWI ISR program is triggered at run time, the value of the SWI mailbox is set to the trigger-related value, but does not affect the currently running program, including the call to the Swi_ The return value when Getmbox ().
This means that a SWI ISR program can update its mailbox value when it is not complete. 1, the trigger SWI API functions have different functions:
1 if SWI's ISR function must respond to each trigger, whether or not it is running, use the Swi_inc function.
2) Swi_andn (&swihandle, data) can verify that some bits of the data of its parameters are "1", and then run the ISR function.
3) Swi_or (&swihandle, data) directly triggers the ISR function and invokes the Swi_getmbox () function in the ISR program to get the data value, Depending on the numeric value of the data, you can use the Switch-case statement to run different program branches, and note that you will not be able to run the correct program branch until you set the mailbox parameter in the Swi property to 0 in the settings.
4 If you need to set an event to trigger a SWI ISR function, you can call the Swi_dec () function, at which point the module in SWI sets its "Mailbox" property to the number of times it needs to be repeated, and the number is reduced by 1 per call to the Swi_dec () function. When you reduce to 0, run the ISR function.
2, the use of SWI benefits:
1 can be run when all HWI are enabled.
For example, to define a shared data structure in a hwi, it is prohibited to change it in a task first, which will affect the real-time nature of the system, and if the structure is defined in a SWI, this is not a problem. Typically, an ISR is divided into two parts, which need to be strictly adhered to in the hwi, and not so rigidly placed in the SWI.
2 SWI can call some functions and HWI cannot.
Because the SWI is not running when Dsp/bios updates its internal data structure. You must be familiar with restricting which functions can be invoked in HWI and which can only be invoked in SWI. Functions callable by Tasks, SWI handlers, or hardware ISRs in the TMS320 dsp/bios API Reference Guide for your platform T The hat lists Dsp/bios functions and the threads from which each function can be called.
SWI can invoke any API function that is not blocked, any functions that can be blocked and functions that call such functions cannot be called by SWI.
3, when a SWI interrupts another thread, Dsp/bios will automatically save the majority of the value of the register, so whether the use of C or assembly to write ISR programs are no longer save these registers, of course, The safest way to do this is to save the unsaved registers when using the assembly (AR1, AR6, and AR7 for c54x). For HWI, you must use Hwi_enter and Hwi_exit or Hwi dispatcher to save these values.
Note:
An important side effect the swi_disable is this task preemption is also
Disabled. This is because Dsp/bios uses software interrupts internally to
Manage semaphores and clock ticks.
4. Each task has its own stack to hold its local variables. You can specify the size of its stack in the object's properties.
5, contains semaphore, mailbox and other resources of the task can not be released, or will cause errors. You should release these resources before releasing the task that contains them.
6. For c55x Dsp/bios, the average memory assigned to a task is distributed to both the system and the user.
7. If you want a task to be initialized and then run until it is needed, you can set its priority to-1, and then change it in the program.
8. When a task is in terminate state, it is no longer running.
9, a task will occupy the part of another task when its allocated stack is not big enough, which can lead to fatal errors, so you can use Tsk_ceckstacks and tsk_stat to test the stack size of the task.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.