printf输出同个数据,输出结果却不一样
最近在做一个51单片机项目,其实通过串口调试助手的向pc输出数据时却遇到一个问题
printf("The current voltage is %dmv\nVOLTL %d VOLTH %d VOLTH %d\n",temp,volt[0],volt[0],volt[0]);
在pc上输出怎么会是
The current voltage is 32761mv
VOLTL -1543 VOLTH -1745 VOLTH 0
volt[]是定义的全局变量。
[解决办法]
加volatile试试
[解决办法]
设数据改变断点:
VC6
Setting a Breakpoint When a Variable Changes Value
To set a breakpoint when a variable changes value
From the Edit menu, click Breakpoints.
Click the Data tab of the Breakpoints dialog box.
In the Expression text box, type the name of the variable.
Click OK to set the breakpoint.
[解决办法]
字节对齐问题。
[解决办法]
会不会是类型长度不一样?单片机中是16位的int 在PC上编译就有可能就是32位的.
[解决办法]
[解决办法]