2014-06-22 09:08 AM
Hi,
I am debugging my project. I can ''step one line'' each time to walk through it, but when I let it run freely, or ''step over the current line'', or ''step out of current function'', it crash. Please help.2014-06-22 12:30 PM
Crash how and where? Where is it when you hit stop?
If you end up in the Hard Fault Handler, and that's just a while(1) loop then you need to use a better handler like the one's demonstrated by Joseph Yiu. When you can see the faulting assembler instructions, and the processor registers you might better place to describe the failure. Do you have all the interrupt handlers in place? Is your stack big enough?2014-06-22 12:38 PM
It is not end up in the Hard Fault Handler. When I hit the stop, it go to: line 431 of startup_stm32f429xx.s
~~~~~~~~~~~ B . ENDP ALIGN ~~~~~~~~~~~~~~~~~~~~~~~ I am using Keil to debug STM32F429 i Discovery. If stack is not big enough, how to fix it?2014-06-22 01:44 PM
I'd suspect you have enabled an interrupt for which you don't provide an IRQHandler (stm32f4xx_it.c?)
The stack is defined in startup_stm32f4xx.s, but you're not getting a Hard Fault2014-06-22 03:33 PM
Further information:
It crash when I call ADC second times. The code is: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /* Check if ADC peripheral is disabled in order to enable it and wait during Tstab time the ADC's stabilization */ if((hadc->Instance->CR2 & ADC_CR2_ADON) != ADC_CR2_ADON) { /* Enable the Peripheral */ __HAL_ADC_ENABLE(hadc); /* Delay inserted to wait during Tstab time the ADC's stabilazation */ for(; i <= 540; i++) { __NOP(); } } ~~~~~~~~~~~~~~~~~~~ It stays in the loop of _NOP();2014-06-23 11:43 PM
Dear Clive 1,
Yes, I did enable a interup of ADC_DMA, but how to add a IRQHandler in stm32f4xx_it.c? The following is some code in ADC_DMA: ~~~~~~~~~~~~~~~~~~~ /* Definition for ADCx clock resources */ #define ADCx ADC3 #define ADCx_CLK_ENABLE() __ADC3_CLK_ENABLE() #define DMAx_CLK_ENABLE() __DMA2_CLK_ENABLE() #define ADCx_CHANNEL_GPIO_CLK_ENABLE() __GPIOC_CLK_ENABLE() #define ADCx_FORCE_RESET() __ADC_FORCE_RESET() #define ADCx_RELEASE_RESET() __ADC_RELEASE_RESET() /* Definition for ADCx Channel Pin */ #define ADCx_CHANNEL_PIN GPIO_PIN_3 #define ADCx_CHANNEL_GPIO_PORT GPIOC /* Definition for ADCx's Channel */ #define ADCx_CHANNEL ADC_CHANNEL_13 /* Definition for ADCx's DMA */ #define ADCx_DMA_CHANNEL DMA_CHANNEL_2 #define ADCx_DMA_STREAM DMA2_Stream0 /* Definition for ADCx's NVIC */ #define ADCx_DMA_IRQn DMA2_Stream0_IRQn #define ADCx_DMA_IRQHandler DMA2_Stream0_IRQHandler /** @addtogroup STM32F4xx_HAL_Examples * @{ */ /** @addtogroup ADC_RegularConversion_DMA * @{ */ /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* ADC handler declaration */ ADC_HandleTypeDef AdcHandle; /* Variable used to get converted value */ __IO uint16_t uhADCxConvertedValue=1; /* Private function prototypes -----------------------------------------------*/ //static void SystemClock_Config(void); static void Error_Handler(void); extern float Efact ; /* Private functions ---------------------------------------------------------*/ /** * @brief Main program. * @param None * @retval None */ void ADCmain(void) { ADC_ChannelConfTypeDef sConfig; /* STM32F4xx HAL library initialization: - Configure the Flash prefetch, instruction and Data caches - Configure the Systick to generate an interrupt each 1 msec - Set NVIC Group Priority to 4 - Global MSP (MCU Support Package) initialization */ // HAL_Init(); // /* Configure the system clock to have a system clock = 144 Mhz */ // SystemClock_Config(); /* Configure LED3 and LED4 */ // BSP_LED_Init(LED3); // BSP_LED_Init(LED4); /*##-1- Configure the ADC peripheral #######################################*/ AdcHandle.Instance = ADCx; AdcHandle.Init.ClockPrescaler = ADC_CLOCKPRESCALER_PCLK_DIV2; AdcHandle.Init.Resolution = ADC_RESOLUTION12b; AdcHandle.Init.ScanConvMode = DISABLE; AdcHandle.Init.ContinuousConvMode = ENABLE; AdcHandle.Init.DiscontinuousConvMode = DISABLE; AdcHandle.Init.NbrOfDiscConversion = 0; AdcHandle.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE; AdcHandle.Init.ExternalTrigConv = ADC_EXTERNALTRIGCONV_T1_CC1; AdcHandle.Init.DataAlign = ADC_DATAALIGN_RIGHT; AdcHandle.Init.NbrOfConversion = 1; AdcHandle.Init.DMAContinuousRequests = ENABLE; AdcHandle.Init.EOCSelection = DISABLE; if(HAL_ADC_Init(&AdcHandle) != HAL_OK) { /* Initiliazation Error */ Error_Handler(); } /*##-2- Configure ADC regular channel ######################################*/ sConfig.Channel = ADCx_CHANNEL; sConfig.Rank = 1; sConfig.SamplingTime = ADC_SAMPLETIME_3CYCLES; sConfig.Offset = 0; ~~~~~~~~~~~~~~~~~~` Thanks a lot2014-06-24 09:13 AM
I add these lines in the code of stm32f4xx_it.c:
extern ADC_HandleTypeDef AdcHandle; extern ADC_HandleTypeDef ADCx_DMA_IRQn; extern ADC_HandleTypeDef ADCx_DMA_IRQHandler; But it is still the same problem. Please help. Thanks2014-06-24 11:07 AM
I'm not even sure that makes sense to do.
Do you have a void ADCx_DMA_IRQHandler(void) routine? And does it show up in the .MAP file as DMA2_Stream0_IRQHandler? If you don't have this function, and linkage to it, the interrupt is going to go to that ''B .'' loop and die. Do you have any other interrupts which are not being handled?2014-06-24 02:41 PM
I h�?ve �?tt�?ched the .M�?�? file. C�?uld y�?u �?le�?se check it?
Th�?nks ________________ Attachments : STM32F429I-Discovery.map : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I02A&d=%2Fa%2F0X0000000bSs%2F._q11dSauuM7u8CyKEAxdB5GglRvPz33V6p3_HX7bB4&asPdf=false2014-06-24 06:16 PM
Ok, your stm32f4xx_it.c is not including the defines for the ADC configuration, consequently the ADCx_DMA_IRQHandler name is not be substituted with DMA2_Stream0_IRQHandler, and the body code for the handler is being discarded.