STM32F107VC AND KEIL PROBLEM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2012-05-11 8:36 AM
Hello ;
I am new to STM32 ; right now I could blink a led I have good experience with other MCU venders ; but this first time to ARM. I have strange problem with my code ; when I dont use the routine creatfile(); the program work as expect ; but when i add them to the code the program first get : NMI_Handler and then stuck some place .. the code is here : GPIO_InitTypeDef GPIO_InitStructure;// void creatfile(void) ;
//-- void init_card (void);void delay(unsigned int time) {
while(time--);
}volatile unsigned int delay_main;
//-------
//------------
int main(void) { /*!< At this stage the microcontroller clock setting is already configured, this is done through SystemInit() function which is called from startup file (startup_stm32f10x_xx.s) before to branch to application main. To reconfigure the default setting of SystemInit() function, refer to system_stm32f10x.c file */ //RTC_NVIC_Configuration();/* system Tick enable timer----------------------- */
SystemCoreClock =72000000 ; if(SysTick_Config(SystemCoreClock / 1000)) // 1 ms interrupts while(1); // error /* GPIOD Periph clock enable */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD, ENABLE);/* Configure PD0 and PD2 in output pushpull mode */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_4; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_Init(GPIOD, &GPIO_InitStructure); GPIO_SetBits( GPIOD, GPIO_Pin_3 | GPIO_Pin_4);//-----------------
init_card ();
//creatfile();
// while(1) { GPIO_SetBits( GPIOD, GPIO_Pin_3 | GPIO_Pin_4);while (delay_main<1000); delay_main=0; GPIO_ResetBits( GPIOD, GPIO_Pin_3 | GPIO_Pin_4); while (delay_main<1000); delay_main=0; }
init_card ();
}void init_card (void) {
U32 retv;while ((retv = finit (NULL)) != 0) { /* Wait until the Card is ready*/
if (retv == 1) { while(1); } else { } } }void creatfile(void) {
char *fname, *next; FILE *f; int i,cnt = 1000;f = fopen (''ASSAAD.TXT'', ''w''); /* open a file for writing */
if (f == NULL) { while(1); return; } for (i = 0; i < cnt; i++) { fprintf (f, ''This is line # %d in file %s\n'', i, ''ASSAAD.TXT''); } fclose (f); /* close the output file */ while(1); } //--------#ifdef USE_FULL_ASSERT
/**
* @brief Reports the name of the source file and the source line number * where the assert_param error has occurred. * @param file: pointer to the source file name * @param line: assert_param error line source number * @retval None */ void assert_failed(uint8_t* file, uint32_t 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 2011 STMicroelectronics *****END OF FILE****/
Thank you Regards- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2012-05-11 9:28 AM
Where do you think the file is going?
What libraries and hardware do you have supporting the STDIO routines, and whatever media it is writing too? Try digging out a debugger and step through the code so you better understand why it is crashing, and it explain it more thoroughly.Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2012-05-11 11:48 AM
