HCSO8 Skipping over important code for no reason

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

HCSO8 Skipping over important code for no reason

2,358 次查看
mjcoury
Contributor I
So I have a routine here to catch the start of a RS232 stream....

Code:
  #ifdef USB_LOGGER  if(cSCI1rxFlag)                   // Rx Flag  {                        if( !(cSystemFlag & GWF_SCIDP) )            // If device not present    {      USBFileOpen("test.txt");                  // Open File      cSystemFlag |= GWF_SCIDP;                 // Set Device Present    }    if( !(cSystemFlag & GWF_SCIRX) )            // If we are not admist a burst    {      iUSBSendCommand(MC_e,NULL);      cSystemFlag |= GWF_SCIRX;                 // Set that we are in a burst    }    cSCI1rxFlag = 0;                            // Clear the Rx Flag    }

 
the Routine iUSBSendCommand(MC_e,NULL); gets skipped.... its output does not show up on the logic analyzer and when I step through it in processor expert, skips over that line like it does not exist.

I know that the code is inside that if routine AND that the routine works because in a 1 second loop I put


Code:
   if(cSystemFlag & GWF_SCIRX)            // If we are not admist a burst    {      iUSBSendCommand(MC_e,NULL);    }

 
And the code works as expected, I have killed almost the whole day on this :smileysad: WTF?
标签 (1)
0 项奖励
回复
3 回复数

954 次查看
bigmac
Specialist III
Hello,
 
I wonder if the GWF_SCIRX bit within cSystemFlag is already set when you reach that section of the code.  Following execution of the function the flag bit becomes set, and this would prevent further execution until the flag was cleared.
 
Regards,
Mac
 
0 项奖励
回复

954 次查看
Witztronics
Contributor IV
You need to verify that this code is not being stripped out by the compiler due to it not being used.
 
I've had routines that I thought should be there, but the compiler removed them because that section of code would always be skipped due to code errors.  It still shows up in the debugger, but gets skipped because it doesn't really exits in the executed code.
 
0 项奖励
回复

954 次查看
CompilerGuru
NXP Employee
NXP Employee
I would recommend to have a look to the preprocessor output and to the disassembly listing at that code position.
Those two listings can be created with the context menu in the CW ide, I always check them first when I see some unexpected behavior.
With the current information the problem could be just about anywhere, so really not enough information. The code looks basically ok, but as it is only a non complete code snippet, there are many reasons why it would not work as expected.

Daniel
0 项奖励
回复