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.
UARTprintf("%f",x);
发送 接到的是ERROR
怎么用UARTprintf()函数发送浮点格式的数
void f_char_printf(float Xangle)
{
float temp = Xangle;
if(Xangle>=0){
UARTprintf("%d.%d",(int32_t)temp ,(int32_t)((temp -(int32_t)temp )*1000));
}
else{
temp = 0-temp;
UARTprintf("-%d.%d",(int32_t)temp ,(int32_t)((temp -(int32_t)temp )*1000));
}
}
直接写了个函数 不知道为什么UARTprintf 没有%f 这种用发、。。。
double c,d;
int m1,m2,m3,m4,pui32ADC0Value[0];
d=(double)(pui32ADC0Value[0]);
c=(double)(d/4096)*3.3;
m1=c;
m2=(int)(c*10)%10;
m3=(int)(c*100)%100;
UARTprintf("AIN0 = %d", m1);
UARTprintf(".");
UARTprintf("%d", m2);
UARTprintf("%dv\n", m3);
看懂你就你能用了