我的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****/
|