LPC4357: how to setting M4 core frequency at most 204MHz?

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

LPC4357: how to setting M4 core frequency at most 204MHz?

Jump to solution
1,570 Views
astrogreco
Contributor II

I'm trying to implement PLL1 to set the main clock frequency for the M4 core at most 204MHz.
To set the PLL1 with the PLL1_CTRL register there are no problems. I perform the following instructions:
1) Set AUTOBLOCK
2) Set M and N
3) wait LOCK
4) Set DIRECT
5) wait LOCK
6) clear BYPASS
7) wait LOCK

Each setting is set and the LOCK in PLL1_STAT is always 0.
Unfortunately, when I finally select the CLK_SEL of BASE_M4_CLK at 0x9, the next instruction is no longer executed.
Even if I do this last setting before setting up the PLL1, it does the same problem.

What could be the reason?

Labels (1)
1 Solution
1,429 Views
bernhardfink
NXP Employee
NXP Employee

I must admit that I'm a little bit out of business for this LPC4300 platform, but after a short look into your code I have the follwing recommendations:

  • If you use a variable to poll for a status which changes with an event from the outside, then declare your variable with the keyword volatile. Otherwise the compiler could do some ugly optimization.
  • Don't poll on register flags (like the lock bit) in a while loop. At least add some NOP() in the while loop.
  • If it is recommended to wait after a specific setting, then do it with a simple wait() function. For safety reasons you can then read the lock bit to confirm that it is set.

Regards,

Bernhard.

View solution in original post

4 Replies
1,429 Views
bernhardfink
NXP Employee
NXP Employee

A few reasons for this:

  • You execute from internal flash and after switching to 204MHz the waitstate setting do no longer fit. So set the wait states to the maximum first and then switch to higher frequency.
  • Other components connected to this PLL output might cause a crash if they are not prepared for this step
  • You execute from external QSPI flash and the interface speed does no longer match the specifcation when switching to 204MHz
  • Power supply problems due to the higher power demand at 204MHz (in case it's your own board development)

Regards,

Bernhard.

1,429 Views
astrogreco
Contributor II

Thanks for the reply. I set the PLL as the first operation.
I solved, the problem was that the PLL1 was not enabled, ie bit 0 (PD) was not clear.
However now it works but I have to skip the wait LOCK phases. In fact, the LOCK bit of PLL1_STAT is never set to 1.
I set the PLL1_CTRL register in several steps, but when I check the LOCK it is always 0.
If I skip the LOCK check the process goes on all the same and everything works.

Attached the function I use.

What could be the problem of LOCK bit?

0 Kudos
Reply
1,430 Views
bernhardfink
NXP Employee
NXP Employee

I must admit that I'm a little bit out of business for this LPC4300 platform, but after a short look into your code I have the follwing recommendations:

  • If you use a variable to poll for a status which changes with an event from the outside, then declare your variable with the keyword volatile. Otherwise the compiler could do some ugly optimization.
  • Don't poll on register flags (like the lock bit) in a while loop. At least add some NOP() in the while loop.
  • If it is recommended to wait after a specific setting, then do it with a simple wait() function. For safety reasons you can then read the lock bit to confirm that it is set.

Regards,

Bernhard.

1,429 Views
astrogreco
Contributor II

Thank you very much. I solved the problem. NOP operations  are required. Now after every PLL1 setting the LOCK bit is set to 1 and the process goes on correctly.

Attached the function used

0 Kudos
Reply