![]() | ![]() | ![]() |
| | |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
| | LinkBack | Thread Tools | Display Modes |
| | (permalink) |
| I have the master setup to transmit data to the slave using the 18f2420. My question is what is the process to get the received data out of the SSPBUF in the slave unit? Do i have to test for more that the SPIF to know when the data has been recieved. Code: i2Write: SSPCON2.0 =1 'initiate START condition gosub i2Wait 'wait for current operation to finish SSPBUF = i2cAddr 'send out slave address zero / all unit call gosub i2Wait 'wait for current operation to finish SSPBUF= rxChar 'write memory data gosub i2Wait 'wait for current operation to finish SSPCON2.2=1 'initiate STOP condition gosub i2Wait 'wait for current operation to finish return | |
| |
| | (permalink) |
| Oh yeah it's more complicated than that. You need to read some status bits- S, DA, RW, & BF- to determine the state of the response. But these do nicely frame your packet in the stream of bytes which in some ways makes it easier than the serial port. There is a notable absence of a well documented solution which includes handling of link errors. It's a bit tricky.
__________________ I thought what I'd do was I'd pretend I was one of those deaf-mutes. | |
| |