<?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>8-bit MicrocontrollersのトピックRe: Timer Interface Module Problems</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC68HC908JK1-Timer-Interface-Module-Problems/m-p/142807#M6413</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Hello Mauricio and Peg,&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;It would appear that the compiler is sufficiently smart to generate code that writes high byte first.&amp;nbsp; This would seem to apply whether the variables Modulo and Duty are global or local.&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;Actually, in this case, I would tend to write all bits simultaneously to both TSC0 and TSC registers, since there is no apparent reason to set the bits individually.&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 face="Courier New" size="2"&gt;TMOD = Modulo;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;TCNT = Duty;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;TSC0 = 0x1A;&amp;nbsp; /* Unbuffered PWM mode */&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;TSC = 0x00;&amp;nbsp;&amp;nbsp; /* Start timer with pre-scale = 1&amp;nbsp;*/&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;Are you monitoring the output pin with an oscilloscope to determine that it is not working?&amp;nbsp; Do you have a transistor driver for the LED?&amp;nbsp; The output pin of the MCU probably won't have sufficient drive capability for a reflective sensor device.&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 you are actually monitoring at the output of the IR detector, does this provide internal&amp;nbsp;filtering for a specific carrier (PWM)&amp;nbsp;frequency?&amp;nbsp; If so, you would probably need to trim the internal oscillator of the MCU.&amp;nbsp; Keep in mind that each PWM output cycle will consist of (TMOD+1) bus cycles.&amp;nbsp; With a modulo value of only 62, the accuracy of the PWM&amp;nbsp;frequency will be limited.&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;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Aug 2007 11:28:34 GMT</pubDate>
    <dc:creator>bigmac</dc:creator>
    <dc:date>2007-08-12T11:28:34Z</dc:date>
    <item>
      <title>MC68HC908JK1  - Timer Interface Module Problems</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC68HC908JK1-Timer-Interface-Module-Problems/m-p/142804#M6410</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;P&gt;Hi:&lt;BR /&gt;i'm in trouble with the configuration of the TIM module of MC68HC908JK1 microcontroller.&amp;nbsp;&amp;nbsp; i wwant to use it as an PWM output to trigger a led in a IR reflective sensor.&amp;nbsp; it seems that the sintaxis is good, but it doesn't work!!!!!&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;this is the program (section of the TIM configuration):&lt;BR /&gt;&lt;BR /&gt;unsigned int Frecuencia=40;&lt;BR /&gt;unsigned int Dureza=4;&lt;BR /&gt;unsigned int Modulo;&lt;BR /&gt;unsigned int Duty;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;void Emisor(void){&lt;BR /&gt;Modulo=2500/Frecuencia;&lt;BR /&gt;Duty=Dureza*Modulo/100;&lt;BR /&gt;TSC_TSTOP=1;&lt;BR /&gt;TSC_TRST=1;&lt;BR /&gt;TMOD=Modulo;&lt;BR /&gt;TCH0=Duty;&lt;BR /&gt;TSC0_MS0A=1;&lt;BR /&gt;TSC0_ELS0B=1;&lt;BR /&gt;TSC0_TOV0=1;&lt;BR /&gt;TSC_TRST=0;&lt;BR /&gt;TSC_TSTOP=0;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Added part number to subject.&lt;BR /&gt;&lt;/P&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Message Edited by NLFSJ on &lt;/SPAN&gt;&lt;SPAN class="date_text"&gt;2007-08-12&lt;/SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;SPAN class="time_text"&gt;11:46 PM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Aug 2007 01:56:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC68HC908JK1-Timer-Interface-Module-Problems/m-p/142804#M6410</guid>
      <dc:creator>mauricio2346</dc:creator>
      <dc:date>2007-08-12T01:56:08Z</dc:date>
    </item>
    <item>
      <title>Re: Timer Interface Module Problems</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC68HC908JK1-Timer-Interface-Module-Problems/m-p/142805#M6411</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hi mauricio,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;This basically looks correct. However this older device does not have the HLL friendly "write either byte first" latches on the TMOD and TCHx double registers.&lt;/DIV&gt;&lt;DIV&gt;They need to be written high byte first in each case. You need to check what your resultant code is doing and perhaps do&amp;nbsp;this more specifically in your C code.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Aug 2007 06:53:32 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC68HC908JK1-Timer-Interface-Module-Problems/m-p/142805#M6411</guid>
      <dc:creator>peg</dc:creator>
      <dc:date>2007-08-12T06:53:32Z</dc:date>
    </item>
    <item>
      <title>Re: Timer Interface Module Problems</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC68HC908JK1-Timer-Interface-Module-Problems/m-p/142806#M6412</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;Hi.&lt;BR /&gt;yeah, it seems to be correct.&amp;nbsp; after i wrote my last message, i found a little thing that maybe was the problem: the "Frecuencia" and "Duty" values. i couldn't understand why this values worked in other program with other microcontroller (mc68hc908gp32) with the same aplication: "38Khz Infrared receiver".&amp;nbsp; changing that values just a little and poof..... it worked!!!&amp;nbsp;&lt;BR /&gt;i understand that this device is a "fossil", but sometimes the older, the better, (the cheaper), jajajaja.&amp;nbsp; sometimes i think that i should keep a couple of this devices, in&amp;nbsp; 5 years i'll be rich selling them..&lt;BR /&gt;Now my problem is bigger: i have a couple of discrete H bridges and i can't find the problem... they don't work!!!&lt;BR /&gt;&lt;BR /&gt;Thank you so much...!!!&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;Message Edited by mauricio2346 on &lt;SPAN class="date_text"&gt;2007-08-12&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;05:09 AM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Aug 2007 11:08:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC68HC908JK1-Timer-Interface-Module-Problems/m-p/142806#M6412</guid>
      <dc:creator>mauricio2346</dc:creator>
      <dc:date>2007-08-12T11:08:23Z</dc:date>
    </item>
    <item>
      <title>Re: Timer Interface Module Problems</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC68HC908JK1-Timer-Interface-Module-Problems/m-p/142807#M6413</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Hello Mauricio and Peg,&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;It would appear that the compiler is sufficiently smart to generate code that writes high byte first.&amp;nbsp; This would seem to apply whether the variables Modulo and Duty are global or local.&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;Actually, in this case, I would tend to write all bits simultaneously to both TSC0 and TSC registers, since there is no apparent reason to set the bits individually.&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 face="Courier New" size="2"&gt;TMOD = Modulo;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;TCNT = Duty;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;TSC0 = 0x1A;&amp;nbsp; /* Unbuffered PWM mode */&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;TSC = 0x00;&amp;nbsp;&amp;nbsp; /* Start timer with pre-scale = 1&amp;nbsp;*/&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;Are you monitoring the output pin with an oscilloscope to determine that it is not working?&amp;nbsp; Do you have a transistor driver for the LED?&amp;nbsp; The output pin of the MCU probably won't have sufficient drive capability for a reflective sensor device.&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 you are actually monitoring at the output of the IR detector, does this provide internal&amp;nbsp;filtering for a specific carrier (PWM)&amp;nbsp;frequency?&amp;nbsp; If so, you would probably need to trim the internal oscillator of the MCU.&amp;nbsp; Keep in mind that each PWM output cycle will consist of (TMOD+1) bus cycles.&amp;nbsp; With a modulo value of only 62, the accuracy of the PWM&amp;nbsp;frequency will be limited.&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;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Aug 2007 11:28:34 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC68HC908JK1-Timer-Interface-Module-Problems/m-p/142807#M6413</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2007-08-12T11:28:34Z</dc:date>
    </item>
    <item>
      <title>Re: Timer Interface Module Problems</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC68HC908JK1-Timer-Interface-Module-Problems/m-p/142808#M6414</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Hi.&lt;BR /&gt;No Bigmac, i have already solve the problem.&amp;nbsp; it was only a little change on the variable's values.&amp;nbsp; you idea is great, less code, i'll try it!!&lt;BR /&gt;&lt;BR /&gt;already i'm programming and i have a question:&lt;BR /&gt;&lt;BR /&gt;can i declare a global variable that works in the main program and the libraries at the same time?&lt;BR /&gt;&lt;BR /&gt;i have a library (MOTORAPI.c and MOTORAPI.h) that controls a pair of dc motors with the codes to the h bridges.&amp;nbsp; in MOTORAPI.h i wrote this:&lt;BR /&gt;&lt;BR /&gt;signed char Estado;&lt;BR /&gt;&lt;BR /&gt;void Atras (void){&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Estado=-1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PTB_PTB3=1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PTD_PTD2=0;&lt;BR /&gt;}&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;void Adelante(void){&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Estado=1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PTB_PTB3=0;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PTD_PTD2=1;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;Estado controls two bumpers (both conected to IRQ pin).&amp;nbsp; while the program is running, i want to control if the aplication moves forward or backward with Estado. in the main program i wrote this:&lt;BR /&gt;&lt;BR /&gt;void interrupt 2 Init_IRQ_Isr(void){&lt;BR /&gt;INTSCR_ACK1=1;&lt;BR /&gt;if(Estado==1){&lt;BR /&gt;Parar();&lt;BR /&gt;Centro();&lt;BR /&gt;Delayms(500);&lt;BR /&gt;Atras();&lt;BR /&gt;Izquierda();&lt;BR /&gt;Delayms(800);&lt;BR /&gt;Parar();&lt;BR /&gt;Delayms(500);&lt;BR /&gt;Adelante();&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;i want to use Estado to control the movement of the aplication (robot).&amp;nbsp; can i???&lt;BR /&gt;&lt;BR /&gt;Regards..&lt;BR /&gt;mauricio2346&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Aug 2007 12:29:21 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC68HC908JK1-Timer-Interface-Module-Problems/m-p/142808#M6414</guid>
      <dc:creator>mauricio2346</dc:creator>
      <dc:date>2007-08-12T12:29:21Z</dc:date>
    </item>
    <item>
      <title>Re: Timer Interface Module Problems</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC68HC908JK1-Timer-Interface-Module-Problems/m-p/142809#M6415</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;ajajaja!! i forgot to say that the IR Emitter uses a transistor in saturation mode between the MCU and LED.&amp;nbsp; it works fine.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Regards...&lt;BR /&gt;mauricio2346&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Aug 2007 12:32:31 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC68HC908JK1-Timer-Interface-Module-Problems/m-p/142809#M6415</guid>
      <dc:creator>mauricio2346</dc:creator>
      <dc:date>2007-08-12T12:32:31Z</dc:date>
    </item>
    <item>
      <title>Re: Timer Interface Module Problems</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC68HC908JK1-Timer-Interface-Module-Problems/m-p/142810#M6416</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hi Mac,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I am not sure if the compiler is "smart" or this is just how it does it. On a straight assignment and with the one compiler (Codewarrior I presume you tested) you could perhaps rely on it.&lt;/DIV&gt;&lt;DIV&gt;Given that I don't believe that the compiler is aware of the exact derivative that it is compiling for, I still don't think you can rely on this always. If the compiler does this always under all optimisations for every location it would be missing out sometimes.&lt;/DIV&gt;&lt;DIV&gt;Perhaps the "Guru" could shed some light on this.&lt;/DIV&gt;&lt;DIV&gt;When Freescale removed the restriction they made the point that it was to help compatability with HLL's.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Also to the OP, you are resetting the RST bit in TSC, this is unnecessary. (meant to mention this before).&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Aug 2007 13:25:53 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC68HC908JK1-Timer-Interface-Module-Problems/m-p/142810#M6416</guid>
      <dc:creator>peg</dc:creator>
      <dc:date>2007-08-12T13:25:53Z</dc:date>
    </item>
    <item>
      <title>Re: Timer Interface Module Problems</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC68HC908JK1-Timer-Interface-Module-Problems/m-p/142811#M6417</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;The compiler was changed to generate that order,here's the release note entry:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;DIV class="msg_source_code"&gt;&lt;DIV class="text_smallest"&gt;out of compler release notes:&lt;/DIV&gt;&lt;PRE&gt;RELEASE NOTES CHC08 V5.0.18...List of new Features- Changed access order to objects declared with 'volatile', typically IO registers:  volatile unsigned int TCNT;  TCNT = 0x1234;  gives now code that accesses the low address byte first:  LDA   #52  LDX   #18  STX   TCNT  STA   TCNT:1  previous compiler versions accessed all objects high address byte first.....&lt;/PRE&gt;&lt;/DIV&gt;&lt;BR /&gt;Note that the current compiler version is V5.0.24, so that was changed quite some time ago.&lt;BR /&gt;&lt;BR /&gt;Daniel&lt;BR /&gt;&lt;BR /&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 08:43:06 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC68HC908JK1-Timer-Interface-Module-Problems/m-p/142811#M6417</guid>
      <dc:creator>CompilerGuru</dc:creator>
      <dc:date>2020-10-29T08:43:06Z</dc:date>
    </item>
    <item>
      <title>Re: Timer Interface Module Problems</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC68HC908JK1-Timer-Interface-Module-Problems/m-p/142812#M6418</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 Mauricio,&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 global variable Estado is defined in the main program, you can use it from within the library file, but for visibility of the variable you will also need to declare it within the second file.&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 face="Courier New" size="2"&gt;extern signed char;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;This could be placed directly in the&amp;nbsp;library&amp;nbsp;file prior to first use, or alternatively&amp;nbsp;within a header file included in the library file.&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 further comment about your ISR code -&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;It could be problematic to include lengthy delays within the ISR function (and is a bad programming practice).&amp;nbsp; This will&amp;nbsp;prevent any background tasks, and any other ISRs,&amp;nbsp;from executing for the for the duration of the delayed ISR.&amp;nbsp; It is better to exit the ISR function as quickly as possible, and to&amp;nbsp;provide the delays as a background task within the main loop.&amp;nbsp; You might use a global&amp;nbsp;variable to provide communication between the ISR and the background task.&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;For example,&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 face="Courier New" size="2"&gt;/* Global variable definition */&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;unsigned char int_flag = 0;&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;Within main loop:&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 face="Courier New" size="2"&gt;if (int_flag) {&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;nbsp; Delayms(500);&lt;BR /&gt;&amp;nbsp; Atras();&lt;BR /&gt;&amp;nbsp; Izquierda();&lt;BR /&gt;&amp;nbsp; Delayms(800);&lt;BR /&gt;&amp;nbsp; Parar();&lt;BR /&gt;&amp;nbsp; Delayms(500);&lt;BR /&gt;&amp;nbsp; Adelante();&lt;BR /&gt;&amp;nbsp; int_flag = 0;&amp;nbsp; /* Clear flag */&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;}&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;Modified ISR code:&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 face="Courier New" size="2"&gt;void interrupt 2 Init_IRQ_Isr(void){&lt;BR /&gt;&amp;nbsp; INTSCR_ACK1 = 1;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;nbsp;&amp;nbsp;if (!int_flag) {&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Execute following only if flag is clear */&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (Estado == 1) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int_flag = 1;&amp;nbsp;&amp;nbsp; /* Set flag */&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Parar();&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Assumed to be&amp;nbsp;quick functions */&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Centro();&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;nbsp; }&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New" size="2"&gt;}&lt;BR /&gt;&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>Mon, 13 Aug 2007 11:07:12 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC68HC908JK1-Timer-Interface-Module-Problems/m-p/142812#M6418</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2007-08-13T11:07:12Z</dc:date>
    </item>
    <item>
      <title>Re: Timer Interface Module Problems</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC68HC908JK1-Timer-Interface-Module-Problems/m-p/142813#M6419</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I thought I remembered that the compiler was supposed to take care of it, but I've just had problems with it:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;TCH1 = TMOD * scratch_byte &amp;gt;&amp;gt; 8;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(or even TCH1 = TMOD &amp;gt;&amp;gt; 8&lt;IMG alt=":smileywink:" class="emoticon emoticon-smileywink" id="smileywink" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-wink.gif" title="Smiley Wink" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Compiler seems to get them the wrong way round - apparently because it knows the high byte is 0.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is this right?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jim&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 19 Apr 2009 15:56:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC68HC908JK1-Timer-Interface-Module-Problems/m-p/142813#M6419</guid>
      <dc:creator>JimB</dc:creator>
      <dc:date>2009-04-19T15:56:02Z</dc:date>
    </item>
    <item>
      <title>Re: Timer Interface Module Problems</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC68HC908JK1-Timer-Interface-Module-Problems/m-p/142814#M6420</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;The operation &lt;FONT face="courier new,courier"&gt;TMOD * scratch_byte&lt;/FONT&gt; seems to be problematic.&amp;nbsp; We are multiplying a 16-bit value with an 8-bit value, with the possible result of unsigned long value.&amp;nbsp; The result always seems to be zero.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I obtained the expected result with the following code -&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp; dword c;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp; c = TMOD;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; c *= scratch_byte;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; TCH1 = (word)(c &amp;gt;&amp;gt; 8);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The cast was required to eliminate a "possible loss of data" warning.&amp;nbsp; Yet the following expression gave a zero result for c, and casts did not seem to help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp; c = TMOD * scratch_byte;&lt;/FONT&gt;&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;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 19 Apr 2009 20:01:12 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC68HC908JK1-Timer-Interface-Module-Problems/m-p/142814#M6420</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2009-04-19T20:01:12Z</dc:date>
    </item>
    <item>
      <title>Re: MC68HC908JK1  - Timer Interface Module Problems</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC68HC908JK1-Timer-Interface-Module-Problems/m-p/142815#M6421</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&lt;P&gt;&lt;FONT size="2"&gt;Hello Mac,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Thank you very much for your reply.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;In my application I happen to know that TMOD is less than 256, and originally chose 16-bit arithmetic for speed and because it was sufficient - and left a warning comment for myself that hopefully I would spot if I changed TMOD. I suppose my use of "TMOD" rather than "(word)TMODL" shows a lack of commitment!&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;I don't think I've had any strange results with the actual value - only that the two TCH1 byte-writes occur in the wrong order, which (unsurprisingly given the earlier result) also happens if I take your code snippet but do the cast before the shift: it seems to be torn between the knowledge that the expression really would fit in a byte but that it must be padded out to a word, and in so doing forgets that TCH1 is supposed to be written high byte first.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;I'll take a fresh look at my application to see if there is any reason for not using a dword. I suppose if I do make the assumption that TMODH is zero, it would be logical to leave TCH1H alone (having once set it to zero) and just write TCH1L each time. Something for me to think about.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Thanks,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Jim&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Apr 2009 05:02:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC68HC908JK1-Timer-Interface-Module-Problems/m-p/142815#M6421</guid>
      <dc:creator>JimB</dc:creator>
      <dc:date>2009-04-20T05:02:56Z</dc:date>
    </item>
    <item>
      <title>Re: MC68HC908JK1  - Timer Interface Module Problems</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC68HC908JK1-Timer-Interface-Module-Problems/m-p/142816#M6422</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;I did some further tests with the value of TMOD limited, as you described.&amp;nbsp; I also checked the HCS08, in addition to the HC908, to see if there were any differences.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For the HC908, the following code was tested:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp; word c;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; volatile byte scratch_byte = 0x40;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; TMOD = 0x00F0;&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp; // Case 1:&lt;BR /&gt;&amp;nbsp;&amp;nbsp; c = TMODL * scratch_byte / 256;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; TCH1 = c;&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp; // Case 2:&lt;BR /&gt;&amp;nbsp;&amp;nbsp; TCH1 = TMODL * scratch_byte / 256;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The compiler generated the following code to write to TCH1.&lt;/P&gt;&lt;P&gt;Case 1:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; STX&amp;nbsp; 0x29&amp;nbsp; ; High byte first&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; STA&amp;nbsp; 0x2A&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Case 2:&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; STHX 0x29&amp;nbsp; ; This should also be OK&lt;/FONT&gt;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The equivalent code for the HCS08:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp; volatile word scratch_byte = 0x40;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; word c;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; TPM1MOD = 0x00F0;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; // Case 1:&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp; c = TPM1MODL * scratch_byte / 256;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; TPM1C1V = c;&lt;BR /&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Case 2:&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp; TPM1C1V = TPM1MODL * scratch_byte / 256;&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The compiler generated the following code to write to TPM1C1V.&lt;/P&gt;&lt;P&gt;Case 1:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp; STHX 0x29&amp;nbsp; ; OK&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Case 2:&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp; STA&amp;nbsp; 0x2A&amp;nbsp; ; Low byte first - OK for HCS08&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp; CLR&amp;nbsp; 0x29&amp;nbsp; ; High byte&lt;/FONT&gt;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In all the above cases, the expected result of the calculation was obtained.&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;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Apr 2009 05:38:33 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC68HC908JK1-Timer-Interface-Module-Problems/m-p/142816#M6422</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2009-04-21T05:38:33Z</dc:date>
    </item>
    <item>
      <title>Re: MC68HC908JK1  - Timer Interface Module Problems</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC68HC908JK1-Timer-Interface-Module-Problems/m-p/142817#M6423</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&lt;P&gt;&lt;FONT size="2"&gt;Hello Mac,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Thank you very much for your continued efforts - naturally I tried out your code and had a play around to see what happened. Case 2 was a match, but case 1 also did an STHX for "c" in a __SHORT_SEG (MOV X+,0x29 etc otherwise), but in any case TCH1 was written correctly.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;I eventually figured out why the code looked so different (the apparently non-optimised division (tired!) and the correct write-order): casting to a word optimised the division, and in case 1 the code worked as one would expect, however in case 2 the write-order problem came back.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;I guess this is a fairly unlikely scenario - if I'd chosen to code properly for either a 16-bit TMOD/TCH1 or an 8-bit one everything would have been fine.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;I've not yet done anything for HCS08 - I'm hoping to jump straight to its succesor!&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Thanks again,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Jim&lt;/FONT&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Apr 2009 18:19:51 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC68HC908JK1-Timer-Interface-Module-Problems/m-p/142817#M6423</guid>
      <dc:creator>JimB</dc:creator>
      <dc:date>2009-04-21T18:19:51Z</dc:date>
    </item>
  </channel>
</rss>

