<?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: Changing channel function TIM08 in 8-bit Microcontrollers</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Changing-channel-function-TIM08/m-p/192550#M14867</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Jim,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You will observe that the paragraph that you quote is provided as a "note", and is not a "warning".&amp;nbsp; No mention is made of any consequences if this is not followed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since you need to continue counting, following the input capture event for the start bit, you certainly do not want to clear the TIM counter.&amp;nbsp; While you could conceivably halt the counter for a short interval while the registers are altered, I don't think that this is really necessary.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For PWM mode, certain precautions are necessary to prevent spurious pin output.&amp;nbsp; However, your requirement commences with input capture mode, and then changes to a software compare mode, and finally reverts back to input capture mode.&amp;nbsp; Just ensure that the channel interrupt flag is explicitly cleared after each mode change.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With a reasonable choice of bus frequency and baud rate, none of the channel timing would seem critical.&amp;nbsp; I cannot see why the AN2502 code should not work as intended.&amp;nbsp; The only potential timing issue would concern any other interrupts than may occur, and give additional latency in reading the pin state.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Mac&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 27 Dec 2011 11:41:04 GMT</pubDate>
    <dc:creator>bigmac</dc:creator>
    <dc:date>2011-12-27T11:41:04Z</dc:date>
    <item>
      <title>Changing channel function TIM08</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Changing-channel-function-TIM08/m-p/192548#M14865</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I wish to bit-bang a SCI receiver on a TIM08 channel in a similar way to that demonstrated in AN2502 so that I can use the other channel independently for other things. AN2502 says:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"It is possible to implement full-duplex operation because two independent&lt;/P&gt;&lt;P&gt;channels of the TIM are used for each of the operations with independent data&lt;/P&gt;&lt;P&gt;registers."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;...and...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"In the interrupt service routine (ISR) for the input capture, the time for the first&lt;/P&gt;&lt;P&gt;received bit is set. At this point, the reception channel is configured as output&lt;/P&gt;&lt;P&gt;compare and used as a time base for data bit receptions."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The TIM08 reference manual and the MCU datasheet seem to rule this out:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"&lt;SPAN style="font-size: 2;"&gt;&lt;SPAN style=": ; font-family: Arial;"&gt;NOTE:&lt;/SPAN&gt; &lt;SPAN style=": ; font-family: Arial;"&gt;Stop and reset the TIM before changing a channel function.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-size: 2; font-family: Arial;"&gt;Before writing to the mode select bits (MSxB and MSxA), set the timer&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style=": ; font-size: 2; font-family: Arial;"&gt;stop and timer reset bits (TSTOP and TRST) in the TSC register."&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd really like to reconcile these two sources before I proceed. Please let me know if you have any suggestions, ideally a datasheet or other reference that expands on the TIM08 directive.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Incidentally, I realise that bit-banging a SCI and coding for an HC08 are both a bit old-fashioned now!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Jim&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Dec 2011 11:54:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Changing-channel-function-TIM08/m-p/192548#M14865</guid>
      <dc:creator>JimB</dc:creator>
      <dc:date>2011-12-26T11:54:07Z</dc:date>
    </item>
    <item>
      <title>Re: Changing channel function TIM08</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Changing-channel-function-TIM08/m-p/192549#M14866</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jim,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is another attempt to reply, not as thorough as the previous attempt (I'm out of time).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can't help with your question directly, as I have always used HC08 and S08 that contained an SCI. However, I did implement a uart in a DSP once, using just two standard I/O pins and a periodic timer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I set one I/O pin as output for TX and one as input for RX. I set the timer to interrupt at 16x the baud rate.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would sample the RX pin on every timer interrupt, and update the TX pin on every 16th timer interrupt. The TX part was way too easy. The RX, not so.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For RX, I implemented a state-machine algorithm, as spelled-out in the SCI chapter of the HC08 databook: Syncing a mod-16 counter on the leading edge of the start-bit, and then sampling the data in every 7th, 9th and 11th interrupt.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But the DSP was a lot faster than an HC08. If the baud rate is high, you could reduce the timer to 8x the baud-rate and sample the 3rd, 4th and 5th interrupt. I can even see it working at 2x baud-rate.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Dec 2011 06:56:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Changing-channel-function-TIM08/m-p/192549#M14866</guid>
      <dc:creator>rocco</dc:creator>
      <dc:date>2011-12-27T06:56:59Z</dc:date>
    </item>
    <item>
      <title>Re: Changing channel function TIM08</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Changing-channel-function-TIM08/m-p/192550#M14867</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Jim,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You will observe that the paragraph that you quote is provided as a "note", and is not a "warning".&amp;nbsp; No mention is made of any consequences if this is not followed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since you need to continue counting, following the input capture event for the start bit, you certainly do not want to clear the TIM counter.&amp;nbsp; While you could conceivably halt the counter for a short interval while the registers are altered, I don't think that this is really necessary.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For PWM mode, certain precautions are necessary to prevent spurious pin output.&amp;nbsp; However, your requirement commences with input capture mode, and then changes to a software compare mode, and finally reverts back to input capture mode.&amp;nbsp; Just ensure that the channel interrupt flag is explicitly cleared after each mode change.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With a reasonable choice of bus frequency and baud rate, none of the channel timing would seem critical.&amp;nbsp; I cannot see why the AN2502 code should not work as intended.&amp;nbsp; The only potential timing issue would concern any other interrupts than may occur, and give additional latency in reading the pin state.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Mac&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Dec 2011 11:41:04 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Changing-channel-function-TIM08/m-p/192550#M14867</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2011-12-27T11:41:04Z</dc:date>
    </item>
    <item>
      <title>Re: Changing channel function TIM08</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Changing-channel-function-TIM08/m-p/192551#M14868</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you both (Rocco &amp;amp; Mac) for taking the time to help - I know it took me a long time just to get the question right :smileyalert:, so I really appreciate it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Rocco: your suggestion, as you say, could be a bit tight in my situation. In fact I have only 333 cycles per bit, and perhaps the clincher is that I wish to use the MCU's internal clock source rather than a xtal which I figure means I probably can't afford the added uncertainty of the phase difference between the periodic interrupt and the transmitter's bit clock with an achievable interrupt rate. I must confess I would also be worried about how the rest of my struggled-for code would perform with such a change, so perhaps I am just a bit chicken.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Mac: that gives me the confidence to proceed as intended, I hoped someone would say something like that! I suppose also that the author of AN2502 would have quickly discovered anything too severe. Your final point about interrupt latency and the clock-uncertainty consideration Rocco inspired has got me re-examining the rest of my design: It looks like my worst case is about 50 cycles, which I had thought would be OK, but I'll put it on my list to&amp;nbsp; consider whether I can unmask interrupts within that ISR.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again,&lt;/P&gt;&lt;P&gt;Jim&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Dec 2011 18:56:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Changing-channel-function-TIM08/m-p/192551#M14868</guid>
      <dc:creator>JimB</dc:creator>
      <dc:date>2011-12-27T18:56:48Z</dc:date>
    </item>
  </channel>
</rss>

