<?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: MC9S08GT60 Port Setting Problems in 8-bit Microcontrollers</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08GT60-Port-Setting-Problems/m-p/124596#M375</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;P&gt;Hi Andie,&lt;/P&gt;&lt;P&gt;I would have thought the more elegant solution was to use the&amp;nbsp;IF construct. It looks more like the BRSET that it generates and doesn't require the interrupts to be disabled. A comment should be made in the code here in case someone decides to "optimise" it later.&lt;/P&gt;&lt;P&gt;But "each to his own"&lt;/P&gt;&lt;P&gt;Also your "cos" explaination (or understanding) is not quite correct.&lt;/P&gt;&lt;P&gt;The value of the accumulator changing in the ISR is irrelevant as the accumulator value from the main routine is stacked before the ISR and unstacked after it. The problem is that this stacked value is supposed to be the current port value but after the ISR it won't (might not)&amp;nbsp;be.&lt;/P&gt;&lt;P&gt;Regards David&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 21 Jul 2006 17:22:53 GMT</pubDate>
    <dc:creator>peg</dc:creator>
    <dc:date>2006-07-21T17:22:53Z</dc:date>
    <item>
      <title>MC9S08GT60 Port Setting Problems</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08GT60-Port-Setting-Problems/m-p/124587#M366</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Processor: MC9S08GT60.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I am using the Port B as a Output (PTB0 .. PTB7).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The ATD Function is disabled.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Every 200ms i toggle each Pin of Port B in a Timer Overflow Interrupt with the commands PINxx ^= 1;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;In the majority of cases it works.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;But several times the whole Port B changes his Output value after a few µs i have set them.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;When i try this with a other Port (for Example Port D) it works every time.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Maybe someone can help me.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;andie&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Jul 2006 16:47:03 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08GT60-Port-Setting-Problems/m-p/124587#M366</guid>
      <dc:creator>the_andie</dc:creator>
      <dc:date>2006-07-20T16:47:03Z</dc:date>
    </item>
    <item>
      <title>Re: MC9S08GT60 Port Setting Problems</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08GT60-Port-Setting-Problems/m-p/124588#M367</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;P&gt;Hi Andie,&lt;/P&gt;&lt;P&gt;If you have the ADC function disabled and you have port B set up as all outputs then the pins will only change state on a write to PTBD or PTBDD. I would suggest you check your code or cut it down to a minimal program that can be posted here.&lt;/P&gt;&lt;P&gt;Regards David&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Jul 2006 18:26:40 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08GT60-Port-Setting-Problems/m-p/124588#M367</guid>
      <dc:creator>peg</dc:creator>
      <dc:date>2006-07-20T18:26:40Z</dc:date>
    </item>
    <item>
      <title>Re: MC9S08GT60 Port Setting Problems</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08GT60-Port-Setting-Problems/m-p/124589#M368</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;little corrections:&lt;BR /&gt;&lt;BR /&gt;in the interrupt routine i only toggle 3 pins of port b.&lt;BR /&gt;in the main program i toggle another pin of port b with smaller pulses ( 200µs).&lt;BR /&gt;when i toggle this pin with the command&lt;BR /&gt;&lt;BR /&gt;PTBD_PTBD7 ^= 1;&lt;BR /&gt;&lt;BR /&gt;then it could happens, that all other pins of port b (which has changed not very long ago) also changed !!!&lt;BR /&gt;when i toggle this pin with the command&lt;BR /&gt;&lt;BR /&gt;if (PTBD_PTBD7)&lt;BR /&gt;PTBD_PTBD7 = 0;&lt;BR /&gt;else&lt;BR /&gt;PTBD_PTBD7 = 1;&lt;BR /&gt;&lt;BR /&gt;then everything works correctly.&lt;BR /&gt;&lt;BR /&gt;can anyone tell me the reason of this?&lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;andie&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Jul 2006 23:28:52 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08GT60-Port-Setting-Problems/m-p/124589#M368</guid>
      <dc:creator>the_andie</dc:creator>
      <dc:date>2006-07-20T23:28:52Z</dc:date>
    </item>
    <item>
      <title>Re: MC9S08GT60 Port Setting Problems</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08GT60-Port-Setting-Problems/m-p/124590#M369</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Are you treating Port B as a critical section? This is a very common problem.&lt;BR /&gt;&lt;BR /&gt;When you toggle a bit with&lt;BR /&gt;PTBD_PTBD7 ^= 1;&lt;BR /&gt;you are doing a read/modify/write.&lt;BR /&gt;&lt;BR /&gt;Since you are changing port B in both the main code (with interrupts enabled, I assume) and in an ISR, you have what is called a "critical section". What can happen is that the interrupt occurs after the read, but before the write. That make the read invalid, since the ISR has changed the port value subsequent to the read.&lt;BR /&gt;&lt;BR /&gt;To treat port B as a critical section, you need to disable interrupts during any access to it (prior to the read, until after the write).&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Jul 2006 03:05:05 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08GT60-Port-Setting-Problems/m-p/124590#M369</guid>
      <dc:creator>rocco</dc:creator>
      <dc:date>2006-07-21T03:05:05Z</dc:date>
    </item>
    <item>
      <title>Re: MC9S08GT60 Port Setting Problems</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08GT60-Port-Setting-Problems/m-p/124591#M370</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;FONT size="2"&gt;Hello Andie,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;As a matter of curiosity, do you still get the same problem if you&amp;nbsp;use the following -&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;PTBD_PTBD7 = PTBD_PTBD7 ^ 1;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Regards,&lt;BR /&gt;Mac&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Jul 2006 14:07:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08GT60-Port-Setting-Problems/m-p/124591#M370</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2006-07-21T14:07:18Z</dc:date>
    </item>
    <item>
      <title>Re: MC9S08GT60 Port Setting Problems</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08GT60-Port-Setting-Problems/m-p/124592#M371</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;bigmac wrote:&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;FONT size="2"&gt;Hello Andie,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;As a matter of curiosity, do you still get the same problem if you&amp;nbsp;use the following -&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;PTBD_PTBD7 = PTBD_PTBD7 ^ 1;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Regards,&lt;BR /&gt;Mac&lt;/FONT&gt;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Not sure what you're thinking here Mac...&lt;/P&gt;&lt;P&gt;The above is equivalent in C to &lt;FONT face="Courier New" size="2"&gt;PTBD_PTBD7 ^= 1;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;so surely it compiles to the same thing???&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;The if else structure probably compiles to BRSET and then BSET, BCLR and thus avoids the problem as there is no bytes held between opcodes and therefore the ISR can break in anywhere.&lt;/P&gt;&lt;P&gt;Another example of C being inappropriate for this kind of stuff.&lt;/P&gt;&lt;P&gt;Regards David&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Jul 2006 14:33:28 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08GT60-Port-Setting-Problems/m-p/124592#M371</guid>
      <dc:creator>peg</dc:creator>
      <dc:date>2006-07-21T14:33:28Z</dc:date>
    </item>
    <item>
      <title>Re: MC9S08GT60 Port Setting Problems</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08GT60-Port-Setting-Problems/m-p/124593#M372</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;@ rocco:&lt;BR /&gt;&lt;BR /&gt;i understand your explications. but in the main code and in the ISR i do not change the same pins of the port. the strange thing is, that i want to change a pin and then the whole port were changed.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;@ bigmac:&lt;BR /&gt;&lt;BR /&gt;when i use the command&lt;BR /&gt;PTBD_PTBD7 = PTBD_PTBD7 ^ 1;&lt;BR /&gt;i don't have the problem, cos the compiler (CW) translate it also to BRSET and then BSET, BCLR commands, like the if-else command.&lt;BR /&gt;&lt;BR /&gt;when i use the comand&lt;BR /&gt;PTBD_PTBD7 ^= 1;&lt;BR /&gt;the compiler translate it to LDA, EOR and STA commands and then i have the problems...&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Jul 2006 15:14:19 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08GT60-Port-Setting-Problems/m-p/124593#M372</guid>
      <dc:creator>the_andie</dc:creator>
      <dc:date>2006-07-21T15:14:19Z</dc:date>
    </item>
    <item>
      <title>Re: MC9S08GT60 Port Setting Problems</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08GT60-Port-Setting-Problems/m-p/124594#M373</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;P&gt;OK, so CW compiles these two versions of the same thing differently.&lt;/P&gt;&lt;P&gt;The LDA, EOR, STA can fail because if the ISR interrupts in between these three commands then the main code will continue with a stale value for the port. This will set any bits that where changed in the ISR back to what they were before the ISR did its thing.&lt;/P&gt;&lt;P&gt;In the bit testing case, no value for the whole port is retained only the branch address which is determined in one opcode.&lt;/P&gt;&lt;P&gt;David&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Jul 2006 15:35:15 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08GT60-Port-Setting-Problems/m-p/124594#M373</guid>
      <dc:creator>peg</dc:creator>
      <dc:date>2006-07-21T15:35:15Z</dc:date>
    </item>
    <item>
      <title>Re: MC9S08GT60 Port Setting Problems</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08GT60-Port-Setting-Problems/m-p/124595#M374</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;thank you all for your help!&lt;BR /&gt;&lt;BR /&gt;the solution is, that i disable the interrups, like rocco said.&lt;BR /&gt;&lt;BR /&gt;__asm SEI;&lt;BR /&gt;PTBD_PTBD7 ^= 1;&lt;BR /&gt;__asm CLI;&lt;BR /&gt;&lt;BR /&gt;cos in the ISR the value of the accumulator were changed.&lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;andie.&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Jul 2006 17:00:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08GT60-Port-Setting-Problems/m-p/124595#M374</guid>
      <dc:creator>the_andie</dc:creator>
      <dc:date>2006-07-21T17:00:58Z</dc:date>
    </item>
    <item>
      <title>Re: MC9S08GT60 Port Setting Problems</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08GT60-Port-Setting-Problems/m-p/124596#M375</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;P&gt;Hi Andie,&lt;/P&gt;&lt;P&gt;I would have thought the more elegant solution was to use the&amp;nbsp;IF construct. It looks more like the BRSET that it generates and doesn't require the interrupts to be disabled. A comment should be made in the code here in case someone decides to "optimise" it later.&lt;/P&gt;&lt;P&gt;But "each to his own"&lt;/P&gt;&lt;P&gt;Also your "cos" explaination (or understanding) is not quite correct.&lt;/P&gt;&lt;P&gt;The value of the accumulator changing in the ISR is irrelevant as the accumulator value from the main routine is stacked before the ISR and unstacked after it. The problem is that this stacked value is supposed to be the current port value but after the ISR it won't (might not)&amp;nbsp;be.&lt;/P&gt;&lt;P&gt;Regards David&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Jul 2006 17:22:53 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08GT60-Port-Setting-Problems/m-p/124596#M375</guid>
      <dc:creator>peg</dc:creator>
      <dc:date>2006-07-21T17:22:53Z</dc:date>
    </item>
    <item>
      <title>Re: MC9S08GT60 Port Setting Problems</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08GT60-Port-Setting-Problems/m-p/124597#M376</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Hi David,&lt;BR /&gt;&lt;BR /&gt;now i understand it. You've right, again. That's exactly what i measure with my oscilloscope.&lt;BR /&gt;I also choose the IF construct and hope the compiler will translate it always in the same way :smileywink:&lt;BR /&gt;&lt;BR /&gt;Thanks, andie.&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Jul 2006 19:09:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08GT60-Port-Setting-Problems/m-p/124597#M376</guid>
      <dc:creator>the_andie</dc:creator>
      <dc:date>2006-07-21T19:09:58Z</dc:date>
    </item>
    <item>
      <title>Re: MC9S08GT60 Port Setting Problems</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08GT60-Port-Setting-Problems/m-p/124598#M377</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;FONT size="2"&gt;Hello all,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;It actually surprises me that the compiler ever does a BSET/BCLR construct to represent the exclusive-OR case, simply because there is no single instruction to "flip a single bit", and the bit mask&amp;nbsp;construct would be simpler.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;This seems to demonstrate a very significant "trap" that is not obvious when using C, and whether or not&amp;nbsp;a problem occurs could well be compiler dependent.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;The situation is much more obvious with assembly programming where it is clearly evident whether single&amp;nbsp;BSET or BCLR instructions are used, or multiple instructions using a bit mask is used.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;The&amp;nbsp;problem could apply with the manipulation of&amp;nbsp;&lt;U&gt;any&lt;/U&gt; bit within a port, where other bits&amp;nbsp;can change under interrupt control (and where the evidence that other bits&amp;nbsp;may alter may be in a totally different file).&amp;nbsp; This would seem to imply that the only safe way to manipulate an I/O port bit in C code is to disable interrupts, and to re-enable them after the manipulation, just in case an interrupt might affect another bit in the same port, now or in a future upgrade of the firmware.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Regards,&lt;BR /&gt;Mac&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Jul 2006 21:23:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08GT60-Port-Setting-Problems/m-p/124598#M377</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2006-07-21T21:23:54Z</dc:date>
    </item>
    <item>
      <title>Re: MC9S08GT60 Port Setting Problems</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08GT60-Port-Setting-Problems/m-p/124599#M378</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;peg wrote:&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;P&gt;Another example of C being inappropriate for this kind of stuff.&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;BR /&gt;With all due respect, Peg, I have never found an example of C being inappropriate for this kind of stuff.&amp;nbsp; Nowadays, the vast majority of embedded applications are written in C.&amp;nbsp; Everything is possible - albeit open to debate about being less efficient during runtime and&amp;nbsp;more efficient in programming time.&lt;/P&gt;&lt;P&gt;Also, it is erroneous to assume that a single assembly instruction is atomic.&amp;nbsp; The HC12, for example, has a handful of non-atomic assembly instructions that can be interrupted.&amp;nbsp; As processors become more pipelined this becomes even more evident, but for the HC08 I believe all instructions are atomic.&lt;/P&gt;&lt;P&gt;It is standard practice to force code segments into being atomic when multiple threads access the same variables.&amp;nbsp; It is the first&amp;nbsp;zinger that appears in any textbook when discussing threaded programming.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Jul 2006 02:33:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08GT60-Port-Setting-Problems/m-p/124599#M378</guid>
      <dc:creator>rhinoceroshead</dc:creator>
      <dc:date>2006-07-27T02:33:57Z</dc:date>
    </item>
    <item>
      <title>Re: MC9S08GT60 Port Setting Problems</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08GT60-Port-Setting-Problems/m-p/124600#M379</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;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;My point is that if you have to concern yourself with what the code will compile into (or how different compilers will generate the output) then what is the purpose of using the higher level language?&lt;/P&gt;&lt;P&gt;With a proper hardware abstraction layer it is fine (or where you are not dealing directly with the hardware). Because then you just code away making it do what you want.&lt;/P&gt;&lt;P&gt;My "this kind of stuff" wasn't meant to refer to embedded processors in general, but more specifically bit level hardware manipulation.&lt;/P&gt;&lt;P&gt;As the question relates to a specific 9S08 processor, I take it that the last two paragraphs are just general comment.&lt;/P&gt;&lt;P&gt;Hmm.. took a while to get a bite, I thought the bait had rotted away. &lt;IMG alt=":smileyhappy:" class="emoticon emoticon-smileyhappy" id="smileyhappy" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-happy.gif" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;Regards David&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Message Edited by peg on &lt;SPAN class="date_text"&gt;2006-07-27&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;09:34 PM&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Jul 2006 17:44:24 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08GT60-Port-Setting-Problems/m-p/124600#M379</guid>
      <dc:creator>peg</dc:creator>
      <dc:date>2006-07-27T17:44:24Z</dc:date>
    </item>
    <item>
      <title>Re: MC9S08GT60 Port Setting Problems</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08GT60-Port-Setting-Problems/m-p/124601#M380</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;P&gt;Appropriate or inappropriate, I've never been&amp;nbsp;surprised&amp;nbsp;by the way CW does bit-level hardware manipulation and I've used C exclusively for years.&amp;nbsp; That's why I'm surprised to find someone claiming that it is, perhaps, unreliable.&lt;/P&gt;&lt;P&gt;You know, I see a lot of people doing bit setting/clearing in C like this:&lt;/P&gt;&lt;P&gt;PTBD_PTBD7 = 1;&lt;/P&gt;&lt;P&gt;which is fine, but I was taught to do it with the whole byte and a bitmask like this:&lt;/P&gt;&lt;P&gt;PTBD |= 0x80;&lt;/P&gt;&lt;P&gt;In the case of the exclusive or, with a single bit, does the bitwise XOR even make sense when applied to a single bit?&amp;nbsp; The_andie originally stated that the entire port was sometimes flipping its state.&lt;/P&gt;&lt;P&gt;My question is, how did the other bits get flipped if CW was using BRSET, BSET, and BCLR?&lt;/P&gt;&lt;P&gt;It seems like CW must be doing something like:&lt;/P&gt;&lt;P&gt;PTB ^= 1;&lt;/P&gt;&lt;P&gt;instead of applying the XOR to just 1 bit like:&lt;/P&gt;&lt;P&gt;PTBD_PTBD7 ^=1;&lt;/P&gt;&lt;P&gt;I've never looked into how the bit structures are laid out in the really long header file where they are defined...&amp;nbsp; Maybe the answer lies in there somewhere.&lt;/P&gt;&lt;P&gt;I've always toggled bits like this:&lt;/P&gt;&lt;P&gt;if (PTB &amp;amp; 0x80) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PTB &amp;amp;= ~0x80;&lt;BR /&gt;} else {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PTB |= 0x80;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;This&amp;nbsp;compiles to&amp;nbsp;BRCLR, BRSET and BCLR - which should never mess with other bits in the port.&amp;nbsp; But still I would disable interrupts before starting this segment.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Jul 2006 10:53:35 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08GT60-Port-Setting-Problems/m-p/124601#M380</guid>
      <dc:creator>rhinoceroshead</dc:creator>
      <dc:date>2006-07-28T10:53:35Z</dc:date>
    </item>
  </channel>
</rss>

