Introduction to DSP-BIOS, dsp-bios

Source: Internet
Author: User

Introduction to DSP-BIOS, dsp-bios
Build the first project from the environment perspective

Please note that by default, the reader has a certain understanding of the DSP and CCS V3.3 environments, knows the configuration of the cmd file, knows how to create a project, compile and connect to the simulator for download! If you are not familiar with these items, please familiarize yourself with them first! Of course, it is best to have the basic concepts of the Operating System-tasks, scheduling, and interruptions!

  1. The first question: What is DSP/BIOS (well, we usually write it like this?

    It is an embedded real-time operating system developed by TI for DSPs. Since it was developed by TI for its own DSP, the performance is of course excellent (of course, I am still getting started, and I have no practical experience ). When it comes to real-time operating systems, what other embedded real-time operating systems? Is it true in Linux-no, VxWorks-Yes, oh, there is also a small open-source system-uCOS II.

  2. Question 2: What environment should I install to use DSP/BIOS?

    This article is for CCS v3.3. The DSP/BIOS is installed by default, and the version is V5.31.2.Help->About...Menu view version ). Of course, if you need other versions (you can install multiple versions at the same time), you can download them from the TI official website. Link:

    Http://software-dl.ti.com/dsps/dsps_public_sw/sdo_sb/targetcontent/bios/dspbios/index.html

    Note: compatibility exists between the DSP processor model, the CCS version, and the DSP/BIOS version!

    Download the package and install it in the directory where the CCS is located.Help->About...Select the BIOS version for the Manager!

    This document uses the default DSP/BIOS version of CCS V3.3, namely V5.31.2. The example in this article runs in the simulation mode of TI's CCS 3.3 software. The simulation environment is configured as follows (using the C6713 processor for simulation ):

  3. Question 3: How to build the first BIOS project?

    Create a common project first,Project->New..., As follows:

    File->New->DSP/BIOS Configuration...Create a DSP/BIOS configuration file,

    Save the configuration file with the suffix *. tcf.

    Add the configuration file and the cmd file automatically generated by the configuration file to the project,

    Create a new main. c file, add main. c to the project (always forget this file and find problems everywhere), and write the simplest code,

    int main(void){    return 0;}

    Compile the project and the following error occurs:

    js: "./bios_first.tcf", line 11: Heaps are enabled, but the segment for DSP/BIOS Objects (MEM.BIOSOBJSEG) is not set correctly. Please create a heap in one of your data segments and set MEM.BIOSOBJSEG to it.

    It doesn't matter. In the next section, we will see how to remove this error!

DSP/BIOS configuration method
  1. System Configuration

    Right-click Global Setting and set the DSP target board clock, CLKOUT clock, and size-end mode.

    The Call User Init Function option is enabled by default. If an object target board is connected, in this case, it is best to set a function for the user to initialize the code of the PLL and EMIF (for the code of the PLL initialization, refer to other C6713 projects ). Otherwise, in software simulation mode, this option can be removed to avoid many errors during running.

    Configure the SDRAM and heap size,

    Now you can recompile the project. Congratulations! The compilation is successful! The heap error is resolved here!

    Now, you need to divide the storage space of the SDRAM according to your needs (that is, if you did not use the operating system before writing the cmd file, the division here will automatically generate or modify the cmd file ). It is very convenient to use DSP/BIOS, right-click on MEMInsert MEMYou can insert partitions! This function is similar to the MEMORY function in cmd,

    MEMORY{    BOOT_RAM: o=00000000h,l=00000400h       IRAM    : o=00000400h,l=0003FC00h    /* CE2: SDRM 256Mbit */    SDRAM:  o = 80000000h,l=01000000h  /* 128Mbit */    GB_MEM: o = 81000000h,l=01000000h  /* 128Mbit */     /* Flash */    FLASH_BOOT : o=90000000h,l=00000400h    FLASH_REST : o=90000400h,l=000FFB00h }
  2. LOG Configuration

    The LOG function is used to implement printf, and STS is used to capture the Count value of any object.

    Right-click LOGInsert LOG, Insert a Print Object of the trace,

    Write the following code in main. c,

    # Include "bios_firstcfg.h" // Automatic Generation of DSP/BIOS, which can be found in the project, including the trace Declaration and the header file containing int main (void) {LOG_enable (& trace); LOG_printf (& trace, "Hello DSP/BIOS % d. ", 0); return 0 ;}

    Load the program after compilation, and open the menuDSP/BIOS->Message Log, Run the program effect,

    Note: The above program uses the LOG_printf function instead of printf to print messages. Other LOG-related functions include,

    LOG_disable. Disable the system log.LOG_enable. Enable the system log.LOG_error. Write a user error event to the system log.LOG_event. Append unformatted message to message log.LOG_event5. Append 5-argument unformatted message to log.LOG_message. Write a user message event to the system log.LOG_printf. Append formatted message to message log.LOG_printf4. Append 4-argument formatted message to log.LOG_reset. Reset the system log.

    Okay, this is the 1st Module-LOG Module we have learned about DSP/BIOS.

    In fact, there are many modules in DSP/BIOS. Refer to the TI document SPRU430S: TMS320C6000 DSP/BIOS 5.x Application Programming Interface (API) Reference Guide.

  3. Task module configuration

    The most basic operating system is the task. Let's take a look at the task first! Create two tasks, right-click the task function name ,,

    Make the same configuration for TSK_task1. Note that the Task function must be underlined before the C function!

    Add the code of two tasks to the main function,

    Void func_task0 (void) // corresponds to the previous _ func_task0 {static Uint16 TSK0 = 0; while (1) {// tasks generally have an endless loop, it is of little significance to execute only one task LOG_printf (& trace, "TSK0 = % u", TSK0 ++); TSK_yield () ;}} void func_task1 (void) // corresponds to the previous _ func_task1 {static Uint16 TSK1 = 0; while (1) {LOG_printf (& trace, "TSK1 = % u", TSK1 ++ ); TSK_yield ();}}

    Re-compile and load. After running, you can see the following results in the Message Log window:

    Operating system tasks are in an endless loop structure. To implement task scheduling, each task must have idle time. You may comment out TSK_yield () in the above Code and re-compile and load the task, at this time, the program will be executed in func_task0 all the time.

    TSK_yield is used to schedule tasks with the same priority to other tasks with the same priority!

    The TSK module has many attributes. In addition to setting function names, you can also set priorities and input parameters! There are also many scheduling functions. Another common method is to use the sleep scheduling function-TSK_sleep, which uses the following:

    Void func_task (void) {while (1) {// processing code TSK_sleep (100); // 100 indicates the system clock count }}
  4. Soft Interrupt SWI module configuration

    Interruptions have a higher priority than any task, and hardware interruptions (HWI) have a higher priority than software interruptions (SWI.

    The Soft Interrupt mailbox is not a message mailbox in the signal, but the mechanism is similar. The above value is the reset value of the Soft Interrupt mailbox!

    Once the Soft Interrupt mailbox value reaches 0, the software interruption is triggered, and the next execution is completed (unless interrupted by hardware). After the execution, the Soft Interrupt mailbox is restored to the reset value! Because the execution is completed once, unlike the task, there will never be an endless loop in the Soft Interrupt (otherwise, the Soft Interrupt will always be executed and the task will not be executed )!

    Next, complete the content of the Soft Interrupt function: Task 1 is executed twice, triggering a Soft Interrupt. The Soft Interrupt Count value is + 1.

    Void func_task1 (void) // corresponds to _ func_task1 {static Uint16 TSK1 = 0; while (1) {LOG_printf (& trace, "TSK1 = % u ", TSK1 ++); SWI_dec (& ADC_swi); // decrease the count of the Soft Interrupt mailbox; TSK_yield () ;}} void swi_adc (void) {static Uint16 adc_cnt = 0; LOG_printf (& trace, "SWI_ADC = % u", adc_cnt ++); // after one execution, the mailbox value is restored to the initial value 2}

    The SWI_dec () function is used to modify the Count value of the Soft Interrupt mailbox. Other functions for the Soft Interrupt mailbox operation include:

    Void SWI_or (swi, mask); // perform or operate on the mailbox value and mask. When the value is 0, the Soft Interrupt SWI_Handle swi is triggered;/* SWI object handle */Uns mask; /* value to be ORed */void SWI_andn (swi, mask); // If the mailbox value is 0 and the value is not the same as that of the mask, the Soft Interrupt SWI_Handle swi is triggered; /* SWI object handle */Uns mask/* inverse value to be ANDed */void SWI_inc (swi); // Increment SWI's mailbox value and post the SWISWI_Handle swi; /* SWI object handle */void SWI_dec (swi); // Decrement SWI's mailbox value and post if mailbox becomes 0SWI_Handle swi;/* SWI object handle */

    The DSP Soft Interrupt mailbox of the 6000 series is 32-bit, And the DSP Soft Interrupt mailbox of the 2000 series is 16-bit. The following is a comparison diagram of the Soft Interrupt mailbox function captured from Liu xinmao's DSP/BIOS lecture PPT and the change process diagram of the mailbox value during operation:

  5. Semaphore SEM module configuration

    Semaphores are divided into mutex semaphores and count semaphores. mutex semaphores have only two States: they can be used for unavailability. A count semaphores set a Count value. If the Count value is greater than 0, the task is not blocked when requesting the semaphore.

    Program writing: Now the task is executed twice for a Soft Interrupt. Here, the initial semaphore value is set to 1, and SEM_pend is used in task0 to wait for the semaphore. task0 enters the waiting state once after being executed once, enter Soft Interrupt. In Soft Interrupt, use SEM_post to publish the semaphores. The signal value increases by 1. After task0 receives the semaphores, it returns from the waiting status and continues execution!

    Status = SEM_pend (sem, timeout); SEM_Handle sem;/* semaphore object handle */Uns timeout;/* return after this variable system clock ticks */return Value: Bool status; /* TRUE if successful, FALSE if timeout */

    If timeout is set to 0, the system does not wait for execution. SYS_FOREVER means that the system waits until the semaphore value is greater than 0. The SEM_post () function is relatively simple.

  6. Input and Output-real-time data exchange module configuration

    I don't know. In software simulation mode, the following warning box will always pop up when I Load the program,

    This is because the RTDX module is not configured. Right-click the input and output RTDX module and configure it as follows,

    After the configuration is complete, re-compile it. The warning box will not pop up during Load!

Summary: in fact, as shown above, there are still many DSP/BIOS modules. The above is just a few of the more common ones, in the aspect of optical signal synchronization, there are also Message mailboxes and message queues. The functions and function definitions of these modules can also be understood.

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.