<?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: What is CONTROL SPSEL value? in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/What-is-CONTROL-SPSEL-value/m-p/357261#M17918</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi again,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I reconfirmed the fact on my FRDM-KL25Z board. I have found SPSEL bit had been set to "1".&lt;/P&gt;&lt;P&gt;That is, we can modify CONTROL.SPSEL bit.&lt;/P&gt;&lt;P&gt;It is inconsistent with your comment. Did I misunderstand your comments?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Yasuhiko Koumoto.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 09 Feb 2015 21:43:04 GMT</pubDate>
    <dc:creator>yasuhikokoumoto</dc:creator>
    <dc:date>2015-02-09T21:43:04Z</dc:date>
    <item>
      <title>What is CONTROL SPSEL value?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/What-is-CONTROL-SPSEL-value/m-p/357258#M17915</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Freescale people,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to know the implementation of SPSEL bit (bit[1]) value of CONTROL register of KInetis of which CPU is Cortex-M0+.&lt;/P&gt;&lt;P&gt;According to my experiment, SPSEL bit was fixed to 0 by KL25Z. This means the stack pointer would be always MSP even in the thread mode, doesn't it?&lt;/P&gt;&lt;P&gt;How about the other Kinetis MCUs?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Yasuhiko Koumoto.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 08 Feb 2015 20:29:04 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/What-is-CONTROL-SPSEL-value/m-p/357258#M17915</guid>
      <dc:creator>yasuhikokoumoto</dc:creator>
      <dc:date>2015-02-08T20:29:04Z</dc:date>
    </item>
    <item>
      <title>Re: What is CONTROL SPSEL value?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/What-is-CONTROL-SPSEL-value/m-p/357259#M17916</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I agree with you, the Kinetis product is using SP_main as the current stack, which means the SPSEL bit in control register of ARM Cortex M4/M0+ core value is 0.&lt;/P&gt;&lt;P&gt;From the Kinetis reference manual with below description:&lt;/P&gt;&lt;P&gt;When the system exits reset, the processor sets up the stack, program counter (PC),and link register (LR). The processor reads the start SP (SP_main) from vector-table offset 0. The core reads the start PC from vector-table offset 4. (K70 RM)&lt;/P&gt;&lt;P&gt;This device supports booting from internal flash with the reset vectors located at addresses 0x0 (initial SP_main), 0x4 (initial PC), and RAM with relocating the exception vector table to RAM. (KL25 RM)&lt;/P&gt;&lt;P&gt;Wish it helps.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Have a great day,&lt;BR /&gt;best regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ma Hui&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Feb 2015 06:21:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/What-is-CONTROL-SPSEL-value/m-p/357259#M17916</guid>
      <dc:creator>Hui_Ma</dc:creator>
      <dc:date>2015-02-09T06:21:16Z</dc:date>
    </item>
    <item>
      <title>Re: What is CONTROL SPSEL value?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/What-is-CONTROL-SPSEL-value/m-p/357260#M17917</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Hui_Ma,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I confirmed your comment by both FRDM-KL25Z and FRDM-K20D50M.&lt;/P&gt;&lt;P&gt;We cannot make SPSEL bit of CONTROL register "1".&lt;/P&gt;&lt;P&gt;I wonder why such important information was not described in any Reference Manuals.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Yasuhiko Koumoto.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Feb 2015 11:01:34 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/What-is-CONTROL-SPSEL-value/m-p/357260#M17917</guid>
      <dc:creator>yasuhikokoumoto</dc:creator>
      <dc:date>2015-02-09T11:01:34Z</dc:date>
    </item>
    <item>
      <title>Re: What is CONTROL SPSEL value?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/What-is-CONTROL-SPSEL-value/m-p/357261#M17918</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi again,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I reconfirmed the fact on my FRDM-KL25Z board. I have found SPSEL bit had been set to "1".&lt;/P&gt;&lt;P&gt;That is, we can modify CONTROL.SPSEL bit.&lt;/P&gt;&lt;P&gt;It is inconsistent with your comment. Did I misunderstand your comments?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Yasuhiko Koumoto.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Feb 2015 21:43:04 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/What-is-CONTROL-SPSEL-value/m-p/357261#M17918</guid>
      <dc:creator>yasuhikokoumoto</dc:creator>
      <dc:date>2015-02-09T21:43:04Z</dc:date>
    </item>
    <item>
      <title>Re: What is CONTROL SPSEL value?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/What-is-CONTROL-SPSEL-value/m-p/357262#M17919</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sorry for the delay reply.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I checked &amp;lt;ARM Cortex-m0+ generic user guide&amp;gt; with below description about CONTROL register :&lt;/P&gt;&lt;P&gt;In an OS environment, ARM recommends that threads running in Thread mode use the process stack and the kernel and exception handlers use the main stack.&lt;/P&gt;&lt;P&gt;By default, Thread mode uses the MSP. To switch the stack pointer used in Thread mode to the PSP, use the MSR instruction to set the active stack pointer bit to 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So I double check with KL25 MQX_LITE example and K60 MQX example, after the MQX RTOS boots up, it will switch the SP_process.&lt;/P&gt;&lt;P&gt;Below is KL25 MQX_Lite example CPU register info after MQX_Lite RTOS boot up:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="SP.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/50445iA129073C820159F8/image-size/large?v=v2&amp;amp;px=999" role="button" title="SP.png" alt="SP.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;And you could find below stack switch code at &amp;lt;boot.s&amp;gt; file, the SP_main and SP_process using the same SRAM address:&lt;/P&gt;&lt;P&gt;/* Prepare process stack pointer */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mrs r0, MSP&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; msr PSP, r0&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* Switch to proccess stack (PSP) */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mrs r0, CONTROL&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; movs r1, #0x2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; orrs r0, r0, r1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; msr CONTROL, r0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; isb&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Below is TWR-K60D100M board running MQX example CPU registers status:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="K60_SP.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/50446iFE9C0418B5EE2563/image-size/large?v=v2&amp;amp;px=999" role="button" title="K60_SP.png" alt="K60_SP.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Here is the stack pointer switch code at &amp;lt;boot.s&amp;gt;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/TD&gt;&lt;TD&gt;/* Prepare process stack pointer */&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/TD&gt;&lt;TD&gt;mrs r0, MSP&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/TD&gt;&lt;TD&gt;msr PSP, r0&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/TD&gt;&lt;TD&gt;/* Switch to proccess stack (PSP) */&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/TD&gt;&lt;TD&gt;mrs r0, CONTROL&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/TD&gt;&lt;TD&gt;orr r0, r0, #2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/TD&gt;&lt;TD&gt;msr CONTROL, r0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/TD&gt;&lt;TD&gt;isb #15&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, the CONTROL_SPSEL bit could be set at all Kinetis product.&lt;/P&gt;&lt;P&gt;The Stack Pointer (SP) is register R13. In Thread mode, bit[1] of the CONTROL register indicates the stack pointer to use:&lt;/P&gt;&lt;P&gt;• 0 = Main Stack Pointer (MSP). This is the reset value.&lt;/P&gt;&lt;P&gt;• 1 = Process Stack Pointer (PSP).&lt;/P&gt;&lt;P&gt;On reset, the processor loads the MSP with the value from address 0x00000000.&lt;/P&gt;&lt;P&gt;Wish it helps.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Have a great day,&lt;BR /&gt;best regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ma Hui&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Feb 2015 07:40:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/What-is-CONTROL-SPSEL-value/m-p/357262#M17919</guid>
      <dc:creator>Hui_Ma</dc:creator>
      <dc:date>2015-02-11T07:40:23Z</dc:date>
    </item>
    <item>
      <title>Re: What is CONTROL SPSEL value?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/What-is-CONTROL-SPSEL-value/m-p/357263#M17920</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Hui_Ma,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thank you for confirmation. I understood well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards.&lt;/P&gt;&lt;P&gt;Yasuhiko Koumoto.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Feb 2015 07:59:20 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/What-is-CONTROL-SPSEL-value/m-p/357263#M17920</guid>
      <dc:creator>yasuhikokoumoto</dc:creator>
      <dc:date>2015-02-11T07:59:20Z</dc:date>
    </item>
  </channel>
</rss>

