<?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 Control not returning after Context Switch in i.MX Processors</title>
    <link>https://community.nxp.com/t5/i-MX-Processors/Control-not-returning-after-Context-Switch/m-p/637707#M97198</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="background-color: #ffffff; margin: 0px 0px 10px;"&gt;Hi,&lt;/P&gt;&lt;P style="background-color: #ffffff; margin: 10px 0px;"&gt;I am using I.mx6q Sabre-sd board. I am trying&amp;nbsp;to write my own custom OS. During the context switching process, the context switch happens accurately but the control doesn't return to the exact position. ie. when the context has to be switched, i call a function that is written in assembly. After the assembly has been executed the context gets switched but the control doesn't reach where the assembly function was actually called. But the next task is being executed accurately. What might be the problem. The assembly code i am using is,&lt;/P&gt;&lt;P style="background-color: #ffffff; margin: 10px 0px;"&gt;.global _context_switch&lt;BR /&gt;.func _context_switch&lt;BR /&gt;//save required registers&lt;BR /&gt;_context_switch:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; STMFD sp!,{r14}&lt;BR /&gt;&amp;nbsp; &amp;nbsp; STMFD sp!,{r0-r12,r14}&lt;BR /&gt;&amp;nbsp; &amp;nbsp; MRS r0,cpsr&lt;BR /&gt;&amp;nbsp; &amp;nbsp; STMFD sp!,{r0}&lt;BR /&gt;&amp;nbsp; &amp;nbsp; LDR r0,__userStackPtr2Ptr&lt;BR /&gt;&amp;nbsp; &amp;nbsp; LDR r1,[r0]&lt;BR /&gt;&amp;nbsp; &amp;nbsp; STR sp,[r1]&lt;BR /&gt;// &lt;BR /&gt;&amp;nbsp; &amp;nbsp; LDR r0,__newUserStackPtr2Ptr&lt;BR /&gt;&amp;nbsp; &amp;nbsp; LDR r12,[r0]&lt;BR /&gt;&amp;nbsp; &amp;nbsp; LDR sp ,[r12]&lt;BR /&gt;&amp;nbsp; &amp;nbsp; LDMFD sp!,{r0}&lt;BR /&gt;&amp;nbsp; &amp;nbsp; ORR r0,r0,#0xc0&lt;BR /&gt;&amp;nbsp; &amp;nbsp; MSR cpsr,r0&lt;BR /&gt;&amp;nbsp; &amp;nbsp; BIC r0,r0,#0xc0&lt;BR /&gt;&amp;nbsp; &amp;nbsp; MSR spsr,r0 &lt;BR /&gt;&amp;nbsp; &amp;nbsp; LDR sp,[r12]&lt;BR /&gt;&amp;nbsp; &amp;nbsp; ADD sp,sp,#4&lt;BR /&gt;&amp;nbsp; &amp;nbsp; LDMFD sp!,{r0-r12,lr}&lt;BR /&gt;&amp;nbsp; &amp;nbsp; LDMFD sp!,{pc}^&lt;BR /&gt;// sub lr, lr, #4;&lt;BR /&gt;// bx lr&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; .endfunc&lt;/P&gt;&lt;P style="background-color: #ffffff; margin: 10px 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="background-color: #ffffff; margin: 10px 0px;"&gt;Is this correct? Am i missing some steps ? I am not good with assembly. Please help.&lt;/P&gt;&lt;P style="background-color: #ffffff; margin: 10px 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="background-color: #ffffff; margin: 10px 0px;"&gt;Regards,&lt;/P&gt;&lt;P style="background-color: #ffffff; margin: 10px 0px 0px;"&gt;Ajeesh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Feb 2017 12:07:58 GMT</pubDate>
    <dc:creator>ajmalali</dc:creator>
    <dc:date>2017-02-15T12:07:58Z</dc:date>
    <item>
      <title>Control not returning after Context Switch</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Control-not-returning-after-Context-Switch/m-p/637707#M97198</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="background-color: #ffffff; margin: 0px 0px 10px;"&gt;Hi,&lt;/P&gt;&lt;P style="background-color: #ffffff; margin: 10px 0px;"&gt;I am using I.mx6q Sabre-sd board. I am trying&amp;nbsp;to write my own custom OS. During the context switching process, the context switch happens accurately but the control doesn't return to the exact position. ie. when the context has to be switched, i call a function that is written in assembly. After the assembly has been executed the context gets switched but the control doesn't reach where the assembly function was actually called. But the next task is being executed accurately. What might be the problem. The assembly code i am using is,&lt;/P&gt;&lt;P style="background-color: #ffffff; margin: 10px 0px;"&gt;.global _context_switch&lt;BR /&gt;.func _context_switch&lt;BR /&gt;//save required registers&lt;BR /&gt;_context_switch:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; STMFD sp!,{r14}&lt;BR /&gt;&amp;nbsp; &amp;nbsp; STMFD sp!,{r0-r12,r14}&lt;BR /&gt;&amp;nbsp; &amp;nbsp; MRS r0,cpsr&lt;BR /&gt;&amp;nbsp; &amp;nbsp; STMFD sp!,{r0}&lt;BR /&gt;&amp;nbsp; &amp;nbsp; LDR r0,__userStackPtr2Ptr&lt;BR /&gt;&amp;nbsp; &amp;nbsp; LDR r1,[r0]&lt;BR /&gt;&amp;nbsp; &amp;nbsp; STR sp,[r1]&lt;BR /&gt;// &lt;BR /&gt;&amp;nbsp; &amp;nbsp; LDR r0,__newUserStackPtr2Ptr&lt;BR /&gt;&amp;nbsp; &amp;nbsp; LDR r12,[r0]&lt;BR /&gt;&amp;nbsp; &amp;nbsp; LDR sp ,[r12]&lt;BR /&gt;&amp;nbsp; &amp;nbsp; LDMFD sp!,{r0}&lt;BR /&gt;&amp;nbsp; &amp;nbsp; ORR r0,r0,#0xc0&lt;BR /&gt;&amp;nbsp; &amp;nbsp; MSR cpsr,r0&lt;BR /&gt;&amp;nbsp; &amp;nbsp; BIC r0,r0,#0xc0&lt;BR /&gt;&amp;nbsp; &amp;nbsp; MSR spsr,r0 &lt;BR /&gt;&amp;nbsp; &amp;nbsp; LDR sp,[r12]&lt;BR /&gt;&amp;nbsp; &amp;nbsp; ADD sp,sp,#4&lt;BR /&gt;&amp;nbsp; &amp;nbsp; LDMFD sp!,{r0-r12,lr}&lt;BR /&gt;&amp;nbsp; &amp;nbsp; LDMFD sp!,{pc}^&lt;BR /&gt;// sub lr, lr, #4;&lt;BR /&gt;// bx lr&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; .endfunc&lt;/P&gt;&lt;P style="background-color: #ffffff; margin: 10px 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="background-color: #ffffff; margin: 10px 0px;"&gt;Is this correct? Am i missing some steps ? I am not good with assembly. Please help.&lt;/P&gt;&lt;P style="background-color: #ffffff; margin: 10px 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="background-color: #ffffff; margin: 10px 0px;"&gt;Regards,&lt;/P&gt;&lt;P style="background-color: #ffffff; margin: 10px 0px 0px;"&gt;Ajeesh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Feb 2017 12:07:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Control-not-returning-after-Context-Switch/m-p/637707#M97198</guid>
      <dc:creator>ajmalali</dc:creator>
      <dc:date>2017-02-15T12:07:58Z</dc:date>
    </item>
    <item>
      <title>Re: Control not returning after Context Switch</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Control-not-returning-after-Context-Switch/m-p/637708#M97199</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ajeesh,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;writing your own operating system is a huge task and this is out of our free support scope. I can recommend this nice reference &lt;A href="https://pdfs.semanticscholar.org/a24e/c6903e740a61af9310efda3b7af8cdd00401.pdf"&gt;Real-Time Concepts for Embedded Systems by Qing Li and Carolyn or&lt;/A&gt; you may also o aquire our NXP professional support and services here &lt;A class="link-titled" href="http://www.nxp.com/products/software-and-tools/software-support-and-services/professional-support-and-service-resources:PROF-SUPPORT-SERVICE-RESOURCES?tid=vanSERVICES" title="http://www.nxp.com/products/software-and-tools/software-support-and-services/professional-support-and-service-resources:PROF-SUPPORT-SERVICE-RESOURCES?tid=vanSERVICES"&gt;Professional Support and Service Resources|NXP&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Carlos&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>Thu, 16 Feb 2017 23:00:45 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Control-not-returning-after-Context-Switch/m-p/637708#M97199</guid>
      <dc:creator>Carlos_Musich</dc:creator>
      <dc:date>2017-02-16T23:00:45Z</dc:date>
    </item>
  </channel>
</rss>

