F********g 发帖数: 475 | 1 unsigned int calculate_1X_LO_period(unsigned int input_freq_khz, unsigned
int if_freq_khz)
{
unsigned int
remainder;
unsigned int temp_result;
unsigned int divisor;
DISABLE_TMR1_INT;
DISABLE_TMR4_INT;
DISABLE_SPI1_INT;
dividend.all=32000;
divisor=input_freq_khz+if_freq_khz;
if (0==divisor)
{
divide_by_0_error_1++;
divisor=285;
}
DIV_32X16U(dividend.word2.hi, dividend.word2.lo, divisor);
asm("mov w0,%0":"=g"(temp_result):);
asm("mov w1,%0":"=g"(remainder):);
ENABLE_TMR1_INT;
ENABLE_TMR4_INT;
ENABLE_SPI1_INT;
if(remainder<(temp_result>>1)){temp_result++;}
return(temp_result);
}//end calculate_1X_LO_period()
现在的问题是如果第二个方程变量if_freq_khz用global variable call的话,会出现
DIVIDE BY 0 ERROR,即使两个变量都非0;如果第二个方程变量赋同样值,用LITERAL
CALL,没问题。
会是什么问题?? | s**********s 发帖数: 47 | 2 I guess something related to "if_freq_khz"?! you really like start with "if_
"?!
just guess |
|