<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: imx233 How to correctly initialise the CPU clock? in i.MX Processors</title>
    <link>https://community.nxp.com/t5/i-MX-Processors/imx233-How-to-correctly-initialise-the-CPU-clock/m-p/239441#M19668</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the advice.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As far as I can tell by looking at the code, bit 20 (AUTO_SLOW_MODE) of &lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;HW_CLKCTRL_HBUS is 0 and thus off (the default). There are other auto-slow &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;modes available, so I will specifically set them all to OFF and report back &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;to you later.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For info, I was specifically using the HCLK counter to measure the frequency of clk_h, so I could indirectly measure clk_p ( clk_h = clk_p / 3 ). As DIGCTL_MICROSECONDS counter is driven directly from the 24MHz, I can't use that to measure clk_p.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've made a further discovery since my original post. I wrote a loop in assembly that toggled the LED pin, instead of using the HCLK counter, so that the execution speed of the ARM could be measured directly. Based on an average of 1.5 CPI for an ARM9 core, there should be 9 clock cycles between each change of LED state. Again measurements do not match the theory and, confusingly, if I double the clk_p-to-clk_h divide ratio from 3 to 6, the LED flash period DOUBLES !!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was not expecting this. Why should clk_h affect the execution speed of a tight loop of ARM assembly code???&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Really confused now.&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 05 Aug 2013 12:30:28 GMT</pubDate>
    <dc:creator>chrissmith</dc:creator>
    <dc:date>2013-08-05T12:30:28Z</dc:date>
    <item>
      <title>imx233 How to correctly initialise the CPU clock?</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/imx233-How-to-correctly-initialise-the-CPU-clock/m-p/239439#M19666</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here's hoping you can help!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've a project that I was running under Linux on an (olimex) imx233 board that I need to run bare, to reduce the resource use.&lt;/P&gt;&lt;P&gt;When I run it bare (having done all the initialisation I thought necessary), it appears much slower, as though the CPU is not running at the desired 454 MHz.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To prove this, I wrote the following test program to initialise the imx23 CPU clock (clk_p) to 454 MHz, set clk_h to clk_p / 3, and toggle a GPIO pin at clk_h / 8. My last round of testing seemed to indicate that clk_p was actually at 42 MHz, but I confess I've gone round and round in my testing, and have kind of lost the plot now, so 42 could be wrong!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm currently doing this without JTAG until my serial JTAG arrives.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This code is not a million miles away from the u-boot code. This should compile with gcc and the imx-bootlets mach-mx23/includes/ files, and boot with imxbootlets.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Am I right in thinking that clk_p is the CPU clock?&lt;/P&gt;&lt;P&gt;Can someone confirm my findings and/or point out the error of my ways????&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yours, really stuck,&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="_jivemacro_uid_13755553347464753 jive_text_macro jive_macro_code" jivemacro_uid="_13755553347464753" modifiedtitle="true"&gt;
&lt;P&gt;#include "regsdigctl.h"&lt;/P&gt;
&lt;P&gt;#include "regsclkctrl.h"&lt;/P&gt;
&lt;P&gt;#include "regspower.h"&lt;/P&gt;
&lt;P&gt;#include "regstvenc.h"&lt;/P&gt;
&lt;P&gt;#include "regspinctrl.h"&lt;/P&gt;
&lt;P&gt;#include "regs.h"&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;#define LED_OLIMEX (1 &amp;lt;&amp;lt; 1)&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;/* -------------------------------------------------------------------------- */&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;void delay_us (int us)&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; olatile int start = HW_DIGCTL_MICROSECONDS_RD();&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; while (HW_DIGCTL_MICROSECONDS_RD() - start &amp;lt; us) { }&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;/* -------------------------------------------------------------------------- */&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;int main(void)&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; unsigned int value;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Configue PIO for LED */&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; BW_PINCTRL_MUXSEL4_BANK2_PIN01( 0x3 ); // Enable GPIO&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; HW_PINCTRL_DOUT2_SET( LED_OLIMEX );&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; HW_PINCTRL_DOE2_SET ( LED_OLIMEX );&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Enable PLL. */&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; HW_CLKCTRL_PLLCTRL0_SET( BM_CLKCTRL_PLLCTRL0_POWER );&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; delay_us(10000);&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Change VDD to 1.550v&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; value&amp;nbsp; =&amp;nbsp; HW_POWER_VDDDCTRL_RD();&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; value &amp;amp;= ~BM_POWER_VDDDCTRL_TRG;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; value |=&amp;nbsp; BF_POWER_VDDDCTRL_TRG(30);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; HW_POWER_VDDDCTRL_WR(value);&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; delay_us(10000);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; HW_CLKCTRL_CLKSEQ_SET( BM_CLKCTRL_CLKSEQ_BYPASS_CPU ); // Use ref_xtal&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; HW_CLKCTRL_FRAC_SET( BM_CLKCTRL_FRAC_CLKGATECPU&amp;nbsp;&amp;nbsp; );&amp;nbsp;&amp;nbsp; // Disable ref_cpu&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; HW_CLKCTRL_FRAC_SET( BM_CLKCTRL_FRAC_CPUFRAC&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; );&amp;nbsp;&amp;nbsp; // Leave CPUFRAC set to 19&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; HW_CLKCTRL_FRAC_CLR( BF_CLKCTRL_FRAC_CPUFRAC(~19) );&amp;nbsp;&amp;nbsp; // by going to max, then to 19&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; HW_CLKCTRL_FRAC_CLR( BM_CLKCTRL_FRAC_CLKGATECPU&amp;nbsp;&amp;nbsp; );&amp;nbsp;&amp;nbsp; // Enable ref_cpu @&amp;nbsp; 454.736 MHz&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Set CLK_H to (CPU) CLK_P / 3&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; HW_CLKCTRL_HBUS_SET(BM_CLKCTRL_HBUS_DIV);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; HW_CLKCTRL_HBUS_CLR( ((~3)&amp;amp;BM_CLKCTRL_HBUS_DIV) );&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //HW_CLKCTRL_HBUS_WR( BF_CLKCTRL_HBUS_DIV(3) );&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; while( HW_CLKCTRL_HBUS_RD() &amp;amp; BM_CLKCTRL_HBUS_BUSY )&amp;nbsp; {}&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; delay_us(10000);&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; HW_CLKCTRL_CLKSEQ_CLR( BM_CLKCTRL_CLKSEQ_BYPASS_CPU ); // Use ref_cpu&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Flash LED @ clk_h / 8&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // So rate should be clk_p / (3 * 8) = 454.736 / 24 = 18.94 MHz&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; while(1) {&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if( HW_DIGCTL_HCLKCOUNT_RD() &amp;amp; 0x4&amp;nbsp; ) { // divide by 8&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; HW_PINCTRL_DOUT2_SET( LED_OLIMEX );&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } else {&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; HW_PINCTRL_DOUT2_CLR( LED_OLIMEX );&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;/* -------------------------------------------------------------------------- */&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 03 Aug 2013 18:51:40 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/imx233-How-to-correctly-initialise-the-CPU-clock/m-p/239439#M19666</guid>
      <dc:creator>chrissmith</dc:creator>
      <dc:date>2013-08-03T18:51:40Z</dc:date>
    </item>
    <item>
      <title>Re: imx233 How to correctly initialise the CPU clock?</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/imx233-How-to-correctly-initialise-the-CPU-clock/m-p/239440#M19667</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, Chris&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; I think you can try below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1. Using HW_DIGCTL_MICROSECONDS which is a microsecond counter in stead of &lt;SPAN style="color: #000000; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px; background-color: #f8f8f8;"&gt;HW_DIGCTL_HCLKCOUNT&lt;/SPAN&gt; which is HCLK counter, as HCLK counter may be auto slow;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2. Please check ASM_ENABLE bit in HW_CLKCTRL_HBUS to see whether auto slow mode is enabled. Not sure whether i.MX233 has same function as i.MX28.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Aug 2013 07:07:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/imx233-How-to-correctly-initialise-the-CPU-clock/m-p/239440#M19667</guid>
      <dc:creator>AnsonHuang</dc:creator>
      <dc:date>2013-08-05T07:07:02Z</dc:date>
    </item>
    <item>
      <title>Re: imx233 How to correctly initialise the CPU clock?</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/imx233-How-to-correctly-initialise-the-CPU-clock/m-p/239441#M19668</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the advice.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As far as I can tell by looking at the code, bit 20 (AUTO_SLOW_MODE) of &lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;HW_CLKCTRL_HBUS is 0 and thus off (the default). There are other auto-slow &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;modes available, so I will specifically set them all to OFF and report back &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;to you later.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For info, I was specifically using the HCLK counter to measure the frequency of clk_h, so I could indirectly measure clk_p ( clk_h = clk_p / 3 ). As DIGCTL_MICROSECONDS counter is driven directly from the 24MHz, I can't use that to measure clk_p.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've made a further discovery since my original post. I wrote a loop in assembly that toggled the LED pin, instead of using the HCLK counter, so that the execution speed of the ARM could be measured directly. Based on an average of 1.5 CPI for an ARM9 core, there should be 9 clock cycles between each change of LED state. Again measurements do not match the theory and, confusingly, if I double the clk_p-to-clk_h divide ratio from 3 to 6, the LED flash period DOUBLES !!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was not expecting this. Why should clk_h affect the execution speed of a tight loop of ARM assembly code???&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Really confused now.&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Aug 2013 12:30:28 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/imx233-How-to-correctly-initialise-the-CPU-clock/m-p/239441#M19668</guid>
      <dc:creator>chrissmith</dc:creator>
      <dc:date>2013-08-05T12:30:28Z</dc:date>
    </item>
    <item>
      <title>Re: imx233 How to correctly initialise the CPU clock?</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/imx233-How-to-correctly-initialise-the-CPU-clock/m-p/239442#M19669</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I can confirm that HW_CLKCTRL_HBUS is completely set to zero, except for the clk_p-to-clk_h divisor value of 3, so auto_slow modes are off.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The fact that changing the clk_p-to-clk_h divisor alters the speed of the executing code is telling me something. I just don't know what yet.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anyone say why this would happen?&amp;nbsp; I am sure it will reveal my problem.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Aug 2013 17:43:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/imx233-How-to-correctly-initialise-the-CPU-clock/m-p/239442#M19669</guid>
      <dc:creator>chrissmith</dc:creator>
      <dc:date>2013-08-05T17:43:26Z</dc:date>
    </item>
    <item>
      <title>Re: imx233 How to correctly initialise the CPU clock?</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/imx233-How-to-correctly-initialise-the-CPU-clock/m-p/239443#M19670</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, Chris&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; As when ARM core executes instruction, it needs to access HBUS to get instruction/data, so the HBUS's freq will impact the instruction execution time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; My suggestion is to do it as below, do NOT pull up/down GPIO, just doing simple instruction such as below, see how many HCLK counts ARM needs to finish 10000000 times adding, and we also need to see the asm code of&amp;nbsp; while (i++ &amp;lt; 10000000);, how many instruction it is compiled out. Then we can get ARM's freq roughly. ARM executes instruction each clock.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; start = &lt;SPAN style="color: #000000; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px; background-color: #f8f8f8;"&gt;HW_DIGCTL_HCLKCOUNT_RD()&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while (i++ &amp;lt; 10000000)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px; background-color: #f8f8f8;"&gt;&amp;nbsp;&amp;nbsp; end = HW_DIGCTL_HCLKCOUNT_RD()&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Aug 2013 03:33:03 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/imx233-How-to-correctly-initialise-the-CPU-clock/m-p/239443#M19670</guid>
      <dc:creator>AnsonHuang</dc:creator>
      <dc:date>2013-08-06T03:33:03Z</dc:date>
    </item>
    <item>
      <title>Re: Re: imx233 How to correctly initialise the CPU clock?</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/imx233-How-to-correctly-initialise-the-CPU-clock/m-p/239444#M19671</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Okay, done that test with the following code snippet (timeloop was hand written to be as simple as possible):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_13758172174132786" jivemacro_uid="_13758172174132786" modifiedtitle="true"&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ; start = HW_DIGCTL_MICROSECONDS_RD();&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ldr&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r3, [pc, #1208] ;&amp;nbsp; &amp;lt;0x8001c0c0&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ldr&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r3, [r3]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; str&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r3, [fp, #-20]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ldr&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r3, [pc, #-120] ; &amp;lt;looplen = 1000000&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mov&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r1, #0&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;timeloop:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sub&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r3, r3, #1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; teq&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r1, r3&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bne&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; timeloop&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ; end = HW_DIGCTL_MICROSECONDS_RD();&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ldr&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r3, [pc, #1176] ;&amp;nbsp; &amp;lt;0x8001c0c0&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ldr&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r3, [r3]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; str&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r3, [fp, #-24]&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The elapsed time (including getting the end time) is 70371us for 1,000,000 iterations of the timeloop.&lt;/P&gt;&lt;P&gt;Now, please check my logic, but for me this gives 14,210,399.1701 loop iterations per second, and therefore a CPU frequency (assuming 3 clock cycles per loop) of 42.63119751 MHz.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This test was done with clk_h = clk_p / 2 and not 3 as in my original post. Repeating with clk_h = clk_p / 3, the loop takes 105556us.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Aug 2013 19:48:01 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/imx233-How-to-correctly-initialise-the-CPU-clock/m-p/239444#M19671</guid>
      <dc:creator>chrissmith</dc:creator>
      <dc:date>2013-08-06T19:48:01Z</dc:date>
    </item>
    <item>
      <title>Re: imx233 How to correctly initialise the CPU clock?</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/imx233-How-to-correctly-initialise-the-CPU-clock/m-p/239445#M19672</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What you want is to prove that CPU is running @454MHz, right?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If so, then we can make things easier, just set H_CLK to be 1/3 CLK_P, and use H_CLK counter to compare with microsecond counter in the same DIG module, or even with RTC timer then we can get it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am afraid previous approach is not very accurate, sorry for that.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Aug 2013 02:02:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/imx233-How-to-correctly-initialise-the-CPU-clock/m-p/239445#M19672</guid>
      <dc:creator>AnsonHuang</dc:creator>
      <dc:date>2013-08-07T02:02:54Z</dc:date>
    </item>
    <item>
      <title>Re: imx233 How to correctly initialise the CPU clock?</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/imx233-How-to-correctly-initialise-the-CPU-clock/m-p/239446#M19673</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Proving 454MHz is my first test in investigating my execution speed problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My issue is that my project runs somewhere between 5 and 10 times &lt;SPAN style="text-decoration: underline;"&gt;faster&lt;/SPAN&gt; when running on top of Linux, than when running on the bare chip - the opposite of what should happen.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Even a simple test like flashing the LED in a loop shows the same speed difference. The bare chip should be much faster!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Obviously I suspect my chip initialisation, and the first thing to look at is the CPU frequency. So far it looks slow.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I will try your latest suggestion, and report back!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;&lt;P&gt;--&lt;/P&gt;&lt;P&gt;Sent while on the move...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Aug 2013 07:58:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/imx233-How-to-correctly-initialise-the-CPU-clock/m-p/239446#M19673</guid>
      <dc:creator>chrissmith</dc:creator>
      <dc:date>2013-08-07T07:58:07Z</dc:date>
    </item>
    <item>
      <title>Re: Re: imx233 How to correctly initialise the CPU clock?</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/imx233-How-to-correctly-initialise-the-CPU-clock/m-p/239447#M19674</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've tried your request with the following code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_13760547608778064" jivemacro_uid="_13760547608778064" modifiedtitle="true"&gt;
&lt;P&gt;volatile unsigned int start = &lt;SPAN style="color: #000000; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px; background-color: #f8f8f8;"&gt;HW_DIGCTL_HCLKCOUNT_RD();&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;volatile unsigned int count = 0;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: #000000; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px; background-color: #f8f8f8;"&gt;delay_us(1000000); // 1 second delay&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;count = &lt;SPAN style="color: #000000; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px; background-color: #f8f8f8;"&gt;HW_DIGCTL_HCLKCOUNT_RD()&lt;/SPAN&gt; - start;&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This gives me a count of 151596528 which, if clk_h = clk_p / 3, gives clk_p = (approximately) 454.789584 MHz, suggesting clk_p is set correctly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The question remains as to why my code runs as expected under Linux, but much slower on the bare chip?&lt;/P&gt;&lt;P&gt;For example, if I get my application running on Linux to flash an LED by writing to &lt;SPAN style="font-family: 'courier new', courier;"&gt;/sys/class/gpiox/gpio&lt;/SPAN&gt; as it executes, it does so with a 0.04s period.&lt;/P&gt;&lt;P&gt;Running the same application directly on the chip, and flashing the LED by writing to &lt;SPAN style="color: #000000; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px;"&gt;HW_PINCTRL_DOUT2_xxx&lt;/SPAN&gt;, does so with a period of 2.5s.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can't explain why the performance would be so different, and I desperately need to get this to work.&lt;/P&gt;&lt;P&gt;An ideas?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Aug 2013 14:02:37 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/imx233-How-to-correctly-initialise-the-CPU-clock/m-p/239447#M19674</guid>
      <dc:creator>chrissmith</dc:creator>
      <dc:date>2013-08-09T14:02:37Z</dc:date>
    </item>
    <item>
      <title>Re: imx233 How to correctly initialise the CPU clock?</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/imx233-How-to-correctly-initialise-the-CPU-clock/m-p/239448#M19675</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI, Chris&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Sorry that I didn't have a i.mx233 board here to do some investigation for you, so what I can do is providing my thoughts, it does not make sense that bare chip running slow than Linux OS. So next step, I think we can dump all registes value in clkctrl module, then compare it on Linux and on bare chip, hope there is something wrong with the clk module config.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 11 Aug 2013 09:28:52 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/imx233-How-to-correctly-initialise-the-CPU-clock/m-p/239448#M19675</guid>
      <dc:creator>AnsonHuang</dc:creator>
      <dc:date>2013-08-11T09:28:52Z</dc:date>
    </item>
    <item>
      <title>Re: imx233 How to correctly initialise the CPU clock?</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/imx233-How-to-correctly-initialise-the-CPU-clock/m-p/239449#M19676</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've dumped out the CLKCTRL registers, even dumped out POWER and EMI registers to see what was going on.&lt;/P&gt;&lt;P&gt;There is no real difference between the Linux settings and mine.&lt;/P&gt;&lt;P&gt;I used SJTAG to dump the values out of my application, and noticed that I-Cache and D-Cache were disabled!&lt;/P&gt;&lt;P&gt;I was not configuring the MMU correctly (actually I was bypassing it). Today I corrected that, and now the code runs at the speed I'd expect.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your assistance, you were most helpful!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 17 Aug 2013 23:41:50 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/imx233-How-to-correctly-initialise-the-CPU-clock/m-p/239449#M19676</guid>
      <dc:creator>chrissmith</dc:creator>
      <dc:date>2013-08-17T23:41:50Z</dc:date>
    </item>
  </channel>
</rss>

