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 CCS Technical Support

Queue up SPI TX in Slave Mode

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



Joined: 21 Dec 2005
Posts: 25

View user's profile Send private message

Queue up SPI TX in Slave Mode
PostPosted: Thu Sep 06, 2012 2:00 pm     Reply with quote

I am working on implementing the SPI Slave using a PIC24FV32KA304 on PCWHD 4.134.

What I need to be able to do is queue up two bytes to transmit once the master starts to clock it in.

Code:

#use SPI (FORCE_HW, SPI1, STREAM=HOST, BITS=8, SLAVE, SAMPLE_RISE,IDLE=1)

...

      whichChannel = spi_xfer(HOST,0x11,8);
      whichChannel = spi_xfer(HOST,0x08,8);   


For the above code when I queue both of these up and then the master clocks in 16 clocks, instead of getting a 0x11 and 0x08 I get two copies of the 0x08 byte. How do I queue up these bytes correctly so that I get both once the master starts clocking in the data.

Thanks!
Ttelmah



Joined: 11 Mar 2010
Posts: 19499

View user's profile Send private message

PostPosted: Fri Sep 07, 2012 1:03 am     Reply with quote

Exactly as you would for the RS232.
You implement a software circular buffer, and use int_ssp, to load the next byte from this to the hardware.

Best Wishes
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