我的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); }
#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) */
要定义VECT_TAB_FLASH在配置里 应该在main 主函数里加入 void NVIC_Configuration(void) { #ifdef VECT_TAB_RAM /* Set the Vector Table base location at 0x20000000 */ NVIC_SetVectorTable(NVIC_VectTab_RAM, 0x0); #else /* VECT_TAB_FLASH */ /* Set the Vector Table base location at 0x08000000 */ NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0); #endif }