|
如果我就while(i--)这么编译不出来。
必须在while语句里加一个SysTick->VAL = 0;之类的无意义语句才能编译出来。是怎么回事?
void i2c_delay_us(uint32_t i)
{
uint32_t temp;
if(i==0)return;//0.6us
if(Moni_speed>3)
{
temp=2;
while(temp)
{
temp--;
SysTick->CTRL = 0;//必须加上这句才能生效
SysTick->VAL = 0;
};
}
else
{
if(Moni_speed<=1)SysTick->LOAD = 30 * i;//100k 4.6us
if(Moni_speed==2)SysTick->LOAD = 9 * i;//200k 2.3us
if(Moni_speed==3)SysTick->LOAD = i;//300k 1.48us
SysTick->CTRL = 0X01;
SysTick->VAL = 0;
do
{
temp = SysTick->CTRL;
} while ((temp & 0x01) && (!(temp & (1 << 16))));
SysTick->CTRL = 0;
SysTick->VAL = 0;
}
}
加上两句无意义语句,就能编译出来
|
|