CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

SPI buffer size

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
theteaman



Joined: 04 Aug 2006
Posts: 98

View user's profile Send private message

SPI buffer size
PostPosted: Sun Oct 04, 2009 3:17 am     Reply with quote

Hi,

Sorry if this sounds stupid, but how many characters can the SPI buffer hold on an 18F series chip?

Reason is, I am trying to get two PICs to communicate via hardware SPI.

PIC1 calls spi_write() three times, sending three bytes. PIC2 slightly later on calls spi_read(0) three times, receiving three bytes. The problem is the three bytes received are always the same (they should be different)!! Indicating to me that perhaps the buffer size is one, and I need the process to be: write, read, write, read, write, read.... instead of write, write, write, read, read, read..

Can someone clear up this confusion for me?

Any help appreciated. Thanks.
bungee-



Joined: 27 Jun 2007
Posts: 206

View user's profile Send private message

PostPosted: Sun Oct 04, 2009 3:22 am     Reply with quote

SSPBUF is 8bits wide ... and that is all that this buffer have.

Post your code. It will be easier to help you. Wink
Ttelmah
Guest







PostPosted: Sun Oct 04, 2009 7:01 am     Reply with quote

There is the incoming shift register, and _one_ character buffer.
Effectively therre can be a maximum of 1.875 characters actually 'in' the chip, before data is lost. The chip can be receiving the next character, while the first is being retrieved, but as soon as the eighth clock arrives, the character in the shift register is transferred to the buffer, and if the first has not been read by then, SSPOV is set to show that an overrun has happened.
In your case, the first two characters will have been lost, and SSPOV will have been set.
This is where the SSP interrupt comes in. This triggers as soon as a character is complete in the shift register, and is transferred to the buffer.
Simply have this write the received character to a software buffer.

Best Wishes
Guest








PostPosted: Sun Oct 04, 2009 7:32 am     Reply with quote

Ttelmah wrote:
There is the incoming shift register, and _one_ character buffer.
Effectively therre can be a maximum of 1.875 characters actually 'in' the chip, before data is lost. The chip can be receiving the next character, while the first is being retrieved, but as soon as the eighth clock arrives, the character in the shift register is transferred to the buffer, and if the first has not been read by then, SSPOV is set to show that an overrun has happened.
In your case, the first two characters will have been lost, and SSPOV will have been set.
This is where the SSP interrupt comes in. This triggers as soon as a character is complete in the shift register, and is transferred to the buffer.
Simply have this write the received character to a software buffer.

Best Wishes


Makes sense, thanks Ttelmah. I'll work on int_ssp! Thanks!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group