|
|
View previous topic :: View next topic |
Author |
Message |
theteaman
Joined: 04 Aug 2006 Posts: 98
|
SPI buffer size |
Posted: Sun Oct 04, 2009 3:17 am |
|
|
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
|
|
Posted: Sun Oct 04, 2009 3:22 am |
|
|
SSPBUF is 8bits wide ... and that is all that this buffer have.
Post your code. It will be easier to help you. |
|
|
Ttelmah Guest
|
|
Posted: Sun Oct 04, 2009 7:01 am |
|
|
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
|
|
Posted: Sun Oct 04, 2009 7:32 am |
|
|
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! |
|
|
|
|
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
|