<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.arm.com/utility/feedstylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Debug Skipping Function with IF ELSE</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/36650/debug-skipping-function-with-if-else</link><description> Summary: Device TI MSC1210 
 
A user function called in main passes a pointer to an array and either a 1 or a 0. The function uses the 1/0 to decide which serial port to use. It then outputs data from the pointed array over serial N. 
 
I have tried</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: Debug Skipping Function with IF ELSE</title><link>https://community.arm.com/thread/122485?ContentTypeID=1</link><pubDate>Mon, 23 Aug 2004 09:13:21 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:d5490e73-94e7-4213-80be-6e9c9c7f8efd</guid><dc:creator>Jon Ward</dc:creator><description>&lt;p&gt;Can you please contact technical support about the code that was skipping the call so we can take a look at it and get this problem corrected?&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Jon&lt;/b&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Debug Skipping Function with IF ELSE</title><link>https://community.arm.com/thread/111037?ContentTypeID=1</link><pubDate>Mon, 23 Aug 2004 07:50:38 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:1f424e0d-70c6-43bb-a8da-a555d87029e7</guid><dc:creator>Dan Dutkosky</dc:creator><description>&lt;p&gt;Well, I got back to work this morning and started poking around through the compiler outputs.  Turns out it was indeed skipping the call.&lt;br /&gt;
&lt;br /&gt;
I changed the optimization settings, recompiled, and viola - function called properly.&lt;br /&gt;
&lt;br /&gt;
Thanks for the replies.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Debug Skipping Function with IF ELSE</title><link>https://community.arm.com/thread/96529?ContentTypeID=1</link><pubDate>Sun, 22 Aug 2004 13:48:37 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:75085152-a54b-410d-9f68-38c0e4c9c7d7</guid><dc:creator>Jon Ward</dc:creator><description>&lt;p&gt;Here&amp;#39;s the listing I get for your SerialXmit function:&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;
             ; FUNCTION _SerialXmit (BEGIN)
                                           ; SOURCE LINE # 3
;---- Variable &amp;#39;pArray&amp;#39; assigned to Register &amp;#39;R1/R2/R3&amp;#39; ----
                                           ; SOURCE LINE # 4
                                           ; SOURCE LINE # 5
0000 300004      R     JNB     n,?C0001
                                           ; SOURCE LINE # 6
                                           ; SOURCE LINE # 7
0003 7441              MOV     A,#041H
                                           ; SOURCE LINE # 10
0005 8005              SJMP    ?C0010
0007         ?C0001:
                                           ; SOURCE LINE # 11
0007 200005      R     JB      n,?C0004
                                           ; SOURCE LINE # 12
                                           ; SOURCE LINE # 13
000A 7442              MOV     A,#042H
000C         ?C0010:
000C 120000      E     LCALL   ?C?CSTPTR
                                           ; SOURCE LINE # 16
                                           ; SOURCE LINE # 17
000F         ?C0004:
000F 22                RET
             ; FUNCTION _SerialXmit (END)
&lt;/pre&gt;
&lt;br /&gt;
It looks fine to me.&lt;br /&gt;
&lt;br /&gt;
Actually, I had to modify your example to get it to compile:&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;   1          typedef unsigned char BYTE;
   2
   3          void SerialXmit(BYTE * pArray, bit n)
   4          {
   5   1      if(n == 1)
   6   1      {
   7   2      *pArray=&amp;#39;A&amp;#39;;
   8   2      //Use Serial Port 1
   9   2      // transmit pArray stuff
  10   2      }
  11   1      else if( n == 0)
  12   1      {
  13   2      *pArray=&amp;#39;B&amp;#39;;
  14   2      //Use Serial Port 0
  15   2      // transmit pArray stuff
  16   2      }
  17   1      }
&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;Jon&lt;/b&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Debug Skipping Function with IF ELSE</title><link>https://community.arm.com/thread/72681?ContentTypeID=1</link><pubDate>Sat, 21 Aug 2004 09:52:02 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:2af09fe6-8293-4b98-be15-5dc383c0cb4b</guid><dc:creator>Dan D</dc:creator><description>&lt;p&gt;code snippet showing the general idea:&lt;br /&gt;
&lt;br /&gt;
void SerialXmit(BYTE * pArray, bit n)&lt;br /&gt;
{&lt;br /&gt;
  if(n == 1)&lt;br /&gt;
  {&lt;br /&gt;
   //Use Serial Port 1&lt;br /&gt;
   // transmit pArray stuff&lt;br /&gt;
  }&lt;br /&gt;
  else if( n == 0)&lt;br /&gt;
  {&lt;br /&gt;
    //Use Serial Port 0&lt;br /&gt;
   // transmit pArray stuff&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void MAIN()&lt;br /&gt;
{&lt;br /&gt;
 //Initialization Stuff&lt;br /&gt;
 BYTE DataArray [4];&lt;br /&gt;
 BYTE * pArrayStart;&lt;br /&gt;
 pArrayStart = DataArray[0];&lt;br /&gt;
&lt;br /&gt;
while(1)&lt;br /&gt;
 {&lt;br /&gt;
   switch(opcode)&lt;br /&gt;
   {&lt;br /&gt;
   case opcode4:&lt;br /&gt;
      SerialXmit(pArrayStart,1);&lt;br /&gt;
   break;&lt;br /&gt;
  // rest of cases...&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
}&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Debug Skipping Function with IF ELSE</title><link>https://community.arm.com/thread/42653?ContentTypeID=1</link><pubDate>Sat, 21 Aug 2004 01:01:57 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:62a466d8-4710-4d3a-ac0a-673081ba8eed</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;i&gt;&amp;quot;Any ideas?&amp;quot;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
Not without seeing the code!&lt;br /&gt;
&lt;br /&gt;
HAve you tried looking at the generated code, and stepping it in the debugger to see where it actually goes &amp;quot;wrong&amp;quot;?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>