2015-05-10 12:41 AM
Hello, i designed board with STM32F373, since i don't need lot of speed, and low pin count will save me some space. ( this is first time i not used STM32F4 series, that works every time with little or no trouble)
Problem i am having is even at simple task, like SetBits( GPIOD, GPIO_Pin_10) it goes to void HardFault_Handler(void) loop. This is just nuts ! If i use GPIOD->BSRR = GPIO_Pin_10; i get no problems. Same happens with my other program parts, like using adc, sdadc and so on. I can't get it working without crashing. Where is no word to describe how i want to throw it to wall at the time. I never had this problem with STM32F4. I used templates from examples folder, i did set HSE to 16MHz instead if 8MHz as stated is STM32, and yes, i am using 16MHz My program crash after few seconds, and at that short time, it looks like it does what it needs to do. Sometimes command goes out of memory, like it missed my asm code, and just go where no code is left ! Anyone knows what could be wrong ? is it compiler ? My hardware is sound, i triple checked everything, voltages are good, not heat, no weird stuff, nothing.2015-05-10 02:48 AM
Simple video with problem:
2015-05-10 04:21 AM
You don't give us a lot to go on.
My first suspicion would be hardware - mainly because all you tell us is that (according to you) it is ''sound''. There are many things that you sometimes can ''get away with'' but not if you need things to work first time. Perhaps inadequate power-supply decoupling. Does the F373 have a ''core'' voltage that is internally regulated from your external Vdd; this needs to be decoupled as well as Vdd. Perhaps the decoupling and/or regulation are too far from the processor. Perhaps a dodgy lead from the power-supply to the board. (Do you have an external ''power-supply monitor/watchdog chip that will automatically reset your processor on brown-outs?)If subroutine calls don't work but the equivalent inline code does, then perhaps you are not allocating enough space for the stack.Hope this helps,Danish2015-05-10 04:44 AM
Does it fqil if you let it continue to run from HSI, ie don't change anything or call SystemInit() ?
Output the clock via MCO and verify it. Double check FLASH wait states, and prefetch settings, most likely to cause random failure. Get a Hard Fault Handler that provides more specific detail. Check for stack issues, and interrupts that are not handled.2015-05-10 04:50 AM
Hi, thank you for taking time to make replay.
My hardware always have decoupling ( in range of 1uF ) near the pins, and second decoupling goes near LDO. Voltage on each pin are 3.30V and noise is below 10mV. CSTACK and HEAP is 0x2000 as default in STM32F373xC , should i change it ? Flash Latency(WS) = 2 , as in default template, i don't know should i change it. ( Data sheet states that above 48Mhz it should be 2, below 1.) How to make hard fault handler loop to tell more information ? Because at this point in time i am a bit lost, i don't know what is wrong ( as example, it's more than 2hours how my processor is running with SDADC code with no problem, so i don't understand it, sometimes it takes secods, sometimes it crashes before init functions)2015-05-10 04:58 AM
As example, SDADC code is running more than 2h and no problem ( with debugger atached), but sometimes it just dies.
It's ironic, try to save ~5EUR on STM32F15 part, that would worked first time every time, i having problems upon problems, with no clear reason why ________________ Attachments : C_Code.rar : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I0oI&d=%2Fa%2F0X0000000bdt%2FryC7SPUglTocVS58bNQfbw1evQBPNnEJKupqb_jiKWo&asPdf=false2015-05-10 05:32 AM
Joseph Yiu has published Hard Fault Handlers, and several books for the Cortex-Mx parts.
https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32Java/Flat.aspx?RootFolder=%2Fpublic%2FSTe2ecommunities%2Fmcu%2FLists%2FSTM32Java%2FHardFault%20when%20using%20IAR%206.50&FolderCTID=0x01200200770978C69A1141439FE559EB459D758000F9A0E3A95BA69146A17C2E80209ADC21¤tviews=60 In other situations I'd also dump out the stack, but usually this is enough to see if there is any consistency to the nature and location of the failure. I'd also fill the stack with a known pattern, and get a clear determination of the depth used. Check also with local/auto variables that you're not assuming specific or zero values to be set, and you completely initialize such structures. So 25 MHz, or 16 MHz? Check the APB clocks, if you run them over spec you'd likely see random behaviour, ie critical path, sensitivity to particular sequences or bit patterns.2015-05-10 05:39 AM
16MHz ( At first, i thought i have 25MHz in stock, but i only had 16MHz. it should not be a problem. Checked with scope it good)
2015-05-10 05:40 AM
C Code
The specific system_stm32f3xx.c and startup_stm32f3xx.s for the project, allow with the defines passed into the compiler (project file, or makefile), might also be enlightening. At the very least you should pull in your own copy of the system_stm32f3xx.c file, because you'd need to modify that to deal with the different clocking source/strategy. For an external oscillator, you'd want HSE in bypass mode. And for HSE_VALUE to reflect the speed.2015-05-10 07:25 AM
system_stm32f3xx.c i did not change, since HSE_VALUE is defined inside stm32f3xx.h file. ( for STM32F4XX it is defined inside system_stm32f4xx.c file)
startup_stm32f3xx.s i will not gonna touch, it's to complicated for me. I was trying to add code for hard fault handler, but it just generating compiler errors HardFault_Handler PROC EXPORT HardFault_Handler IMPORT HardFault_Handler_C TST LR, #4 ITE EQ MRSEQ R0, MSP MRSNE R0, PSP B HardFault_Handler_C ENDP ; HardFault_Handler Error[51]: Can't be both PUBLIC and EXTERN