Reply by Oliver Betz January 24, 20142014-01-24
Arlet Ottens wrote:

>> Some of us prefer to write a COMMENT, such as >> // read SCISR1 to clear framoufoob bit, and discard the result >> >> Aarrrggggg..... >> > >No need to comment the obvious intention of the code. It's clear that >the code is reading SCISR1, and that the result is discarded. So the >comment can be: > >(void) SCISR1; // clear framoufoob bit
IMO it's useful information that framoufoob bit is cleared by reading the register. So, nitpicking, the comment should be "reading SCISR1 clears framoufoob". Oliver -- Oliver Betz, Munich despammed.com is broken, use Reply-To:
Reply by Arlet Ottens January 23, 20142014-01-23
On 01/22/2014 10:08 PM, Dave Nadler wrote:
> On Tuesday, January 21, 2014 1:25:07 PM UTC-5, Arlet wrote: >> I prefer to write >> (void) SCISR1; >> in cases like this, to make explicit that the result is discarded. > > Some of us prefer to write a COMMENT, such as > // read SCISR1 to clear framoufoob bit, and discard the result > > Aarrrggggg..... >
No need to comment the obvious intention of the code. It's clear that the code is reading SCISR1, and that the result is discarded. So the comment can be: (void) SCISR1; // clear framoufoob bit Or even: clear_framoufoob_bit( );
Reply by Dave Nadler January 22, 20142014-01-22
On Tuesday, January 21, 2014 1:25:07 PM UTC-5, Arlet wrote:
> I prefer to write > (void) SCISR1; > in cases like this, to make explicit that the result is discarded.
Some of us prefer to write a COMMENT, such as // read SCISR1 to clear framoufoob bit, and discard the result Aarrrggggg.....
Reply by Arlet Ottens January 21, 20142014-01-21
On 01/21/2014 01:34 PM, Bruce Varley wrote:
> Copiedt following straight out of a Freescale application note. The second > doesn't look familuar. Is this a standard C construct, and likely to be > accepted by most IDEs? Does it just mean read SCISR1 and discard the result? > > if (SCISR1 & 0x80){ > SCISR1; > if(*(SCIStringp++) != '\0'){ > if(*SCIStringp > 0xD){ /*Avoid to change CR and LF > characters*/ > SCIDRL=*SCIStringp + Stringcase; > } > else{ > SCIDRL=*SCIStringp; > >
I prefer to write (void) SCISR1; in cases like this, to make explicit that the result is discarded.
Reply by Wouter van Ooijen January 21, 20142014-01-21
Bruce Varley schreef op 21-Jan-14 1:34 PM:
> Copiedt following straight out of a Freescale application note. The second > doesn't look familuar. Is this a standard C construct, and likely to be > accepted by most IDEs? Does it just mean read SCISR1 and discard the result? > > if (SCISR1 & 0x80){ > SCISR1; > if(*(SCIStringp++) != '\0'){ > if(*SCIStringp > 0xD){ /*Avoid to change CR and LF > characters*/ > SCIDRL=*SCIStringp + Stringcase; > } > else{ > SCIDRL=*SCIStringp; > >
My guess is that SCISR1 is a macro for some register, something like #define SCISR1 (*((volatile unsigned int *) 0x327F )) that line with only SCISR1; would read the register a second time (the condition read it a first time). Maybe this is needed to clear the register or achieve some other side-effect. Check the documentation :) Wouter van Ooijen
Reply by Boudewijn Dijkstra January 21, 20142014-01-21
Op Tue, 21 Jan 2014 13:34:40 +0100 schreef Bruce Varley <bv@nospam.com>:
> Copiedt following straight out of a Freescale application note. The > second [line] > doesn't look familuar. Is this a standard C construct, and likely to be > accepted by most IDEs? Does it just mean read SCISR1 and discard the > result? > > if (SCISR1 & 0x80){ > SCISR1; > if(*(SCIStringp++) != '\0'){ > if(*SCIStringp > 0xD){ /*Avoid to change CR and LF > characters*/ > SCIDRL=*SCIStringp + Stringcase; > } > else{ > SCIDRL=*SCIStringp;
If I read the C standard (n1570) right, then the expression is an lvalue of type void (implicitly) and shall be evaluated for its side effects. Accessing a volatile object is a side effect. -- (Remove the obvious prefix to reply privately.) Gemaakt met Opera's e-mailprogramma: http://www.opera.com/mail/
Reply by Bruce Varley January 21, 20142014-01-21
Copiedt following straight out of a Freescale application note. The second 
doesn't look familuar. Is this a standard C construct, and likely to be 
accepted by most IDEs? Does it just mean read SCISR1 and discard the result?

 if (SCISR1 & 0x80){
        SCISR1;
        if(*(SCIStringp++) != '\0'){
            if(*SCIStringp > 0xD){     /*Avoid to change CR and LF 
characters*/
                SCIDRL=*SCIStringp + Stringcase;
            }
            else{
                SCIDRL=*SCIStringp;