/* Now the SSP handler code. Using my own, since the supplied routines test the wrong way round for my needs */
#DEFINE READ_SSP() (SSPBUF)
#DEFINE WAIT_FOR_SSP() while((SSPSTAT & 1)==0)
#DEFINE WRITE_SSP(x) SSPBUF=(x)
#DEFINE CLEAR_WCOL() SSPCON=SSPCON & 0x3F
A emulation of the spi_write function, would be:
WRITE_SSP(value);
WAIT_FOR_SSP();
However I wanted the two operations to be seperate, since I can then write a character, let the hardware 'get on' with doing the transfer, and only test that a transfer has completed when I next need to write, with:
WAIT_FOR_SSP(); //Test last transfer has completed
value=READ_SSP(); //retrieve last transfer if required
WRITE_SSP(new_value); //and start the next transfer.
Best Wishes
theteaman
Joined: 04 Aug 2006 Posts: 98
Posted: Wed Aug 30, 2006 8:35 am
Thank you very much ttelmah! I will use these macros and hopefully it all works!! (I was sure I saw this code of yours somewhere else on the forum but i couldnt remember how i found it witht the 'search' function).
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum