This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

DSP BIOS: Adding a PRD function via code. Not from TCF file

 

Hi,

I am trying to add a function in my code instead of adding it via the PRD function manager. Here is what I want if I were to add this function via the tcf file.

 

Currently in TCF file:

 bios.PRD.create("PRD_TestPrdFn");
 bios.PRD.instance("PRD_TestPrdFn").order = 1;
 bios.PRD.instance("PRD_TestPrdFn").comment = "TestPrdFn Simulator";
 bios.PRD.instance("PRD_TestPrdFn").fxn = prog.extern("PRD_ActualFn")
 bios.PRD.instance("PRD_TestPrdFn").period = 1;
 bios.PRD.instance("PRD_TestPrdFn").mode = "continuous";

 

void PRD_ActualFn()

{

// come here every 1ms

}

How would I get the same functionality if I want to add the above function via the code in a .c file and where should I put the code? Like in main()??

Thanks,

  • DSP/BIOS exists to save you a lot of work coming up with your own O/S-type functionality. Implementing this periodic function is as easy as what you show above. Although there is some processing overhead and some program space requirements for using DSP/BIOS, the tradeoff is usually pretty clear that DSP/BIOS makes the job easier and quicker and therefore more cost-effective.

    To duplicate the functionality of DSP/BIOS yourself, you will need to do at least the following:

    - Select, then configure, a timer resource that can generate a CPU interrupt continuously at the period you desire.
    - Configure the Interrupt Controller and interrupt path to the CPU
    - Write your C function with the "interrupt" keyword to handle context switching and the proper return.
    - Write or find a vectors.asm or similar file to implement the interrupt vector branch table.

    I may have missed a step or two. Further information on these steps will be in the various documents, like the Optimizing C-Compiler UG, Assembly Language Tools UG, Timer UG, Interrupt Controller UG, and the datasheet.

    This will interrupt a direct hardware interrupt for your periodic function, rather than a Software Interrupt (SWI) like the PRD function would implement.

  •  

    Randy P,

    Thanks for the response. I guess I thought you could some how access the "bios" object from my C Code, but I guess you cannot.

    Regards,

    Budda

  • I believe I misunderstood your original question. The easier answer would have been "no". That is, I now believe you wanted to have a PRD_create() function that would allow you to create a periodic function that uses the DSP/BIOS functionality without statically defining the PRD function in the tcf file.

    For tasks there is TSK_create() and for semaphores there is SEM_create() and the same for some other DSP/BIOS objects. But there is not a PRD_create() to allow this same type of functionality.

    Another suggestion, if it is very important for your application, would be to create a single PRD function that runs at a 1 tick rate, then create your own list of PRD functions in a linked list (function ptr, rate, current count, next) and handle the variable list of PRD functions yourself.

    To the best of my knowledge, DSP/BIOS does not provide a way to do this.