Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
01/08/08 09:44
Modified:
  01/08/08 09:50

Read: times


 
#149122 - Misleading comment
Responding to: ???'s previous message
Amira Nagi said:
...R_serial () interrupt 4
{
	if(RI)
	{
		 serialR = SBUF;
		 RI=0;
		 *PtrRx = serialR;
		 ++PtrRx;
	} /* wait for receive data */
	else
		TI = 0;
}

Is the comment, "wait for receive data" deliberately placed after the code to which it relates?

I know some people like to do this, but I think it's more common for comments to introduce the code that follows?
That is certainly my personal preference!

Anyhow, the code in the "if(RI)" clause does not wait for received data - it is called immediately as soon as the Receive Interrupt occurs.

So, my personal preference would be to have it as, say,
...R_serial () interrupt 4
{
   if(RI)
   {
     /* Handle received byte */
      serialR = SBUF;
      RI=0;
      *PtrRx = serialR;
      ++PtrRx;
   }
   else
   {
     /* Ignore Transmit interrupt */
      TI = 0;
   }
}

Note also that this forum does not cope (well) with TABs: you were lucky this time, but don't rely on it - use spaces intead to lay-out your code!
(any decent editor can be configured to insert spaces when you press the TAB button).


List of 26 messages in thread
TopicAuthorDate
Serial Problem            01/01/70 00:00      
   Can you post more information ?            01/01/70 00:00      
      more information            01/01/70 00:00      
         Too much information!            01/01/70 00:00      
         Some advice            01/01/70 00:00      
         while loop            01/01/70 00:00      
            Bad indenting trap!            01/01/70 00:00      
               Andu, Andy, how dare you ..            01/01/70 00:00      
            I don't think that's the problem.            01/01/70 00:00      
               you're right            01/01/70 00:00      
                  So, have you got it working yet?            01/01/70 00:00      
                     can't receive the 16 bytes            01/01/70 00:00      
                        Have you dealt with the atomicity issues ?            01/01/70 00:00      
                        Debugging            01/01/70 00:00      
                           details            01/01/70 00:00      
   Misleading comment            01/01/70 00:00      
      I too dislike the placement, even worse it is WRON            01/01/70 00:00      
   RI and TI are not mutually exclusive            01/01/70 00:00      
      ... but this is not a cause it will not work...            01/01/70 00:00      
         Yes...            01/01/70 00:00      
   Here is a sample code that is working ...            01/01/70 00:00      
      ... and here for the right processor            01/01/70 00:00      
         Wheel reinvention is -            01/01/70 00:00      
         I have a doubt about that KEIL code.            01/01/70 00:00      
            The Question is what do you want to loose?            01/01/70 00:00      
               No - I was just wondering the hardware            01/01/70 00:00      

Back to Subject List