TWR-K20D72M: init_bsp.c: two clock configurations: why?

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

TWR-K20D72M: init_bsp.c: two clock configurations: why?

1,555件の閲覧回数
markkalior
Contributor II

Does anyone know why there are two:

_bsp_set_clock_configuration(BSP_CLOCK_CONFIGURATION_AUTOTRIM);   // This seems to use the internal clock

then

_bsp_set_clock_configuration(BSP_CLOCK_CONFIGURATION_STARTUP);   // ...which is BSP_CLOCK_CONFIGARATION_72MHZ.   Which uses the external crystal.  

Why not just have the STARTUP?

0 件の賞賛
返信
6 返答(返信)

1,372件の閲覧回数
danielchen
NXP TechSupport
NXP TechSupport

Hi

Before auto trimming process, the MCG should be set to one of the following modes (FEE,FBE,BLPE,PEE,PBE), and value is in the range <8; 16>Mhz.

the first configuration, the MCG is switched to  (PEE, 12M), next auto trimming process started.

the second configuration, the MCG is switched to (PEE, 72M)


Have a nice day,
Daniel

0 件の賞賛
返信

1,372件の閲覧回数
markkalior
Contributor II

Daniel;

Okay, I understand what code says, but is it required?    Can the MK20DX256VMC10 be configured directly to PEE, 100Mhz?    Why does the evaluation board set the MCG in two stages?   Will the part not start, if just one MCG config is used?

Mark 

0 件の賞賛
返信

1,372件の閲覧回数
DavidS
NXP Employee
NXP Employee

Hi Mark,

Short answer....you do not need to do the autotrim step.

Regards,

David

0 件の賞賛
返信

1,372件の閲覧回数
markkalior
Contributor II

David;

Thanks.   ....but, do i need configure the MCG twice?

I have an external crystal why not configure the MCG once?

Do you know why the code configures the MCG twice?   The first with internal crystal, then again with external crystal?   Does the external crystal ciruit sometimes doesn't work or start?  So, if you have the internal crystal working the circuit can limp along?

Mark

0 件の賞賛
返信

1,372件の閲覧回数
DavidS
NXP Employee
NXP Employee

Hi Mark,

Sorry not to be clear.

You don't need to call MCG twice.

To skip the autotrim feature do the following in init_bsp.c:

    /* MCG initialization and internal oscillators trimming */

#if 0 //DES 0=test, 1=default code

    if (CM_ERR_OK != _bsp_set_clock_configuration(BSP_CLOCK_CONFIGURATION_AUTOTRIM))

    {

        return MQX_TIMER_ISR_INSTALL_FAIL;

    }

    if (CM_ERR_OK != _bsp_osc_autotrim())

    {

        return MQX_TIMER_ISR_INSTALL_FAIL;

    }

#endif

    /* Switch to startup clock configuration */

    if (CM_ERR_OK != _bsp_set_clock_configuration(BSP_CLOCK_CONFIGURATION_STARTUP))

    {

        return MQX_TIMER_ISR_INSTALL_FAIL;

    }

Regards,

David

0 件の賞賛
返信

1,372件の閲覧回数
markkalior
Contributor II

Thanks.