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.
曾经在TI_CC_spi.c内看到过如下的代码:
// Delay function. # of CPU cycles delayed is similar to "cycles". Specifically,
// it's ((cycles-15) % 6) + 15. Not exact, but gives a sense of the real-time
// delay. Also, if MCLK ~1MHz, "cycles" is similar to # of useconds delayed.
void TI_CC_Wait(unsigned int cycles)
{
while(cycles>15) // 15 cycles consumed by overhead
cycles = cycles - 6; // 6 cycles consumed each iteration
}
是否能说明MSP430的一个循环大约为6个时间周期?再除以频率就能得到大致的时间呢?
楼主是要做延时吧,430的编译器提供了一个本征函数__delay_cycle()来做延时,只需要把需要延时的cycle数量填入,编译器会自动行程一个准确的delay。这样比自己计算方便多了
另外补充一点,要做准确的延时,最好的方式还是用GPIO口来输出电平变化,通过示波器来量测。这样做出来最准,也不用计算。