Problem with memory in SDK 2.5.0 on LPC54114

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

Problem with memory in SDK 2.5.0 on LPC54114

632 Views
ben_freudberg
Contributor I

I'm having an issue when running

'CLOCK_SetupPLLData()'

from 'fsl_clock.c'. This function calls a private function:

'CLOCK_GetPllConfig()'

which relies on a static variable defined outside the body of the function at line 1220:

'static uint32_t s_PllSetupCacheIdx = 0U;'

The problem appears to be that the value is not properly initialized to 0. Debugging shows that it's value is 0x23806123 at memory address 0x20000058 when read the first time in the 'CLOCK_GetPllConfig()' function (the only function that uses this variable as far as I can tell).

Several other variables declared at the same time also do not have the correct initialization values. Does anyone have any ideas about how to figure out the problem?

Thanks!

EDIT:

I think my problem is related to memory allocation in the .ld file. I've got to do some more research.

Labels (2)
0 Kudos
3 Replies

559 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

Ben Freudberg

This is because you defined s_PllSetupCacheIdx but you never use it in your code. so compiler optimized it.

To fix it. define a dummy volatile type local variable. then assign s_PllSetupCacheIdx to it.

see my attached video.


Have a great day,
Jun Zhang

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

559 Views
ben_freudberg
Contributor I

Thanks for your reply. The problem doesn't occur in my code; 'fsl_clock.c' is from the SDK (and it's not the problem either really, just the the location where it becomes evident). My memory map in my linker script is wrong so the variable is getting overwritten before it is read.

0 Kudos

559 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

OK. thanks.

0 Kudos