我调用的Tasksleep函数,延迟时间为ms数量级,请问如何将延时时间设置为微秒级别的?
(1)可以通过修改tasksleep函数吗?这个函数源码在哪,可编程?
(2)自己写的delay函数不起作用
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.
我调用的Tasksleep函数,延迟时间为ms数量级,请问如何将延时时间设置为微秒级别的?
(1)可以通过修改tasksleep函数吗?这个函数源码在哪,可编程?
(2)自己写的delay函数不起作用
参考STK例程keystone_common.c中的TSC delay函数,以us为单位。
void TSC_delay_us(Uint32 us)
{
volatile unsigned long long startTSC, currentTSC;
unsigned long long delay_cycles;
Uint32 tscl, tsch;
tscl= TSCL;
tsch= TSCH;
startTSC= _itoll(tsch,tscl);
delay_cycles= ((unsigned long long)us*gMain_Core_Speed_Hz/1000000);
do
{
tscl= TSCL;
tsch= TSCH;
currentTSC= _itoll(tsch,tscl);
}
while((currentTSC-startTSC)<delay_cycles);
}