Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

( ( SSPCON2 & 0x1F ) || ( SSPSTAT & 0x04 ) );

Status
Not open for further replies.

PA3040

Advanced Member level 3
Joined
Aug 1, 2011
Messages
883
Helped
43
Reputation
88
Reaction score
43
Trophy points
1,308
Activity points
6,936
void I2CWait()
{
while ( ( SSPCON2 & 0x1F ) || ( SSPSTAT & 0x04 ) ); /* wait for any pending transfer */
}


Dear All
Kindly please explain everything about below code

( ( SSPCON2 & 0x1F ) || ( SSPSTAT & 0x04 ) );

This is related to PIC16f877a I2C Peripheral


Thanks in advance
 

This function has a null while loop.
The loop repeats while any of the five low bits of SSPCON2 is 1 or bit 2 of SSPSTAT is 1.
In other words: It waits until all the five low bits of SSPCON2 register are 0 and bit 2 of SSPSTAT is 0.
Regards

Z
 
  • Like
Reactions: PA3040

    PA3040

    Points: 2
    Helpful Answer Positive Rating
refer datasheet about I2C tranfer .
" SSPCON and SSPSTAT are the control and status
registers in SPI mode operation.The SSPCON register
is readable and writable. The lower six bits of the
SSPSTAT are read-only. The upper two bits of the
SSPSTAT are read/write.
SSPSR is the shift register used for shifting data in or
out. SSPBUF is the buffer register to which data bytes
are written to or read from.
In receive operations, SSPSR and SSPBUF together
create a double-buffered receiver. When SSPSR
receives a complete byte, it is transferred to SSPBUF
and the SSPIF interrupt is set.
During transmission, the SSPBUF is not doublebuffered.
A write to SSPBUF will write to both SSPBUF
and SSPSR."

the operator "||" is byte wise or.
and
0x1F = 0001 1111
starting from 1st ";0" => its in slave mode
well for the ext things.. refer datasheet! there's plenty of info..
so its checking for
 
  • Like
Reactions: PA3040

    PA3040

    Points: 2
    Helpful Answer Positive Rating
Dear Magvitron,
Thank you so much for reply
You explained it the way any body can understand,
Really thanks
 

Dear All
Can any one please explain the everything related the attached image
This is related to the PIC16f877a i2c operation
Thanks in advance
i2c.JPG
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top