<?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>S12 / MagniV MicrocontrollersのトピックRe: SPI interrupt not triggering (MC9S12DG256 + CW 3.1)</title>
    <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/SPI-interrupt-not-triggering-MC9S12DG256-CW-3-1/m-p/140972#M3194</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;This is correct if and only if read the register clears a flag, and you need to test the state of that flag.&lt;BR /&gt;In most cases, this is not an issue.&lt;BR /&gt;Even if the BSET instruction was not used, there would have to be a read of a register or memory location if a bit was to be set without changing the state of the other bits,&amp;nbsp; C bitfields are not a special case.&lt;BR /&gt;&lt;BR /&gt;If there was not a BSET instruction, and we are not use using C bitfields this:&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; *x |= 4;&lt;BR /&gt;&lt;BR /&gt;Would still generate a read modify cycle of some sort, even if it was to load a register, or the bit in and save it back.&lt;BR /&gt;&lt;BR /&gt;How is it possible to set a bit with out first reading the rest of the byte?&lt;BR /&gt;Are proposing an new kind of memory that is bit addressable - because in this architecture io registers appear as memory.&lt;BR /&gt;&lt;BR /&gt;In those few special cases, the user needs to know read the register first. It really does not matter how you do it, there will still be a read.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;Message Edited by JimDon on &lt;SPAN class="date_text"&gt;2008-04-21&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;08:29 AM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 21 Apr 2008 19:28:18 GMT</pubDate>
    <dc:creator>JimDon</dc:creator>
    <dc:date>2008-04-21T19:28:18Z</dc:date>
    <item>
      <title>SPI interrupt not triggering (MC9S12DG256 + CW 3.1)</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/SPI-interrupt-not-triggering-MC9S12DG256-CW-3-1/m-p/140955#M3177</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hi.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I'm in the process of porting some code from a DG128 to a DG256. After making the minimum number of changes (mainly relating to the differences in the memory map), the code does run. However, I've found that the SPI interrupt doesn't trigger.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;This worked fine on the DG128. The only clue I could find in the documentation was the fact that the SPI module has been upgraded in the DG256, such that "In SPI Master Mode, the change of a config bit during a transmission in progress, will abort the transmission and force the SPI into idle state."&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;The code doesn't change any configuration bits during a transmission. However, there are circumstances where the SPIE bit is cleared or set during transmission. The assembly produced by the compiler uses BSET/BCLR, which I assumed wouldn't affect any of the other bits. Is this assumption wrong?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I've experimented with the debugger, with some odd results:&lt;/DIV&gt;&lt;OL&gt;&lt;LI&gt;Single stepping through the code which writes to SPIDR sets SPIF as expected, but then clears SPIF on the next instruction, even if the next instruction is a NOP! (I understand from another post that the debugger reading the SPI registers could cause this flag to be cleared).&lt;/LI&gt;&lt;LI&gt;Specifying a particular register in the watch window, then restarting the code, makes the problem go away! The following registers worked: SPISR, SPICR1, SPICR2, and an I2C register; SPIDR did not. It didn't matter whether the memory or watch windows were open or not.&lt;/LI&gt;&lt;LI&gt;It makes no difference whether the BDM module is connected or not.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;All in all, this is a bit of a puzzle, especially as this code worked fine on the DG128. I would welcome any suggestions!&lt;/P&gt;&lt;P&gt;Steve.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Jul 2007 15:47:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/SPI-interrupt-not-triggering-MC9S12DG256-CW-3-1/m-p/140955#M3177</guid>
      <dc:creator>sjmelnikoff</dc:creator>
      <dc:date>2007-07-24T15:47:07Z</dc:date>
    </item>
    <item>
      <title>Re: SPI interrupt not triggering (MC9S12DG256 + CW 3.1)</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/SPI-interrupt-not-triggering-MC9S12DG256-CW-3-1/m-p/140956#M3178</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Hello Steve,&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;I wonder if the problem might be related to the use of different SPI clock rates in each instance, especially if you are using a fast rate.&amp;nbsp; You seem to be saying that you are using SPI&amp;nbsp;interrupt for a&amp;nbsp;SPI master, and that you are enabling and disabling this interrupt at various times.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Keep in mind that, for a fast clock rate,&amp;nbsp;it is possible for the ISR processing period to easily exceed the SPI&amp;nbsp;transmission period, so receive overrun might occur, depending on your actual code.&amp;nbsp; This would apply to the processing period of &lt;U&gt;any&lt;/U&gt;&amp;nbsp;ISR that may occur once a SPI transmission is initiated.&amp;nbsp; You could try reducing the SPI clock frequency, and see if the problem persists.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Regards,&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Mac&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Jul 2007 09:37:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/SPI-interrupt-not-triggering-MC9S12DG256-CW-3-1/m-p/140956#M3178</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2007-07-25T09:37:08Z</dc:date>
    </item>
    <item>
      <title>Re: SPI interrupt not triggering (MC9S12DG256 + CW 3.1)</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/SPI-interrupt-not-triggering-MC9S12DG256-CW-3-1/m-p/140957#M3179</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;Hi bigmac; thanks for your response.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I submitted this as a Technical Request to Freescale, and they&amp;nbsp;suggested this (reproduced with permission):&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;BR /&gt;&lt;/DIV&gt;&lt;BLOCKQUOTE&gt;&lt;DIV&gt;&lt;HR /&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;FONT size="2"&gt;Please try the following tip:&lt;/FONT&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;P&gt;I remember similar problem with SPI after migration from old Dx256B to newer Dx256 device.&lt;/P&gt;&lt;P&gt;Please try to read SPISR register immediately after reset before writing to SPI config. registers:&lt;/P&gt;&lt;P&gt;(void)SPI1SR; // SPISR init&lt;/P&gt;&lt;P&gt;Unfortunately this problem is not documented yet.&lt;/P&gt;&lt;P&gt;You could add this line also after SPI configuration is completed before the first writing to SPIDR register.&lt;/P&gt;&lt;HR /&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;&lt;DIV&gt;As suggested, I added a dummy read of SPISR prior to SPI initialisation, and it worked perfectly!&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Freescale have indicated that this issue will now be documented.&lt;BR /&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;Steve.&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Jul 2007 15:18:01 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/SPI-interrupt-not-triggering-MC9S12DG256-CW-3-1/m-p/140957#M3179</guid>
      <dc:creator>sjmelnikoff</dc:creator>
      <dc:date>2007-07-25T15:18:01Z</dc:date>
    </item>
    <item>
      <title>Re: SPI interrupt not triggering (MC9S12DG256 + CW 3.1)</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/SPI-interrupt-not-triggering-MC9S12DG256-CW-3-1/m-p/140958#M3180</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Hello Steve,&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;This appears to be a related issue to the following post, even though the latter refers to 8-bit devices.&amp;nbsp; Obviously, there is some commonality between the SPI modules for the S12 and 9S08 devices.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;A href="http://forums.freescale.com/freescale/board/message?board.id=8BITCOMM&amp;amp;thread.id=6713" target="_blank"&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&lt;/A&gt;&lt;A href="http://forums.freescale.com/freescale/board/message?board.id=8BITCOMM&amp;amp;thread.id=6713" target="test_blank"&gt;http://forums.freescale.com/freescale/board/message?board.id=8BITCOMM&amp;amp;thread.id=6713&lt;/A&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;In fact, the issue may already be documented for some MCUs, but not very prominently.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;My understanding is that the read of SPISR is not related to writing to the configuration registers, but must occur somewhere&amp;nbsp;prior to attempting the first write to SPIDR, but not necessarily within the SPI initialisation function.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Regards,&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Mac&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;Message Edited by bigmac on &lt;SPAN class="date_text"&gt;2007-07-25&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;11:15 PM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Jul 2007 20:02:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/SPI-interrupt-not-triggering-MC9S12DG256-CW-3-1/m-p/140958#M3180</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2007-07-25T20:02:27Z</dc:date>
    </item>
    <item>
      <title>Re: SPI interrupt not triggering (MC9S12DG256 + CW 3.1)</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/SPI-interrupt-not-triggering-MC9S12DG256-CW-3-1/m-p/140959#M3181</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Need to be very careful with bit set and bit clear instructions on registers that have write 1 to clear bits (such as interrupt flags).&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;These are read modify write operations. What set&amp;nbsp;bit actually does is read the register, OR the mask byte in the instruction with it and then write the result back to the register. You can see that any flags in the register that are set will get 1's written back to them and if write one to clear will get cleared - not what you expected! Clear bit does&amp;nbsp;a similar thing&amp;nbsp;using AND.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;At the C level don't use bit field assignments and don't use |= with a bit mask, stick to&amp;nbsp;plain old assignment with the bit mask, e.g. FlagRegister = 0x40;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Dog.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Aug 2007 23:55:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/SPI-interrupt-not-triggering-MC9S12DG256-CW-3-1/m-p/140959#M3181</guid>
      <dc:creator>dog</dc:creator>
      <dc:date>2007-08-21T23:55:54Z</dc:date>
    </item>
    <item>
      <title>Re: SPI interrupt not triggering (MC9S12DG256 + CW 3.1)</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/SPI-interrupt-not-triggering-MC9S12DG256-CW-3-1/m-p/140960#M3182</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hi Dog,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;It would seem our clever chip designers are actually on to this, making write 1 to acknowledge bits read as 0. Do you know of specific instances where they have failed to do this?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Aug 2007 05:04:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/SPI-interrupt-not-triggering-MC9S12DG256-CW-3-1/m-p/140960#M3182</guid>
      <dc:creator>peg</dc:creator>
      <dc:date>2007-08-22T05:04:58Z</dc:date>
    </item>
    <item>
      <title>Re: SPI interrupt not triggering (MC9S12DG256 + CW 3.1)</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/SPI-interrupt-not-triggering-MC9S12DG256-CW-3-1/m-p/140961#M3183</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;BLOCKQUOTE&gt;&lt;DIV&gt;&lt;HR /&gt;dog wrote:&lt;BR /&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;These are read modify write operations. What set&amp;nbsp;bit actually does is read the register, OR the mask byte in the instruction with it and then write the result back to the register.&lt;/DIV&gt;&lt;DIV&gt;...&lt;/DIV&gt;&lt;DIV&gt;At the C level don't use bit field assignments and don't use |= with a bit mask, stick to&amp;nbsp;plain old assignment with the bit mask, e.g. FlagRegister = 0x40;&lt;/DIV&gt;&lt;HR /&gt;&lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;&lt;DIV&gt;Dog's point is a good one in general - though in this particular case, it doesn't apply. The HCS12 headers&amp;nbsp;for CW3.1 use bitfields for bit access as well as masks, As a result, assignments made through bitfields are translated as BSET and BCLR, as mentioned in my original post.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;In any case, the SPIF bit is never written to; it's cleared automatically by reading other registers; and the SPIE bit is in a control register, for which it's perfectly valid to do a read-modigy-write.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Steve.&lt;BR /&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Aug 2007 15:35:34 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/SPI-interrupt-not-triggering-MC9S12DG256-CW-3-1/m-p/140961#M3183</guid>
      <dc:creator>sjmelnikoff</dc:creator>
      <dc:date>2007-08-22T15:35:34Z</dc:date>
    </item>
    <item>
      <title>Re: SPI interrupt not triggering (MC9S12DG256 + CW 3.1)</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/SPI-interrupt-not-triggering-MC9S12DG256-CW-3-1/m-p/140962#M3184</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;peg wrote:&lt;BR /&gt;&lt;DIV&gt;Hi Dog,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;It would seem our clever chip designers are actually on to this, making write 1 to acknowledge bits read as 0. Do you know of specific instances where they have failed to do this?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;That sounds bad. The method works just fine the way it is now. Nearly &lt;I&gt;every interrupt flag&lt;/I&gt; I know works in the way that if the bit reads '&lt;FONT color="#0000ff"&gt;1&lt;/FONT&gt;', you write a '&lt;FONT color="#0000ff"&gt;1&lt;/FONT&gt;' to it in order to clear the same bit (to make it read '&lt;FONT color="#0000ff"&gt;0&lt;/FONT&gt;'). If they changed any of those arrangements, it would introduce a huge incompatibility that is not necessary. It already works just fine to write only a '&lt;FONT color="#0000ff"&gt;1&lt;/FONT&gt;' to the bit(s) which need acknowledged, and &lt;U&gt;not&lt;/U&gt; use &lt;FONT color="#003366"&gt;bset&lt;/FONT&gt;.&lt;BR /&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Aug 2007 22:30:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/SPI-interrupt-not-triggering-MC9S12DG256-CW-3-1/m-p/140962#M3184</guid>
      <dc:creator>imajeff</dc:creator>
      <dc:date>2007-08-23T22:30:42Z</dc:date>
    </item>
    <item>
      <title>Re: SPI interrupt not triggering (MC9S12DG256 + CW 3.1)</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/SPI-interrupt-not-triggering-MC9S12DG256-CW-3-1/m-p/140963#M3185</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Hello all,&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Perhaps I am missing something, but I cannot see a specific problem with using the bset&amp;nbsp;instruction to clear an interrupt&amp;nbsp;flag.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;If the flag is set, it will read as a 1, and the&amp;nbsp;instruction should write a 1 back to the bit to clear the flag.&amp;nbsp; If the flag is clear, the instruction would still write a 1, but this would obviously do nothing, as required.&amp;nbsp; However, there might be a potential problem if a bset&amp;nbsp;instruction was used to set a bit, other than the&amp;nbsp;flag bit - the flag could be unintentionally cleared.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;A simular argument would also apply if the method of clearing a flag is to write a zero, and the bclr&amp;nbsp;instruction is used&amp;nbsp;(e.g.&amp;nbsp;applicable to&amp;nbsp;some timer flags).&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;My understanding would be that the instruction is a read-modify-write type in order to determine the state of the other bits that &lt;U&gt;must not&lt;/U&gt; alter.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Regards,&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Mac&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Aug 2007 01:44:31 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/SPI-interrupt-not-triggering-MC9S12DG256-CW-3-1/m-p/140963#M3185</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2007-08-24T01:44:31Z</dc:date>
    </item>
    <item>
      <title>Re: SPI interrupt not triggering (MC9S12DG256 + CW 3.1)</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/SPI-interrupt-not-triggering-MC9S12DG256-CW-3-1/m-p/140964#M3186</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;FONT size="2"&gt;Hi Mac,&lt;BR /&gt;&lt;/FONT&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;FONT size="2"&gt;BigMac wrote:&lt;BR /&gt;&lt;/FONT&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;BR /&gt;However, there might be a potential problem if a bset&amp;nbsp;instruction was used to set a bit, other than the&amp;nbsp;flag bit - the flag could be unintentionally cleared.&lt;/FONT&gt;&lt;/DIV&gt;&lt;FONT size="2"&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;FONT size="2"&gt;I believe that IS the problem. Inadvertantly clearing a flag.&lt;BR /&gt;&lt;BR /&gt;Couple that with the fact that the C compiler generates BSET and BCLR instructions from statements like:&lt;BR /&gt;&lt;BR /&gt;TSC_TSTOP=1;&lt;BR /&gt;&lt;BR /&gt;An unsuspecting C programmer would never know where his/her firmware was going awry, without getting into the nuts &amp;amp; bolts of the MCU. Many companies have chosen C to &lt;U&gt;avoid&lt;/U&gt; the nuts &amp;amp; bolts of the MCU.&lt;BR /&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;Message Edited by rocco on &lt;SPAN class="date_text"&gt;2007-08-23&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;02:55 PM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Aug 2007 04:54:28 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/SPI-interrupt-not-triggering-MC9S12DG256-CW-3-1/m-p/140964#M3186</guid>
      <dc:creator>rocco</dc:creator>
      <dc:date>2007-08-24T04:54:28Z</dc:date>
    </item>
    <item>
      <title>Re: SPI interrupt not triggering (MC9S12DG256 + CW 3.1)</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/SPI-interrupt-not-triggering-MC9S12DG256-CW-3-1/m-p/140965#M3187</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hi Bigmac,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;The problem is not the intended action of the BSET clearing the flag but the unintended side effect of clearing any other write 1 to clear flags that are set in the same register.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;If you know that there is only one such flag in a specific register then it works fine, but only for the flag bit, (and I've used it occasionally, but only&amp;nbsp;with very&amp;nbsp;careful consideration).&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;As you point out, if you use&amp;nbsp;BSET it for any other bit in the register you also can accidentally clear flag bit(s) - so the simplest rule&amp;nbsp;is avoid using read-modify-write operations on any register that contains any write one to clear bits.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I am not aware of any instance of S12(X) designers changing this feature, it works very effectively the way it is and&amp;nbsp;you need to be able to read these flags as 1 else you couldn't test which flag had been set (to cause your interrupt for example).&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;And, I have used the CodeWarrior compiler a lot and the simple assignment does not&amp;nbsp;generate&amp;nbsp;BSET.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;cheers,&lt;/DIV&gt;&lt;DIV&gt;Dog&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Aug 2007 20:31:05 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/SPI-interrupt-not-triggering-MC9S12DG256-CW-3-1/m-p/140965#M3187</guid>
      <dc:creator>dog</dc:creator>
      <dc:date>2007-08-24T20:31:05Z</dc:date>
    </item>
    <item>
      <title>Re: SPI interrupt not triggering (MC9S12DG256 + CW 3.1)</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/SPI-interrupt-not-triggering-MC9S12DG256-CW-3-1/m-p/140966#M3188</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Dog,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;why using very carefully BSET&amp;nbsp;if you can use safely BCLR with inversed bit mask? Check Motorola HC11 pink book, you will find there asm examples.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Clearing bit N of TFLG1 can be done safely two ways:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;a) using non RMW instruction like this:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;MOVB&amp;nbsp; #(1&amp;lt;&amp;lt;N), TFLG1&amp;nbsp; ; in asm&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;TFLG1 = (1&amp;lt;&amp;lt;N);&amp;nbsp; //in C&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;b) using BCLR&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;BCLR&amp;nbsp; TFLG1, #~(1&amp;lt;&amp;lt;N)&amp;nbsp;&amp;nbsp; ; in asm&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;TFLG1 &amp;amp;= (1&amp;lt;&amp;lt;N);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // in C. Pls don't mix with&amp;nbsp; TFLG1 &amp;amp;= ~(1&amp;lt;&amp;lt;N);&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;^^ this can clear (write 1 to) only Nth bit and nothing else. Only two cases are possible:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;1) Nth bit is 0 before&amp;nbsp;TFLG1 &amp;amp;=(1&amp;lt;&amp;lt;N);. Then &amp;nbsp;CPU will write to register&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;xxxxxxx0 &amp;amp; 00000001 = 00000000.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;2) Nth bit is 1 before TFLG1 &amp;amp;=(1&amp;lt;&amp;lt;N);.&amp;nbsp;Then&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;xxxxxxx1 &amp;amp; 00000001 = 00000001&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Regards&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Aug 2007 21:00:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/SPI-interrupt-not-triggering-MC9S12DG256-CW-3-1/m-p/140966#M3188</guid>
      <dc:creator>kef</dc:creator>
      <dc:date>2007-08-24T21:00:54Z</dc:date>
    </item>
    <item>
      <title>Re: SPI interrupt not triggering (MC9S12DG256 + CW 3.1)</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/SPI-interrupt-not-triggering-MC9S12DG256-CW-3-1/m-p/140967#M3189</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Thanks Kef,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Good point!&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;It's mostly because I'm lazy and I use C headers that have nice easy to&amp;nbsp;to use bit&amp;nbsp;field definitions, so if I can say&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;TFLG1.bit1 = 1;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;and know it is not going to cause any problems for what I'm doing (possibly because I'm not using any other timer channels) then that's what I'll do sometimes.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Not as clean as the pink books &amp;amp;= solution though, I&amp;nbsp;certainly admit.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Dog&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Aug 2007 22:57:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/SPI-interrupt-not-triggering-MC9S12DG256-CW-3-1/m-p/140967#M3189</guid>
      <dc:creator>dog</dc:creator>
      <dc:date>2007-08-24T22:57:48Z</dc:date>
    </item>
    <item>
      <title>Re: SPI interrupt not triggering (MC9S12DG256 + CW 3.1)</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/SPI-interrupt-not-triggering-MC9S12DG256-CW-3-1/m-p/140968#M3190</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Oh no, you shouldn't use bitfields to clear flags. Just think how C handles bitfields. When you write access one field - C has to preserve bits outside the field. This means&amp;nbsp;C will automatically clear all set bits. Let's disassemble it&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp; 71:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TFLG1_C0F=1;&lt;BR /&gt;&amp;nbsp; 0000 4c0001&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [4]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BSET&amp;nbsp; _TFLG1,#1&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Ouch. Maybe clearing the bitfield could somehow magically help:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; 72:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TFLG1_C0F=0;&lt;BR /&gt;&amp;nbsp; 0003 4d0001&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [4]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BCLR&amp;nbsp; _TFLG1,#1&lt;BR /&gt;&lt;/DIV&gt;&lt;DIV&gt;Ouch again.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Are there other solutions with bit fields? Nope. Maybe there should be extension to C that could allow using bitfields with flags?&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Aug 2007 23:58:28 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/SPI-interrupt-not-triggering-MC9S12DG256-CW-3-1/m-p/140968#M3190</guid>
      <dc:creator>kef</dc:creator>
      <dc:date>2007-08-24T23:58:28Z</dc:date>
    </item>
    <item>
      <title>Re: SPI interrupt not triggering (MC9S12DG256 + CW 3.1)</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/SPI-interrupt-not-triggering-MC9S12DG256-CW-3-1/m-p/140969#M3191</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Woops!&lt;/DIV&gt;&lt;DIV&gt;It would seem I forgot which forum I was in. My comment refers to 8-bit devices. This is obviously not relevent with the 12's. The reason I checked was that I don't remember anyone being caught out by this.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 25 Aug 2007 05:50:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/SPI-interrupt-not-triggering-MC9S12DG256-CW-3-1/m-p/140969#M3191</guid>
      <dc:creator>peg</dc:creator>
      <dc:date>2007-08-25T05:50:38Z</dc:date>
    </item>
    <item>
      <title>Re: SPI interrupt not triggering (MC9S12DG256 + CW 3.1)</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/SPI-interrupt-not-triggering-MC9S12DG256-CW-3-1/m-p/140970#M3192</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;I know that it generates BSET, that's the point. Like I said, only when I'm being lazy and &lt;U&gt;know&lt;/U&gt; that this is not going to cause me problems.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;In general I very much agree with you - you'll see in my&amp;nbsp;previous posts that I advise that the simplest (and safest) rule is to stick to&amp;nbsp;plain old&amp;nbsp;assignment and avoid using read-modify-write operations on any register that contains write one to clear bits&amp;nbsp;- and this&amp;nbsp;is what I do&amp;nbsp;in&amp;nbsp;more complex code (say where I have several timer channels in use) or code I expect to get reused.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;dog&lt;/DIV&gt;&lt;DIV&gt;&lt;BR /&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Aug 2007 15:38:49 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/SPI-interrupt-not-triggering-MC9S12DG256-CW-3-1/m-p/140970#M3192</guid>
      <dc:creator>dog</dc:creator>
      <dc:date>2007-08-27T15:38:49Z</dc:date>
    </item>
    <item>
      <title>Re: SPI interrupt not triggering (MC9S12DG256 + CW 3.1)</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/SPI-interrupt-not-triggering-MC9S12DG256-CW-3-1/m-p/140971#M3193</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;Having recently revisited the issues discussed in this thread, I think that some of the confusion may be based on the assumption that a BSET instruction is atomic, and sets a bit in a register without touching any of the other bits.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Unfortunately, as mentioned above, this is not how the instruction is implemented on the HCS12. It appears to be implemented as a read-modify-write, which is implied, though not stated explicity, in the CPU reference manual (S12CPUV2 rev 4.0, p140), where it describes the operation as:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;Operation: (M) + (Mask) ⇒ M&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Unhelpfully, it also states:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;Description: Sets bits in memory location M. To set a bit, set the corresponding bit in the mask byte. All other bits in M are unchanged.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;...which is not the case for flag registers.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;So to reiterate what others have said here: C bitfield assignments are compiled to BSET, so are unsafe for flag registers if you're using other bits in the same register. Simple assignments have the desired effect.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Steve.&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Apr 2008 18:18:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/SPI-interrupt-not-triggering-MC9S12DG256-CW-3-1/m-p/140971#M3193</guid>
      <dc:creator>sjmelnikoff</dc:creator>
      <dc:date>2008-04-21T18:18:26Z</dc:date>
    </item>
    <item>
      <title>Re: SPI interrupt not triggering (MC9S12DG256 + CW 3.1)</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/SPI-interrupt-not-triggering-MC9S12DG256-CW-3-1/m-p/140972#M3194</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;This is correct if and only if read the register clears a flag, and you need to test the state of that flag.&lt;BR /&gt;In most cases, this is not an issue.&lt;BR /&gt;Even if the BSET instruction was not used, there would have to be a read of a register or memory location if a bit was to be set without changing the state of the other bits,&amp;nbsp; C bitfields are not a special case.&lt;BR /&gt;&lt;BR /&gt;If there was not a BSET instruction, and we are not use using C bitfields this:&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; *x |= 4;&lt;BR /&gt;&lt;BR /&gt;Would still generate a read modify cycle of some sort, even if it was to load a register, or the bit in and save it back.&lt;BR /&gt;&lt;BR /&gt;How is it possible to set a bit with out first reading the rest of the byte?&lt;BR /&gt;Are proposing an new kind of memory that is bit addressable - because in this architecture io registers appear as memory.&lt;BR /&gt;&lt;BR /&gt;In those few special cases, the user needs to know read the register first. It really does not matter how you do it, there will still be a read.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;Message Edited by JimDon on &lt;SPAN class="date_text"&gt;2008-04-21&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;08:29 AM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Apr 2008 19:28:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/SPI-interrupt-not-triggering-MC9S12DG256-CW-3-1/m-p/140972#M3194</guid>
      <dc:creator>JimDon</dc:creator>
      <dc:date>2008-04-21T19:28:18Z</dc:date>
    </item>
    <item>
      <title>Re: SPI interrupt not triggering (MC9S12DG256 + CW 3.1)</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/SPI-interrupt-not-triggering-MC9S12DG256-CW-3-1/m-p/140973#M3195</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;Agreed. As an aside:&lt;/DIV&gt;&lt;BLOCKQUOTE&gt;&lt;DIV&gt;&lt;HR /&gt;JimDon wrote:&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;BR /&gt;Are proposing an new kind of memory that is bit addressable - because in this architecture io registers appear as memory.&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;&lt;DIV&gt;Funny you should mention that, as we're doing some work with the STM32 processor, and it does indeed have bit-addressable memory, of a sort.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Each RAM location and reigster has an address in the memory map as normal. But in addition, each bit has its own address in a special "bit-banding" area of the memory space.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;So if you want to write to one bit without affecting any others in the same word, you can write to its bit-band address instead. It's a bit different from&amp;nbsp;using bitfields or masks, but does avoid some of the issues mentioned here.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Steve.&lt;BR /&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Apr 2008 19:55:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/SPI-interrupt-not-triggering-MC9S12DG256-CW-3-1/m-p/140973#M3195</guid>
      <dc:creator>sjmelnikoff</dc:creator>
      <dc:date>2008-04-21T19:55:25Z</dc:date>
    </item>
    <item>
      <title>Re: SPI interrupt not triggering (MC9S12DG256 + CW 3.1)</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/SPI-interrupt-not-triggering-MC9S12DG256-CW-3-1/m-p/140974#M3196</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;BR /&gt;&lt;BLOCKQUOTE&gt;&lt;DIV&gt;&lt;HR /&gt;sjmelnikoff wrote:&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;Unfortunately, as mentioned above, this is not how the instruction is implemented on the HCS12. It appears to be implemented as a read-modify-write, which is implied, though not stated explicity, in the CPU reference manual (S12CPUV2 rev 4.0, p140), where it describes the operation as:&lt;/DIV&gt;&lt;DIV&gt;&lt;HR /&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;While it doesn't say anything about a read-modify-write in the text describing this, the Access Details does show this.&amp;nbsp; For all addressing modes a 'r' is present indicating an 8-bit read.&amp;nbsp; It would be nice for them to&amp;nbsp;state it in the description of the command as they do in the HCS08 Reference Manual(Which also contains a section on the BSET and BCLR commands).&amp;nbsp;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Apr 2008 20:23:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/SPI-interrupt-not-triggering-MC9S12DG256-CW-3-1/m-p/140974#M3196</guid>
      <dc:creator>allawtterb</dc:creator>
      <dc:date>2008-04-21T20:23:18Z</dc:date>
    </item>
  </channel>
</rss>

