main.c 里定义要串口发送的数值:
extern uint16_t SendBuff[SENDBUFF_SIZE];
for(i=0; i<SENDBUFF_SIZE; i++)
{
SendBuff = 'c';
}
我要发送一组十六进制值:EE,B1,11,00,01,00,02,11,37,34,00,FF,FC,FF,FF,我将SendBuff[SENDBUFF_SIZE]这样赋值:
SendBuff[SENDBUFF_SIZE]={0xEE,0xB1,0x11,0x00,0x01,0x00,0x02,0x11,0x37,0x34,0x00,0xFF,0XFC,0XFF,0XFF};
提示编译有错误,去掉extern uint16_t SendBuff[SENDBUFF_SIZE]这一句,在SendBuff[SENDBUFF_SIZE]={0xEE,0xB1,0x11,0x00,0x01,0x00,0x02,0x11,0x37,0x34,0x00,0xFF,0XFC,0XFF,0XFF}前加extern,或const,或 uint16_t都没用,都是提示有error,不知道怎么回事啊?折腾了两天了
如果不用extern,直接这样uint16_t SendBuff[SENDBUFF_SIZE]={0xEE,0xB1,0x11,0x00,0x01,0x00,0x02,0x11,0x37,0x34,0x00,0xFF,0XFC,0XFF,0XFF};编译无error,但有警告,下载后STM32串口输出全都是00.
另外,如果我单独给每个数组赋值,编译没错误警告问题,如:
SendBuff[0]=0xEE;
SendBuff[1]=0xB1;
SendBuff[2]=0x11;
......
SendBuff[13]=0xFF;
SendBuff[14]=0xFF;
编译下载后,串口输出的是3F 3F 11 00 00 00 01 00 00 00 02 00 11,也不是我期望的值。
bsp_dma_mtp.c没改动,bsp_dma_mtp.h里改了一个#define SENDBUFF_SIZE 30,其他没有任何变动
不知道怎么回事啊?折腾了两天了。 |