I'm using PRD module as period 1ms and I want to change it to 0.5ms in code during rutime without using DSP/BIOS Graphical Editor.
Does anyone know how?
Thanks
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.
Hi,
I have the same question as you mentioned above.
Do you have some ideas to solve this problem?
Sincerely.
lex
In my case, I needed only two periods(1ms/0.5ms)
so i made two PRD modules, whose periods are 1ms and 0.5ms, and those two PRD modules do same thing.
and i stop a useless PRD module using "PRD_stop" function.
Hi Quote,
I also have made three PRD modules such as PRD0, PRD1, PRD2, but how to call every PRD module from main?
My PRD modules also do the same thing while some parameters differs.
And in main I set some parameters to call PRD0, how can this realize?
Waiting your reply urgently!
lex
Hi Quote,
PRD_stop function is used to stop a period object that has its mode property set to one-shot in the configuration.-->from BIOS 5.x API Ref Guide.
If my PRD function has set to continuous mode , how to call several PRD functions from main?
Sincerely.
lex
Hi Lex --
Let's use this thread to work this issue. I closed the other 2 threads. It's OK to open new threads for new topics in the future, but let's use this thread until this is resolved.
Just to summarize a few things:
The PRD module is fairly simple. It simply runs functions at the specified rate. You can only create PRD objects via the configuration tool. You cannot create them in .c code. You can start and stop them at runtime using PRD_start() and PRD_stop(). You cannot change their rates or mode (one-shot or periodic) at runtime. These restrictions help keep PRD small and fast for the simple use cases while unfortunately making it harder to do things like what you're trying to do.
The CLK frequency is specified in the configuration and typically cannot be changed. On some devices that support changing frequency of the CPU at runtime, and where the CLK input source is tied to the CPU frequency, it is possible to use CLK_reconfig() to reconfigure the CLK to matech the new CPU frequency. Check the 'CLK_reconfig' API for an example. Which device are you using?
I think your best solution would be to set up your PRD module at the fastest rate that you want (say 0.5ms) and then have a single function called at that rate. Then, you can maintain a data structure and/or simple code of your own to manage when your multiple/specific functions should be called. If you want to change the period of these functions, then change some variables on your side to adjust their periods as you need. Then, you can manage the functions to call (and when) via your own .c function.
Regards,
-Karl-
Hi Karl,
My board is OMAP-L138. What I want to do is to build several CLK.MICROSECONDS/Int = 100, CLK.MICROSECONDS/Int = 300, or CLK.MICROSECONDS/Int = 1000. I want to configure CLK.MICROSECONDS/Int in .c code.
My code is:
void main()
{
GBL_setFrequency(CPUFrequency in KHz);
CLK_reconfig();
}
Is it correct? And how is the relationshio between cpufrequency and CLK.MICROSECONDS?
Thanks!
lex
Lex --
The CLK input frequency is fixed on the OMAPL138. Default is 24MHz. You can only change this via the configuration. The period you specify in the .tcf file is fixed and you cannot change it at runtime.
I don't think you have any other option but to run the interrupt at the rate required for your minimum periodic function.and write a function to do the math and call your other periodic functions as necessary for your app.
Regards,
-Karl-
Hi Karl,
I didn’t understand what you have said.
In my case, I needed several periods, such as 1ms/0.5ms/0.3ms/0.1ms.
How to realize these periods through c code? How to set CLK input frequency?
In BIOS graph configuration table, I can set CLK input frequency while the period is fixed on some value, how to change it to several values?
Best wishes.
lex
Lex --
I was suggesting that you create a single PRD function that runs at the minimum period -- 0.1ms in your case above. And then manage the division of the other periodic functions internally within that single function. I don't think running PRD at 0.1ms is a good idea though. That is a very high rate and PRD uses a SWI to do it's scheduling. It should work, but will have some overhead. 4251.timer.zip I've attached some timer reference code. You might want to use this for reference and dedicate a timer for your needs.
-Karl-
Hi Karl,
Is that to say use Timer3 instead of Timer0 or Timer1 to finish what I want to do? I want to build four PRD functions such as PRD0(0.1ms), PRD1(0.3ms), PRD2(0.5ms), PRD3(1ms), and every PRD function do the same thing except its period. I want to call every in HWI_isr function.
This is the code to call every PRD function in HWI_isr:
void HWI_isr()
{
unsigned int i;
if(i=1)
{
call PRD0
}
else if(i=2)
{
call PRD1
}
else if(i=3)
{
call PRD2
}
else (i=4)
{
call PRD3
}
}
And my PRD function mode is set to continuous. There is only one PRD function running, as the case may be.
Can you give me a simple demo to realize this application?
I cannot understand clearly what you have suggestted "I was suggesting that you create a single PRD function that runs at the minimum period -- 0.1ms in your case above. And then manage the division of the other periodic functions internally within that single function. " Any other ideas or simple demo?
Looking forward to your reply urgently!
lex
Lex --
What I'm saying is that PRD is probably not the right module for your use case. Having PRD period of 0.1ms will have a pretty high load.
I think you should make program the timer for .1ms and then call your functions within that timer function. The attached code shows how to program the timer. Change the init code to program the timer for .1ms and then replace the call to PRD tick with calls to your functions (at whatever rate is appropriate).
Regards,
-Karl-