emwin_M3.lib works but emwin_M4F.lib does not works for EA4357 board..

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

emwin_M3.lib works but emwin_M4F.lib does not works for EA4357 board..

1,242 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by chetansd83 on Wed Dec 30 22:35:37 MST 2015
Dear Friends,

I have recently started working of Embedded Artist board having LPC4357 controller.

I am using my own TFT of 1024x796 resolution and emwin version 5.30.

I have configured lcdconf.c and GUIconf.c files and developed small application. It works fine when I attached emwin_M3.lib file in my KEIL compiler, but hence the core of the controller is M4F It should be working with emwin_M4F.lib file.

When I use emwin_M4F.lib program stops working, I don't get debug messages on Uart port which is placed before any usage library functions.

Please guide me where I can be wrong or it is ok to use M3 lib to lpc4357?

When I debug the code, It goes to Hard fault. Here is the screen shot of the debug screen..


Thanks
Chetan
Labels (1)
0 Kudos
3 Replies

1,137 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by bavarian on Wed Jan 13 06:34:23 MST 2016
You need to enable the FPU manually somewhere in your code. There is a fundamental difference between "use FPU" and "enable FPU". If you tell the compiler to use it, then it will generate code with FPU instructions and will use the registers inside the FPU for whatever purposes. If you then don't enable it your application code, then the system will stop on the first appearance of an FPU instruction or a FPU register.

As you can't really control when the compiler starts using the FPU, you should do this in a quite early stage, e.g. in sysinit.c, directly after the assembler startup code.
Call a function like this:

/* Early initialization of the FPU */
void fpuInit(void)
{
#if __FPU_PRESENT != 0
// from arm trm manual:
//                ; CPACR is located at address 0xE000ED88
//                LDR.W R0, =0xE000ED88
//                ; Read CPACR
//                LDR R1, [R0]
//                ; Set bits 20-23 to enable CP10 and CP11 coprocessors
//                ORR R1, R1, #(0xF << 20)
//                ; Write back the modified value to the CPACR
//                STR R1, [R0]

volatile uint32_t *regCpacr = (uint32_t *) LPC_CPACR;
volatile uint32_t *regMvfr0 = (uint32_t *) SCB_MVFR0;
volatile uint32_t *regMvfr1 = (uint32_t *) SCB_MVFR1;
volatile uint32_t Cpacr;
volatile uint32_t Mvfr0;
volatile uint32_t Mvfr1;
char vfpPresent = 0;

Mvfr0 = *regMvfr0;
Mvfr1 = *regMvfr1;

vfpPresent = ((SCB_MVFR0_RESET == Mvfr0) && (SCB_MVFR1_RESET == Mvfr1));

if (vfpPresent) {
Cpacr = *regCpacr;
Cpacr |= (0xF << 20);
*regCpacr = Cpacr;// enable CP10 and CP11 for full access
}
#endif /* __FPU_PRESENT != 0 */
}


The M3 library will work, no matter if you use for the rest of your code the FPU or not.
The M4F lib does only work when the FPU is there [u]and[/u] enabled.

Regards,
NXP Support Team
0 Kudos

1,137 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by chetansd83 on Thu Dec 31 23:17:21 MST 2015
Thanks for your reply...

I have enabled the Target option in KEIL compilor to "USE FPU". Screen shot is attached...

Above solution doesn't worked.

Do I need to modify the startup file...? I m new to startup file related stuff.

Please guide me what I need to do further. I have attached my startup file too...

Thanks again

Chetan

0 Kudos

1,137 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by vtw.433e on Thu Dec 31 02:07:48 MST 2015
Have you initialised the floating point unit? M4F == M4 with floating point unit. IIRC the floating point unit need to be initailiased in your startup code.
0 Kudos