出错的地方是红色注释的那条代码
程序编译环境是MPLAB
#include <htc.h>
#define U8 unsigned char
#define S8 char
#define U16 unsigned int
#define S16 int
#define U32 unsigned long
#define S32 long
U8 const tab[10] = {0,1,2,3,4,5,6,7,8,9};//串口发送10进制数据表
__CONFIG(WDTDIS & LVPDIS & HS & PWRTDIS & BORDIS);//设置配置位
//WDTDIS:disable watchdog timer
//LVPDIS:low voltage programming disabled
//HS:high speed crystal/resonator
//PWRTDIS:disable power up timer
//BORDIS:disable brown out
void main(void)
{
U8 *array;
U8 a[5];
U16 temp;/////////将temp改为U32就会报错...为什么??
U32 L,M,H;
temp = 0x000000;
// array = ReadATT7022EU(command);
L = array[0];
M = array[1];
H = array[2];
M<<=8;
H<<=16;
temp = H+M+L;
if(temp>0x800000)
temp -= 0xffffff;
temp = temp*377;
a[4] = tab[temp%1000000/100000];
a[3] = tab[temp%100000/10000];
a[2] = tab[temp%10000/1000];
a[1] = tab[temp%1000/100];
a[0] = tab[temp%100/10];
}
|