Possible error in clocks tool output file clock_config.c

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

Possible error in clocks tool output file clock_config.c

Jump to solution
1,550 Views
jaldridge
Contributor II

Working with the MIMXRT1021 EVK board with MCUXpresso and gcc.

I'm changing the clock frequency to conform to the lower maximum core clock for the industrial temperature rated parts.

The auto-generated code in clock_config.c may have an issue when changing the source and frequency of the AHB clock. In this case is is necessary to not declare SKIP_SYSCLK_INIT. The generated code is:

#ifndef SKIP_SYSCLK_INIT
 /* Disable Semc clock gate. */
 CLOCK_DisableClock(kCLOCK_Semc);
 /* Set SEMC_PODF. */
 CLOCK_SetDiv(kCLOCK_SemcDiv, 5);
 /* Set Semc alt clock source. */
 CLOCK_SetMux(kCLOCK_SemcAltMux, 0);
 /* Set Semc clock source. */
 CLOCK_SetMux(kCLOCK_SemcMux, 0);
#endif
  1. (Simple issue for information). If this is compiled with no optimization then the inline functions are treated as normal functions. If the stack pointer is in external RAM this causes a problem when the SEMC clock is disabled. Perhaps this could be highlighted in a comment.
  2. There is no corresponding call to CLOCK_EnableClock(kCLOCK_Semc). This can be added by hand, but the change is over-written if the file is updated again from the tool.

In point (2). Have I missed something? If not then could the call to CLOCK_EnableClock(kCLOCK_Semc) be added to this section of code as an output from the Clocks tool?

0 Kudos
Reply
1 Solution
1,425 Views
jeremyzhou
NXP Employee
NXP Employee

Hi John Aldridge,

Thanks for your reply.
Yes, you're right, it conditionally depending on whether external RAM is used.


Have a great day,
TIC

-------------------------------------------------------------------------------
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.
-------------------------------------------------------------------------------

View solution in original post

3 Replies
1,425 Views
jaldridge
Contributor II

Hi Jeremy. Thanks for your reply. Unfortunately the strategy of enabling the clock in the peripheral's init function does not work for the special case of the SEMC. This peripheral controls access to the external RAM, which is used within the function "BOARD_BootClockRUN" in clock_config.c in at least two places. Firstly if the stack is in external memory, and secondly if the variable SystemCoreClock is in external memory. For this reason the SEMC clock needs to be enabled in "BOARD_BootClockRUN", probably conditionally depending on whether external RAM is used.

Best regards

John

0 Kudos
Reply
1,426 Views
jeremyzhou
NXP Employee
NXP Employee

Hi John Aldridge,

Thanks for your reply.
Yes, you're right, it conditionally depending on whether external RAM is used.


Have a great day,
TIC

-------------------------------------------------------------------------------
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.
-------------------------------------------------------------------------------

1,425 Views
jeremyzhou
NXP Employee
NXP Employee

Hi John Aldridge,

Thank you for your interest in NXP Semiconductor products and for the opportunity to serve you.
Q1) (Simple issue for information). If this is compiled with no optimization then the inline functions are treated as normal functions. If the stack pointer is in external RAM this causes a problem when the SEMC clock is disabled. Perhaps this could be highlighted in a comment.
-- It's a good suggestion, I'll give this feedback to the SDK team.
Q2) There is no corresponding call to CLOCK_EnableClock(kCLOCK_Semc). This can be added by hand, but the change is over-written if the file is updated again from the tool.
-- The CLOCK_EnableClock is usually be called in the corresponding peripheral's initialization function。
Hope this is clear.
Have a great day,
TIC

-------------------------------------------------------------------------------
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.
-------------------------------------------------------------------------------