2011-06-16 05:48 AM
hi.
i am using the STM32f103 chip and i am having all sord of problem that takes me to the Hard Fault inturpt . when i check the SCB->CFSR register i am getting all sord of errors like : ''the processor has attempted to access a coprocessor.'' or ''The processor has attempted to execute an undefined instruction.'' i read alot and i found that i can change the privilege mode for safty reason so that the software cannot accsess importent register in the cpu i am hoping that it will help me solve the problems. my question is how do i change that from what i can find i need to change the control register but how can i chnage that what is he called? i found all that data here by the way: http://www.st.com/stonline/products/literature/pm/15491.pdf thanks.2011-06-22 09:37 AM
Hex might be more helpful, pinning down where in your code the failure is occurring. the values of PC seem to be quite different, however LR seems to be quite uniform, what subroutine is being called at that point?
You'll need to look at the instructions being executed a PC during the failure, and look at the registers being used, and their values and the limits of the memory regions they are touching. You might need to dump out additional registers, as the fault is only pushing a subset. Both int's and long's in the current context are 32-bit values. static const char Hex[] = ''0123456789ABCDEF''; void debug_longhex(unsigned long x) { debug_char(Hex[((x >> 28) & 0x0F)]); debug_char(Hex[((x >> 24) & 0x0F)]); debug_char(Hex[((x >> 20) & 0x0F)]); debug_char(Hex[((x >> 16) & 0x0F)]); debug_char(Hex[((x >> 12) & 0x0F)]); debug_char(Hex[((x >> 8) & 0x0F)]); debug_char(Hex[((x >> 4) & 0x0F)]); debug_char(Hex[((x >> 0) & 0x0F)]); debug_char(0x0d); }2011-06-22 10:07 AM
how do i know ''what subroutine is being called at that point?''
and how do i do that: ''You'll need to look at the instructions being executed a PC during the failure, and look at the registers being used, and their values and the limits of the memory regions they are touching. You might need to dump out additional registers, as the fault is only pushing a subset.''? what does it means:''the fault is only pushing a subset.'' thanks.2011-06-22 11:20 AM
Get a disassembly window, or listing of the code you are running. Correlate the address of the failure(s) with the addresses/instructions/registers in your compiled code.
The LR register points to the next instruction after the BL subroutine call, ie the return address. The ARM architecture has 16 32-bit registers (technically it has more), the hard fault mechanism within the processor is pushing 7 of them on the stack, the remainder are still there. If the faulting instruction is using R4, you want to know the content of that register.2011-06-22 11:40 AM
2011-06-23 12:49 AM
2011-06-23 06:53 AM
what can i understand from that?
Without contemporaneous fault and register data, probably not much.2011-06-24 12:00 AM
hi.
after many test i found that it is probably caused by electromagnetic . is there somthing i can do about it? andi am using the STM32F103 now how do i know its resistence to EMI? maybe there is abetter EMI STM32 chip. how do know for each one the EMI resistence? thanks.2011-06-24 09:12 AM
Is this a problem with GPIO's or that the supply is being glitched repeatedly. If you have a hideously noisy supply, you might want to look at that first. If you can quantify the amount on noise you need to handle, you could use that number to qualify which parts might tolerate that.
Is there separation/isolation between the circuits pulling milli-amps and those pulling more industrial currents? You need to examine the processor state, and the instructions being executed, at each faulting condition. You must decide if the fault is a result of external interference, or if you have a software error/bug which is causing the processor to touch memory it should not (ie stack out of bounds, indexing beyond an array, loading an uninitialized variable/pointer from the stack or other structures). You will need to sit at the debugger and pin down a cause(s), I don't think this can be done remotely.2011-06-25 10:41 PM
2011-06-27 11:12 AM
A PDF might be helpful for those without access to OrCad.
You have a single 3.3V supply. What does that look like on that, how many millivolts of noise do you have in that supply? How much noise is in the 11V supply? How many layers does the PCB have? Doesn't the design manual call for 4.7 uF of bulk capacitance on VDD3 of the STM32? If you can't separate out the supplies, look at adding bulk and decoupling capacitor at components that have large and instantaneous current requirements.