標(biāo)題:
請(qǐng)教我一下
[打印本頁(yè)]
作者:
ben_shere
時(shí)間:
2014-1-9 21:21
標(biāo)題:
請(qǐng)教我一下
#include "stc12c56xx.h"
#include "intrins.h"
#include "math.h"
#define PI 3.1415926
#define uchar unsigned char
#define uint unsigned int
uint count;
short sin_data;
void mcu_init();
void delay(uint x);
void main()
{
mcu_init();
for(count=1;count<270;count++)
{
sin_data=126*(sin(2*PI*count/270))+128;
}
while(1);
}
void mcu_init()
{
P1M0=0x00;
P1M1=0xff;
P2M0=0x00;
P2M1=0xff;
}
請(qǐng)教一下為啥當(dāng)count值到3f時(shí)sin_data的值會(huì)與手工計(jì)算的值不一樣
作者:
xieweihua12
時(shí)間:
2014-1-11 10:50
首先,你說(shuō)的不一樣不知道差別到底是多大。
再一個(gè),你說(shuō)的問(wèn)題可能在于計(jì)算sin的精度不行
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1