ke0x startup code differences

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

ke0x startup code differences

Jump to solution
840 Views
otavioborges
Contributor III

Hello all,

Working with both KE02 and KE04 on KSDK 1.x.x I stumbled on a error on startup code. On "system_MKE02Z2.h" clock configuration read the following:

(...)
#define CPU_XTAL_CLK_HZ 12000000u /* Value of the external crystal or oscillator clock frequency in Hz */
#define CPU_INT_CLK_HZ 32768u /* Value of the internal oscillator clock frequency in Hz */
#define DEFAULT_SYSTEM_CLOCK 40000000u /* Default System clock value */

And then on "system_MKE02Z2.c" the "SystemCoreClockUpdate(void)" method reads the following:

void SystemCoreClockUpdate (void) {

(...)

   } else {
      ICSOUTClock = CPU_INT_CLK_HZ; /* The internal reference clock is selected */
   }
   ICSOUTClock *= 1280u; /* Apply 1280 FLL multiplier */
} else if ((ICS->C1 & ICS_C1_CLKS_MASK) == 0x40u) {

Althought those parameters meet the KE04x sub-family when starting an KE02 project the KDS link the same files but, accordingly to KE02 Reference Manual, the factory trim value for the internal oscillator is 31.250KHz and FLL multiplier is in fact 1024 instead of 1280.

Tags (2)
1 Solution
607 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Otavio Borges,

    Thank you for your information update.

    I also create a KE02 bare mental KDS project, without the PE.

   In system_MKE02Z2.c, the FLL factor is 1280, it is wrong, it should be 1024, I will report it to the KDS department.

  But in system_MKE02Z2.h, the default code is not like you, this is my code:

pastedImage_1.png

But, in this code,

The CPU_INT_CLK_HZ is not correct.

From the datahseet, we can find the internal trimmed IRC is 31.25, NOT 32.768KHZ.

pastedImage_1.png

Default_system_clock should be:31.25k*1024 /2=32000k/2=16Mhz.

Please take care of these two points.

  


Have a great day,
Kerry

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

View solution in original post

4 Replies
607 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Otavio Borges,

    As I know, the KE series still doesn't have the KSDK code, it just have the

FRDM-KEXX Driver Library Package 

  Please use this code.

  I don't know where you download the KE02 and KE04 on KSDK 1.x.x, did you download it from the official website?

  Anyway, you need to refer to the according datasheet, the KE02 trimmed factory value is 31.25Khz, KE04 is 37.5Khz.

   KE02 FLL factor is 1024, KE04 FLL factor is 1280.

Wish it helps you!


Have a great day,
Kerry

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

0 Kudos
607 Views
otavioborges
Contributor III

Hello Kerry,

I used the code that came along KDS 3. I created a new project, selected KSDK 1.x.x and the KE02Z8xxx4 family from the device tree. There are no peripheral drivers, just registers and register's bit mapping, startup (clock configuration) code.

The code is the one that came along with the IDE. As I have a simple project only the basic register mapping is enough for me, that's why I didn't use the KEXX driver library.

0 Kudos
608 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Otavio Borges,

    Thank you for your information update.

    I also create a KE02 bare mental KDS project, without the PE.

   In system_MKE02Z2.c, the FLL factor is 1280, it is wrong, it should be 1024, I will report it to the KDS department.

  But in system_MKE02Z2.h, the default code is not like you, this is my code:

pastedImage_1.png

But, in this code,

The CPU_INT_CLK_HZ is not correct.

From the datahseet, we can find the internal trimmed IRC is 31.25, NOT 32.768KHZ.

pastedImage_1.png

Default_system_clock should be:31.25k*1024 /2=32000k/2=16Mhz.

Please take care of these two points.

  


Have a great day,
Kerry

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

607 Views
otavioborges
Contributor III

I may have upload the altered code from my project (in each I was trying to use an 12MHz external crystal (that wouldn't fit the FLL input freq. range, later I changed to the internal clock reference, that's when I found out the difference). That's why CPU_XTAL_CLK_HZ values differ. I don't know if there are any differences in KE06 sub-family.

Anyway, do you know why NXP doesn't have plans for embedding KSDK 2.x.x KEXX drivers on KDS, Kerry (seems that KEXX driver library did almost all the job)?

I've chosen KE04 and KE02 on my projects because they are one of the cheapest M0 MCUs, on top of that they can be used with 5V source, sometimes quite more useful than +3V3. They seem fit to various applications in a lot of ways and, as I checked, they not close to End of Life.

One last thought, I'm designing a development board using KL26 as debbuger/programmer (OpenSDA + openocd) and KE02 as target, and had a lot of troubles making the openocd shipped with KDS 3 to work with the target. Even though openocd latest version already has support for KEXX sub-family. Had to tweak around the IDE to update openocd to version 0.9.0.

0 Kudos