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

How can I write 16-bit in SPI with a PI24FJ?

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



Joined: 08 Feb 2011
Posts: 18

View user's profile Send private message

How can I write 16-bit in SPI with a PI24FJ?
PostPosted: Wed Feb 23, 2011 6:47 am     Reply with quote

I used a PIC24FJ128GA010 for my sensor project, I found that CCS compiler is able to set the SPI to 16-bit mode, however, spi_write command can only write 8-bit data, is there a way that I could get the PIC simply sending 16-bit data over the SPI without sending 8-bit data twice with SPI set to 8 bit mode?
Ttelmah



Joined: 11 Mar 2010
Posts: 19328

View user's profile Send private message

PostPosted: Wed Feb 23, 2011 8:06 am     Reply with quote

No.
This is all the CCS software does.

It is worth understanding that SPI, has a buffer register. There is the buffer, and the shift register. You can load a second byte into the buffer register, as soon as the first byte transfers to the shift register, so the two bytes are sent one after the other, just as if there was a 16bit write command.
However it doesn't matter even if there is a gap betwene bytes. The whole point about SPI, is that it includes a clock, so couldn't actually care if the data is sent one bit at a time, two bits at a time etc..

Best Wishes
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Wed Feb 23, 2011 8:09 am     Reply with quote

Quote:
is there a way that I could get the PIC simply sending 16-bit data over the SPI without sending 8-bit data twice with SPI set to 8 bit mode?

Yes, by writing to the PIC24 SFR registers directly. You have to handle the status bits yourself. But I don't however understand, what's your problem with sending two bytes with spi_write()?
geolover



Joined: 08 Feb 2011
Posts: 18

View user's profile Send private message

PostPosted: Fri Feb 25, 2011 8:56 am     Reply with quote

FvM wrote:
Quote:
is there a way that I could get the PIC simply sending 16-bit data over the SPI without sending 8-bit data twice with SPI set to 8 bit mode?

Yes, by writing to the PIC24 SFR registers directly. You have to handle the status bits yourself. But I don't however understand, what's your problem with sending two bytes with spi_write()?

Thank you!

I would like to write a 16-bit sine wave look-up table and interface it with a DA Converter to create a DDS module. Each sine wave sample is 16-bit, and I don't know how can I do it by writing 8-bit...
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Fri Feb 25, 2011 9:06 am     Reply with quote

e.g.
Code:
spi_write(make8(data16,1));
spi_write(make8(data16,0));
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