Error Changing from FEI to FBI with KSDK on FRDM-KL25Z

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

Error Changing from FEI to FBI with KSDK on FRDM-KL25Z

Jump to solution
623 Views
ives
Contributor I

Hi!

 

I have a FRDM-KL25Z and I'm trying to change the power mode from FEI to FBI. I want to run on FBI mode with a internal frequency of 4 MHz. I've used the following code to do the job:

 

CLOCK_HAL_SetOutDiv1(SIM, 0);
CLOCK_HAL_SetOutDiv4(SIM, 4);
mcg_mode_error_t mcgModeError = CLOCK_HAL_SetFbiMode(MCG, kMcgDcoRangeSelLow, kMcgIrcFast, 1, NULL);

 

The problem is that the firmware stops running during the CLOCK_HAL_SetFbiMode function. I've added a breakpoint inside this function and I saw that the problem is in the following line:

 

    MCG_WR_C1(base, (MCG_RD_C1(base) & ~(MCG_C1_CLKS_MASK | MCG_C1_IREFS_MASK))

                  | (MCG_C1_CLKS(kMcgClkOutSrcInternal)  /* CLKS = 1 */

                  | MCG_C1_IREFS(kMcgFllSrcInternal))); /* IREFS = 1 */

 

I realized that if I change the CLOCK_HAL_SetFbiMode function, to force it to write on MCG_C1 register after writing on MCG_C2 register, the firmware works!

 

Do you think there is a problem in CLOCK_HAL_SetFbiMode function?

Labels (1)
0 Kudos
1 Solution
477 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello ives,

For your question , i have some suggestions :

1) Which version of KSDK do you use ? i recommend you use the latest one ksdk1.3, you can download it in the web.

2) If you want use the KSDK APIs configure the clock mode ,i recommend you sue the function "CLOCK_SYS_SetConfiguration()",

it configure the SIM SIM  .etc clock module  ,it include the function "CLOCK_HAL_SetFbiMode" ,you can find this function here :

Freescale\KSDK_1.3.0\platform\system\src\clock\MKL25Z4\fsl_clock_MKL25Z4.c

(in general , do not directly use the  "HAL " functions, these HAL functions are call by the driver fucntions. )

3)If you do not want use the ksdk driver,  in the file of "system_MKL25z4.c" and "system_MKL25Z4.h" have defined all of the clock mode ,

you can refer to :

pastedImage_1.png

4) You can also use the PE configure the clock , i thin it is easy .

If use the latest version still can not work well,  please contact me without any hesitate .

Hope it helps

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


Have a great day,
Alice

View solution in original post

3 Replies
478 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello ives,

For your question , i have some suggestions :

1) Which version of KSDK do you use ? i recommend you use the latest one ksdk1.3, you can download it in the web.

2) If you want use the KSDK APIs configure the clock mode ,i recommend you sue the function "CLOCK_SYS_SetConfiguration()",

it configure the SIM SIM  .etc clock module  ,it include the function "CLOCK_HAL_SetFbiMode" ,you can find this function here :

Freescale\KSDK_1.3.0\platform\system\src\clock\MKL25Z4\fsl_clock_MKL25Z4.c

(in general , do not directly use the  "HAL " functions, these HAL functions are call by the driver fucntions. )

3)If you do not want use the ksdk driver,  in the file of "system_MKL25z4.c" and "system_MKL25Z4.h" have defined all of the clock mode ,

you can refer to :

pastedImage_1.png

4) You can also use the PE configure the clock , i thin it is easy .

If use the latest version still can not work well,  please contact me without any hesitate .

Hope it helps

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


Have a great day,
Alice

477 Views
ives
Contributor I

Thanks Alice! I am using KSDK 1.3. Good advice about the function CLOCK_SYS_SetConfiguration(). Have a great weekend.

0 Kudos
477 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hi ives,

Welcome !:smileyhappy:

BR

Alice

0 Kudos