11-17-2015 04:04 AM
I would like to Delay Execution of PS progarm.
Can I use below code with AXI timer for exact Delay Generation in PS??
--------------------------------------------------
void usleep(unsigned int useconds)
{
unsigned int timer_count = 0;
unsigned int wait_for_timer = 0;
unsigned int count_value = 0;
wait_for_timer = 1;
count_value = useconds * (PROCESSOR_CLOCK_FREQUENCY / 1000000);
XTmrCtr_Disable(XPAR_TMRCTR_0_BASEADDR, 0);
XTmrCtr_SetLoadReg(XPAR_TMRCTR_0_BASEADDR, 0, 0x00);
XTmrCtr_LoadTimerCounterReg(XPAR_TMRCTR_0_BASEADD
// Set the timer running
XTmrCtr_SetControlStatusReg(XPAR_TMRCTR_0_BASEADD
while (wait_for_timer)
{
timer_count=XTmrCtr_GetTimerCounterReg(XPAR_TMRCT
if (timer_count > count_value)
{
wait_for_timer = 0;
}
}
XTmrCtr_SetControlStatusReg(XPAR_TMRCTR_0_BASEADD
11-17-2015 04:11 AM - edited 11-17-2015 10:05 PM
Hello,
Every time you call a function to enable, disable or check the counter, the processor has to write or read to the peripheral through the AXI bus. Since you call the function until the counter starts, there will be a delay. Also, since the counter reaches your desired value until the processor "realizes" by reading it, a time interval will pass. If you have other peripherals generating interruptions, these times could vary.
So, I would say this is a way to generate delays, but not 100% exact.
Regards
Ignacio
11-17-2015 09:12 PM
Hello,
Thanks for your reply. Is there any other way to generate exact delay in PS?
11-18-2015 08:57 AM