程序图下:unsigned char buf0[1024];
void App_TaskUart(void *p_arg)
{
INT8U tmp;
INT16U len, i,j;
static INT16U rUart3Len = 0; // UART3½óêÕêy¾Y3¤¶è
INT8U err,cpu_sr;
(void)p_arg;
//Ö÷°å485¿ú£¬′óóòÏò×óòà′ÎêÇUART3¡¢UART4¡¢UART5
while (1)
{
SysFlag.TaskRunStatus |= TASK_UART_FLAG;
Delay_ms(10);
len = Uart_Ctrl(UART3_ID, CMD_UART_GetCharsRxBuf,0);// ¶á衽óêÕêy¾Y3¤¶è
if ((len == rUart3Len)&&(len>0))
{
if (len > 1024)
{
len = 1024;
}
tmp = Uart_Read(UART3_ID, buf0, len);
rUart3Len -= len;
}
else
{
rUart3Len = len;
}
.........
........
当数组buf0定义为全局变量的时候,单片机运行正常;当数组buf0定义为局部变量的时候,单片机不断复位。
我大概了解是堆栈溢出了,但是我看到内存是够用的,所以不明白了,请大神们帮我分析一下为什么?
数组buf0定义在全局变量时编译结果:
Program Size: Code=152064 RO-data=3048 RW-data=132328 ZI-data=56744
FromELF: creating hex file...
After Build - User command #1: fromelf --bin --output .outputupgrade.bin .outputEMB86xxI.axf
".outputEMB86xxI.axf" - 0 Error(s), 0 Warning(s).
数组buf0定义在局部变量时编译结果:
Program Size: Code=152076 RO-data=3048 RW-data=132328 ZI-data=55720
FromELF: creating hex file...
After Build - User command #1: fromelf --bin --output .outputupgrade.bin .outputEMB86xxI.axf
".outputEMB86xxI.axf" - 0 Error(s), 0 Warning(s).
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>