Other Parts Discussed in Thread: SYSBIOS
Thread 中讨论的其他器件:SYSBIOS
工具/软件:TI-RTOS
我想为外部芯片在任务中设置10us 电平延迟、但我不想更改项目的时间周期值。 如何实现延迟?
就像这样
GPIO=1;
delay_us (10);
GPIO=0;
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.
您可以使用 Timestamp 模块为此浏览 SYSBIOS。 SysBIOS 的这个时间戳模块将使用 C674x CPU 时间戳寄存器(TSCL (低32位)、TSCH (高32位)、这些寄存器的时钟频率为600MHz。 只要参考 C 代码中包含 c6x.h、也可以使用编译器直接访问这些寄存器。 对于小于7秒(2^32/600e6)的内联延迟(即 CPU 在时间内等待)、仅 TSCL 就足够了。 SDK 使用这种非 SysBIOS 方法进行循环分析在开箱即用演示中、使用的函数是 Cyclprofiler_getTimeStamp ()、它只是一个等同于 TSCL 的宏(因此不需要用户的函数调用/返回开销)、并在头文件 ti/utils/cycleprofiler/cycleprofiler.h 中实现 因此、如果您使用的是 SDK、则可以编写如下所示的代码(未经验证、您可以检查):
#include
静态内联空延迟(uint32_t tick)
{
volatile uint32_t startTimeStamp;
volatile uint32_t currentTimeStamp;
startTimeStamp = Cycleprofiler_getTimeStamp();
执行{
currentTimeStamp = 循环分析器_getTimeStamp();
} while ((currentTimeStamp - startTimeStamp)< tick);
}
(笑声)
uint32 interruptState;
interruptState =_disable_interrupts ();// TI C674x 编译器直接支持此函数
GPIO = 1;
延迟(10 * 600);//DSP 速度为600MHz
GPIO = 0;
_restore_interrupts (interruptState); //this 函数直接受 TI C674x 编译器支持
如果要使用 SYSBIOS,则可能需要查看该线程
。 这与没有 SYSBIOS 的实现基本相同、但从意义上讲、最好使用 SYSBIOS API 来了解 CPU 频率、而不是硬编码已知的频率。