??? 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). |