搜索
bottom↓
回复: 10

STM32F仿真时提示堆栈溢出,怎么办?

[复制链接]

出0入0汤圆

发表于 2008-5-31 13:43:56 | 显示全部楼层 |阅读模式
我的4LED程序终于是编译通过了,可是我用DEBUG功能仿真运行时系统提示"Sat May 31 13:34:45 2008: The stack 'CSTACK' is filled to 100% (2048 bytes used out of 2048). The warning threshold is set to 90.%"看起来好象是堆栈溢出,可是我翻了STM32的手册和Cortex_M3的手册都没看到怎么设置堆栈.似乎这又是IAR搞的鬼,我就纳闷了就我这么简单一个程序怎么能扯到堆栈溢出上去呢?
* Includes ------------------------------------------------------------------*/
#include "stm32f10x_lib.h"


vu32 count = GPIO_Pin_4;

void SysTick_Config(void);

void Led_Config(void);

void Led_RW_ON(void);
void Led_RW_OFF(void);

void delay(void);
void delay()
{
  vu32 i,j;
  for (i=0; i<0xfff; i++)
  {
      for (j=0; j<0xff; j++);
  }
}


/*******************************************************************************
* Function Name  : main
* Description    : Main program
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
int main(void)
{

#ifdef DEBUG
  debug();
#endif

/* Configure the systick */
  SysTick_Config();

  Led_Config();
  
  while(1)
  {
      Led_RW_ON();
      delay();
  }
}

/*******************************************************************************
* Function Name  : SysTick_Config
* Description    : Configure a SysTick Base time to 10 ms.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void SysTick_Config(void)
{
  /* Configure HCLK clock as SysTick clock source */
  SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK);

  /* SysTick interrupt each 100 Hz with HCLK equal to 72MHz */
  SysTick_SetReload(720000);

  /* Enable the SysTick Interrupt */
  SysTick_ITConfig(ENABLE);

  /* Enable the SysTick Counter */
  SysTick_CounterCmd(SysTick_Counter_Enable);
}

void Led_Config(void)
{
  GPIO_InitTypeDef GPIO_InitStructure;

  /* Enable GPIOC clock */
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);

  /* Configure PC.06, PC.07, PC.08 and PC.09 as output push-pull */
  GPIO_InitStructure.GPIO_Pin =  GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_4 | GPIO_Pin_5;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_Init(GPIOC, &GPIO_InitStructure);
}

void Led_RW_ON(void)
{
  switch(count)
  {
      case GPIO_Pin_4:
      {
          GPIO_SetBits(GPIOC,GPIO_Pin_4 );
          count = GPIO_Pin_5;
      }break;
      case GPIO_Pin_5:
      {
          GPIO_SetBits(GPIOC,GPIO_Pin_5 );
          count = GPIO_Pin_6;         
      }break;   
      case GPIO_Pin_6:
      {
          GPIO_SetBits(GPIOC,GPIO_Pin_6 );
          count = GPIO_Pin_7;
      }break;
      case GPIO_Pin_7:
      {
          GPIO_SetBits(GPIOC,GPIO_Pin_7 );
          count = GPIO_Pin_4;         
      }break;        
      default :
      {
          count = GPIO_Pin_4;         
      }break;  
  }
}

void Led_RW_OFF(void)
{
  GPIO_ResetBits(GPIOC, GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_4 | GPIO_Pin_5);
}

#ifdef  DEBUG
/*******************************************************************************
* Function Name  : assert_failed
* Description    : Reports the name of the source file and the source line number
*                  where the assert error has occurred.
* Input          : - file: pointer to the source file name
*                  - line: assert error line source number
* Output         : None
* Return         : None
*******************************************************************************/
void assert_failed(u8* file, u32 line)
{
  /* User can add his own implementation to report the file name and line number,
     ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */

  /* Infinite loop */
  while (1)
  {

  }
}
#endif
/******************* (C) COPYRIGHT 2007 STMicroelectronics *****END OF FILE****/

阿莫论坛20周年了!感谢大家的支持与爱护!!

月入3000的是反美的。收入3万是亲美的。收入30万是移民美国的。收入300万是取得绿卡后回国,教唆那些3000来反美的!

出0入0汤圆

发表于 2008-5-31 14:31:02 | 显示全部楼层
没问题,这是编译器的输出信息。

出0入0汤圆

 楼主| 发表于 2008-5-31 14:39:20 | 显示全部楼层
不对,我的程序不继续往下走啊.

出0入0汤圆

 楼主| 发表于 2008-5-31 16:31:05 | 显示全部楼层
麻烦大家仿真运行一下我这个工程,我运行个几圈就跑飞了,可是这程序这么简单不应该有什么问题啊。难道我用的iar有问题?我用的是iar4.42 32k限制版

我编译通过的整个项目ourdev_297976.rar(文件大小:183K) (原文件名:4led.rar)

出0入0汤圆

发表于 2008-5-31 19:09:07 | 显示全部楼层
设置堆栈可以在启动文件setup.c里面,也可以是在连接脚本里面设置。
现在没电脑,帮不上。

【楼主位】 sunke9 AVR用GCC吗?
GCC转IAR不难的。

出0入0汤圆

 楼主| 发表于 2008-6-1 15:01:14 | 显示全部楼层
AVR是用GCC,但是是在AVRSTUDIO环境下不用自己写makefile,iar用起来觉得很难.

出0入0汤圆

发表于 2008-6-1 16:54:16 | 显示全部楼层
打开XCL文件
//*************************************************************************
// Stack and heap segments.
//*************************************************************************

-D_CSTACK_SIZE=400 <----------------------------------------修改这里
-D_HEAP_SIZE=200

-Z(DATA)CSTACK+_CSTACK_SIZE=RAMSTART-RAMEND
-Z(DATA)HEAP+_HEAP_SIZE=RAMSTART-RAMEND

出0入0汤圆

 楼主| 发表于 2008-6-2 17:33:55 | 显示全部楼层
我对照ST的例程修改了我的程序,现在程序已经正常运行了.我正在分析我出问题的原因.

出0入0汤圆

发表于 2008-8-11 13:45:31 | 显示全部楼层
以下蓝色文字由版主:bluelucky 于:2008-08-11,13:45:31 加入。
<font color=black>请发贴人注意:
本贴放在这分区不合适,即将移走
原来分区:[1032]ARM技术论坛
即将移去的分区:[3011]Cortex-M3技术讨论区
移动执行时间:自本贴发表0小时后

任何的疑问或咨询,请可随时联系站长。谢谢你的支持!
</font>

出0入0汤圆

发表于 2009-4-1 14:46:04 | 显示全部楼层
【6楼】 正解
堆栈没设好

出0入0汤圆

发表于 2014-8-9 16:16:17 | 显示全部楼层
应该堆栈没设好,
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-4-26 05:39

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

快速回复 返回顶部 返回列表