stm32f100数组赋值问题
uint8_t buf;buf = 33;
buf = 34;
结果是
buf33
buf34
buf34
有没有人碰到过这种情况,帮我看下是哪里不对
回复:stm32f100数组赋值问题
环境是KEIL5,仿真器是JLINKRE:stm32f100数组赋值问题
数组定义的时候直接赋值全0试试:uint8_t buf={0};回复:stm32f100数组赋值问题
回复第 3 楼 于2014-08-17 11:35:40发表:数组定义的时候直接赋值全0试试:uint8_t buf={0};
仿真结果还是一样
RE:stm32f100数组赋值问题
这数组是存放在什么地方的,贴出完整的程序吧。回复:stm32f100数组赋值问题
回复第 5 楼 于2014-08-17 15:06:36发表:这数组是存放在什么地方的,贴出完整的程序吧。
#include "includes.h"
int main (void)
{
uint8_t i;
uint8_t buf = {33,34,35,0};
/*!< At this stage the microcontroller clock setting is already configured,
this is done through SystemInit() function which is called from startup
file (startup_stm32f10x_xx.s) before to branch to application main.
To reconfigure the default setting of SystemInit() function, refer to
system_stm32f10x.c file
*/
i = i;
i = 0;
buf = 33;
buf = 36;
sprintf((char*)&buf, "!#$");
// buf = {}
// buf = 0;
sprintf((char*)&buf, "文");
while(1)
{
}
}
/**********************ends of file*******************************************/
回复:stm32f100数组赋值问题
回复第 5 楼 于2014-08-17 15:06:36发表:这数组是存放在什么地方的,贴出完整的程序吧。
没有什么特殊的地方,也没做特殊处理只是简单赋值。空工程
RE:stm32f100数组赋值问题
sprintf((char*)&buf, "!#$");这是按什么格式输出RE:stm32f100数组赋值问题
建议仿真一下。在sprintf之前buf的值,sprintf以后buf的值。回复:stm32f100数组赋值问题
回复第 9 楼 于2014-08-18 09:18:34发表:建议仿真一下。在sprintf之前buf的值,sprintf以后buf的值。
仿真结果是一样的。我写的那两种赋值方式里,1跟2的位置的数据是一样的
页:
[1]
2