I do have a project based on ProcessorExpert where I now start with some calculation.
I'm using
Up to now everything worked fine so far. Now I'm trying to scale some measurement values and with the first math instruction I enter hardware fault exception (vector #3).
I guess that I doing something wrong in software but I don't know what.
My settings may be wrong - but floating point settings seems to be OK.
Compiler:
-c $(EDNAME) -mthumb -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard
-gdwarf-2 -Wall -ffast-math -fomit-frame-pointer
-I$(IRFDIR)\Generated_Code -I$(IRFDIR)\Sources
-I"%PROCESSOR_EXPERT_PATH%\lib\Kinetis\iofiles"
-I"%PROCESSOR_EXPERT_PATH%\lib\Kinetis\pdd\inc"
-D__GNU__ -D__PE__
Linker:
-mthumb -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard
-Wl,-T,$(INDPATH) -Wl,-Map,$(OUTPUTDIR)\kernel.map,
--gc-sections -o $(OUTPUTPATH)
I do not understand why an instruction
vldr.32 s14,[r3]
causes the hardware fault excpetion. The CPU has an FPU, so it should work.
It would be great if anybody can help me with that.
Thank you very much
Thomas
解決済! 解決策の投稿を見る。
Hi Thomas
CPACR |= (0xf << 20); // enable access to FPU
Regards
Mark
Professional support for Kinetis: http://www.utasker.com/index.html
Remote desktop one-on-one coaching: http://www.utasker.com/services.html
Getting started to expert videos: https://www.youtube.com/results?search_query=utasker+shorts
Hi Mark, Earl,
thanks for your answers.
I now find the SCB_CPACR block and can use it to setup FPU in C.
As beginner with ARM it was a good lessen to learn about standard parts and ARM information center :-)
regards
Thomas
Hello Mark,
thanks a lot you for your hint - it solved my problem.
If someone has the same problem and is reading this thread and now searching for CPACR register: I neither find in in my headers nor is it documented in the Kinetis K22 Sub-Family Reference Manual. Use "CPACR" to find other threads which provide an assembler snippet to enable FPU access
Thanks again to Mark!
Regards
Thomas
Thomas
The Cortex-M4 core is not described in the user's manual because it is a 'standard' part from ARM. That means that anything to do with the core is fully documented by ARM at their "ARM Information Center". For enabling floating point see http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0439b/BEHBJHIG.html
Regards
Mark
P.S. Since the register is memory mapped it doesn't need any special instructions to access it so I would avoid assembler code (to ensure portability). If your framework doesn't supply it just add
#define CORTEX_M4_BLOCK 0xe000e000
#define CPACR *(unsigned long *)(CORTEX_M4_BLOCK + 0xd88) // Co-processor Access Control Register
FYI, the MK22FA header file I access calls that SCB_CPACR, as part of the whole System-Control-Block at 0xE000E000
Hi Thomas
CPACR |= (0xf << 20); // enable access to FPU
Regards
Mark
Professional support for Kinetis: http://www.utasker.com/index.html
Remote desktop one-on-one coaching: http://www.utasker.com/services.html
Getting started to expert videos: https://www.youtube.com/results?search_query=utasker+shorts