<?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 Critical sections enter and exit in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Critical-sections-enter-and-exit/m-p/293381#M11913</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am porting some drivers to KL25Z, which has ring buffer management. The original code has CRITICAL_SECTION_ENTER and CRITICAL_SECTION_EXIT macros, which&amp;nbsp; basically disable interrupt and enable interrupt.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But should we keep some critical register(s) before entering critical sections, and restore after exiting? And which registers should be saved? And any reference code? because I am not good at assembly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Allan K Liu &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 22 Nov 2013 12:19:43 GMT</pubDate>
    <dc:creator>kai_liu</dc:creator>
    <dc:date>2013-11-22T12:19:43Z</dc:date>
    <item>
      <title>Critical sections enter and exit</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Critical-sections-enter-and-exit/m-p/293381#M11913</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am porting some drivers to KL25Z, which has ring buffer management. The original code has CRITICAL_SECTION_ENTER and CRITICAL_SECTION_EXIT macros, which&amp;nbsp; basically disable interrupt and enable interrupt.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But should we keep some critical register(s) before entering critical sections, and restore after exiting? And which registers should be saved? And any reference code? because I am not good at assembly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Allan K Liu &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Nov 2013 12:19:43 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Critical-sections-enter-and-exit/m-p/293381#M11913</guid>
      <dc:creator>kai_liu</dc:creator>
      <dc:date>2013-11-22T12:19:43Z</dc:date>
    </item>
    <item>
      <title>Re: Critical sections enter and exit</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Critical-sections-enter-and-exit/m-p/293382#M11914</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If a simple single writer, single reader, ring buffer is turning IRQs on and off it is not implemented correctly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is some C code that you can use:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://websvn.hylands.org/filedetails.php?repname=Projects&amp;amp;path=%2Fcommon%2FCBUF.h&amp;amp;sc=1" title="http://websvn.hylands.org/filedetails.php?repname=Projects&amp;amp;path=%2Fcommon%2FCBUF.h&amp;amp;sc=1"&gt;WebSVN - Projects - Rev 230 - /common/CBUF.h&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I cove what to watch out for in my Blog related to Queue code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://blog.softwaresafety.net/2012/02/even-design-patterns-still-have-bugs.html" title="http://blog.softwaresafety.net/2012/02/even-design-patterns-still-have-bugs.html"&gt;Software Safety: Even "Design Patterns" still have bugs. A common Queue bug.&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Main point is to be aware of what the atomic size of an increment will be.&amp;nbsp; If multi-byte resisters&amp;nbsp; get split your code will have hard to reproduce bugs.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Nov 2013 15:05:33 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Critical-sections-enter-and-exit/m-p/293382#M11914</guid>
      <dc:creator>bobpaddock</dc:creator>
      <dc:date>2013-11-22T15:05:33Z</dc:date>
    </item>
  </channel>
</rss>

