Clock configuration on K64 using KDS

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

Clock configuration on K64 using KDS

Jump to solution
1,307 Views
Kewal
Contributor IV

We are trying very hard to do the clock configuration. However after doing the required changes on the clock manager and importing all the generated files to the IAR project. We are still not able to get the required clock working or atleast not able to get any value when we call out

 

  uint32_t TEMP = 0;

 

  TEMP = CLOCK_SYS_GetSystemClockFreq();

 

so should we do any clock Init by calling out CLOCK_SYS_SetConfiguration() actually got to see that CLOCK_SYSupdateconfiguration is never called nor the clock init. Any hints about getting out of this problem The clock configuration was done as shown in snapshots below.

 

90543_90543.JPGCapture.JPG90544_90544.JPGCapture2.JPG90545_90545.JPGCapture3.JPG

Labels (1)
0 Kudos
1 Solution
669 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hi Kewal:

Is VBAT pin powered in your custom hardware? Otherwise the execution will enter a hardfault when trying to access any RTC register.

Regards!

Jorge Gonzalez

View solution in original post

0 Kudos
7 Replies
669 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Kewal,

- What's the version of KDS and KSDK ?

- Do you want copy the code generated on KDS to IAR ? Does it can work well on  KDS ?

BR

Alice

0 Kudos
669 Views
Kewal
Contributor IV

Alice,

I am using KDS 3.0 with KSDK 1.2.0 with EWARM 7.2.

Right now i am stuck with a hardfault error, as I am trying to use the same startup file generated by KDS (PE), So I am not sure where exactly or how to find the cause of the error. any inputs on this direction.

thanks,

Kewal

0 Kudos
669 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Kewal,

- What hardfault error ? could you please screenshot it and show me ?

- About the clock of SDK , after configure it on PE,  generate code , the function  SystemInit (void) of code will

configure the clock  refer to the configuration on PE , you can set on breakpoint before download the project , you can see

it run to this function :

pastedImage_0.png

And  You can still use those with the clock_manager APIs

(CLOCK_SYS_Init(), CLOCK_SYS_SetConfiguration(), CLOCK_SYS_UpdateConfiguration(), etc) to configure the clock .

- About the clock  of sdk , you can also refer to here :

Clock configuration with KDS3.0/KSDK1.2.0

Hope it helps

Alice

0 Kudos
669 Views
Kewal
Contributor IV

Alice,

Those links were of help to me.

I sort of fixed the problem and but sort of not fixed the problem as well. :smileyhappy:

I have the RTC osc enabled as you could see and the hardfault error is coming right when it hits the if condition(below in bold)

#ifdef CLOCK_SETUP

  if((RCM->SRS0 & RCM_SRS0_WAKEUP_MASK) != 0x00U)

  {

    if((PMC->REGSC & PMC_REGSC_ACKISO_MASK) != 0x00U)

    {

       PMC->REGSC |= PMC_REGSC_ACKISO_MASK; /* Release hold with ACKISO:  Only has an effect if recovering from VLLSx.*/

    }

  } else {

#ifdef SYSTEM_RTC_CR_VALUE

    SIM_SCGC6 |= SIM_SCGC6_RTC_MASK;

   if ((RTC_CR & RTC_CR_OSCE_MASK) == 0x00U) { /* Only if the OSCILLATOR is not already enabled */

      RTC_CR = (uint32_t)((RTC_CR & (uint32_t)~(uint32_t)(RTC_CR_SC2P_MASK | RTC_CR_SC4P_MASK | RTC_CR_SC8P_MASK | RTC_CR_SC16P_MASK)) | (uint32_t)SYSTEM_RTC_CR_VALUE);

      RTC_CR |= (uint32_t)RTC_CR_OSCE_MASK;

      RTC_CR &= (uint32_t)~(uint32_t)RTC_CR_CLKO_MASK;

    }

#endif

According to me everything is fine on the hardware side. I am able to run the same configuration on the other hardware with almost same configuration.

Can you direct to understand how exactly the RTC works of there is something missing?

0 Kudos
669 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Kewal,

Yes , Jorge Gonzalez is right , you can refer to the demo aboard FRDM-K4:

pastedImage_0.png

And i recommend you after enable the oscillator , delay some time to wait to all the 32KHZ to stabilize as this:

  /*Enable the oscillator*/

  RTC_CR |= RTC_CR_OSCE_MASK;

  /*Wait to all the 32 kHz to stabilize, refer to the crystal startup time in the crystal datasheet*/

  for(i=0;i<0x60000;i++);

Hope it helps

Alice

669 Views
Kewal
Contributor IV

Alice,

thanks that helps.

It was actually the VBAT which was actually not connected to the 3.3V and the RTC register was being accessed.

0 Kudos
670 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hi Kewal:

Is VBAT pin powered in your custom hardware? Otherwise the execution will enter a hardfault when trying to access any RTC register.

Regards!

Jorge Gonzalez

0 Kudos