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.
I think this is really a DSP/BIOS question but there is no forum dedicated to that so this seems to be the next closest place [:)]
I'm programming a C6747 with DSP/BIOS and using the CLK module to generate system ticks. I select either Timer0 or Timer1 to do this and allow BIOS to program it. In my code, I want to set up a watchdog timer using Timer1. But as a check I want to make sure the CLK module is NOT using Timer1 and if it is, LOG_printf a warning without setting up the watchdog. How can I determine which Timer the CLK module is using during execution so I don't mistakenly clobber it when setting up the watchdog?? I've already done this one with catastrophic results that took a long time to debug. I don't want to have it happen again.
thanks,
Mike
sorry, maybe I didn't explain my question well enough. What you describe is what I meant by "I select either Timer0 or Timer1 to do this and allow BIOS to program it."
What I need to do is determine what this selection was when my code is executing in main. Main is where I want to setup the watchdog timer and I want the code, during program execution, to examine some register, variable, or symbol, which indicates the timer that is reserved for use by the BIOS kernel. Something like:
bios_timer = get_clk_module_timer_ID();
I know there is no API like this, but i want the steps to create a function like this.
thanks,
Mike
I don't know of an easy way to do this. The scheduler doesn't care which timer it uses as long as it has its "heartbeat." I don't believe the timer selection you make in the clock manager is stored in any structures anywhere; however, in theory this is a moot point as you are able to specify which timer is used and which timer(s) is available from a system integration standpoint.
Mike,
In addition to Mariana's reply, DSP/BIOS does not have a protection mechanism to prevent changes to its configured timer.
I haven't had any such requests before; therefore the best idea I can think is to verify the IER register before starting the configuration of the other Timer. The code would be something along those lines:
#include <c6x.h>
(...)
int which_timer;
void myconfigTask(void) {
(...)
which_timer = IER;
if (which_timer & 0x8000) { /* Timer 1 is being used */ }
else if (which_timer & 0x4000) { /* Timer 0 is being used */ }
else { /* No timer is being used */ }
}
Make sure the test condition is running after main(), since the IER is configured only when it returns.
Hope this helps,
Rafael
Thanks for the replies. I found out the hard way BIOS does not protect against its Timer from being reconfigured. This is why I want to add this type of check. Tim remarks the check is a moot point since the programmer decides which Timer to select. But it may be a different programmer who doesn't know (or in my case an absent-minded one that forget) Timer1 has been designated for use by BIOS and then goes and tries to reconfigure it as a watchdog timer. It's good practice to make sure parameters take on valid values. I can use Rafael's suggestion but I might prefer to be able to check this in main. He correctly points out that the Timer isn't enabled until after execution exits from main so his function would have to go in a task. One possible way to do this check in main is to use the assembly variable CLK_REGS. I found this in the *cfg.h62 and *cfg.26 generated files. This variable is set the base register of the timer being used by BIOS. I haven't tried this but I think one could write an assembly routine that included these header files and then examined the value of this variable to see which Timer is in use by the CLK module. It could return the Timer in use so the program knows NOT to use that Timer for any other purpose. I'd prefer to have this routine in C but don't think this variable is accessible from a C function. So the best I know how to do is write the asm routine and call it from a C file.
Mike
I was able to write a linear assembly routine I can call from c code main to check on which timer the CLK module will use. Here is the asm code:
.def _get_clk_regs_address
.include mcasp_test2cfg.h62
_get_clk_regs_address: .cproc
.reg timer_address
mvkl CLK_REGS, timer_address
mvkh CLK_REGS, timer_address
.return timer_address
.endproc
and here is the call from main:
void main(void)
{
Uint32 timer_id;
select_peripherals();
configure_peripherals_gpio();
timer_id = get_clk_regs_address();
if(CSL_TMR_1_REGS == timer_id) {
LOG_printf(&trace,"Warning! Timer1 in use by BIOS.\r\n");
LOG_printf(&trace,"No timer is available for use as watchdog.\r\n");
} else {
configure_watchdog();
}
}
seems to work fine!
Mike
Mike,
Glad to hear you got this to work, and thank you for posting your findings here!