Quote Originally Posted by HenrikOlsson View Post
Hi,
Instead of relying on software timing you can check the MSSP interrupt flag:
Code:
myByte VAR BYTE
SSPIF VAR PIR1.3

myByte = 123

SSPBUF = myByte                 ' Load byte to shiftregister buffer
SSPIF = 0                             ' Clear interrupt flag
WHILE SSPIF=0 : WEND        ' Wait for transmission to finish
This way you don't have to change any timing if you change the oscillator or if you change the MSSP module clock divisor etc.

Check the datasheet and make sure the SSPIF is at PIR1.3 for your device. (I think they try to keep it consistent but you never know)

/Henrik.
Hi Henrik,

You are correct. I did try the PIR1.3 flag, however i forgot to clear it before test it, and because of that it was not working like should be.
One problem with this approach is that it takes more memory.

One more thing, to test if the SSPBUF has received a byte, we should test the SSPSTAT.BF bit, like:

Code:
    DataIn = SSPBUF         'Data received from te MCP23S17
    SSPSTAT.0 = 0              
    WHILE SSPSTAT.0 : WEND
Now i need to change the code that i posted before this little improvement, but i can modify my posts!!!!

Thanks!!!