<?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: Trouble with delay in Classic/Legacy CodeWarrior</title>
    <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Trouble-with-delay/m-p/211611#M5950</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Okay, I figured out that when putting "EnableInterrupts﻿" right before my call to delay_ms(), it works.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, this means something is disabling my interrupts after I've enabled them in my initialization routine. I can't find where though. Any ideas on what to look for?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 03 Jun 2011 22:11:04 GMT</pubDate>
    <dc:creator>ignisuti</dc:creator>
    <dc:date>2011-06-03T22:11:04Z</dc:date>
    <item>
      <title>Trouble with delay</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Trouble-with-delay/m-p/211610#M5949</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm using the True-Time Simulator &amp;amp; Real Time Debugger Ver. 6.1 Build 9279.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For some reason, my code keeps breaking in this function on the while loop.&lt;/P&gt;&lt;PRE&gt;void delay_ms(unsigned short time){&amp;nbsp;&amp;nbsp; //max delay time should be 65.535 seconds&amp;nbsp;&amp;nbsp;&amp;nbsp; unsigned long count;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //enable_timer2_interrupt();&amp;nbsp;&amp;nbsp;&amp;nbsp; t2Count = 0;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set_timer_delay(&amp;amp;count);&amp;nbsp;&amp;nbsp;&amp;nbsp; while(!timer_expired_delay(count, time)){;}&amp;nbsp;&amp;nbsp;&amp;nbsp; //if(startTCPIPflash==FALSE)&amp;nbsp;&amp;nbsp;&amp;nbsp; //&amp;nbsp;&amp;nbsp;&amp;nbsp; DISABLE_INT_TIMER2;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/PRE&gt;&lt;P&gt;Please help me figure out what to look for to fix this problem.&lt;/P&gt;&lt;P&gt;It's odd because it works immediatly after initialization, but then a short while later, my 1ms timer interrupts and trys to write data to an LCD. That function calls this delay_ms() function and fails.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Jun 2011 04:18:19 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Trouble-with-delay/m-p/211610#M5949</guid>
      <dc:creator>ignisuti</dc:creator>
      <dc:date>2011-06-03T04:18:19Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble with delay</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Trouble-with-delay/m-p/211611#M5950</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Okay, I figured out that when putting "EnableInterrupts﻿" right before my call to delay_ms(), it works.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, this means something is disabling my interrupts after I've enabled them in my initialization routine. I can't find where though. Any ideas on what to look for?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Jun 2011 22:11:04 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Trouble-with-delay/m-p/211611#M5950</guid>
      <dc:creator>ignisuti</dc:creator>
      <dc:date>2011-06-03T22:11:04Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble with delay</title>
      <link>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Trouble-with-delay/m-p/211612#M5951</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Okay, I think I'm getting closer. I believe my timer_1_interrupt function is disabling interrupts. Is this normal? Or did the compiler tell it to do this because I'm calling a function in the interrupt that is also called outside the interrupt?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My whole problem occurs when MAIN_service_routine() trys to call delay_ms() which relies on this interrupt (see below). Simply adding "EnableInterrupts;" before my call to&amp;nbsp;MAIN_service_routine() fixes the problem. However, I'd like to understand why this is needed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;/* =================================================================================================  FUNCTION DESCRIPTION:==      Interrupt - Hardware Timer 1 - Configured to trigger every 1ms.==          Triggers all Service Routines.====  OUTPUTS:==      N/A== =============================================================================================*/__interrupt void timer_1_interrupt(void)    {    /* Local Variables. */    static BLN service_routine_active = FALSE;    DEBUG_checkpoint( CP_ENTER_timer_1_interrupt ); //Mark Checkpoint.    RESET_TIMER1;                           //Reset timer (allow this interrupt to occur again).        t1Count++;                              //Update ms counter used for software timers.        /* Check if Service Routine already processing (prevent undesired recursion). */    if( service_routine_active == FALSE )        {                service_routine_active = TRUE;      //Mark service routine active.                      MAIN_service_routine();             //Call Main Service Routine.                service_routine_active = FALSE;     //Mark service routine inactive.        }                                           DEBUG_checkpoint( CP_EXIT_timer_1_interrupt ); //Mark Checkpoint.            } /* timer_1_interrupt() */&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 04 Jun 2011 01:27:12 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Classic-Legacy-CodeWarrior/Trouble-with-delay/m-p/211612#M5951</guid>
      <dc:creator>ignisuti</dc:creator>
      <dc:date>2011-06-04T01:27:12Z</dc:date>
    </item>
  </channel>
</rss>

