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

SPI

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
VINE (Guest)
Guest







SPI
PostPosted: Tue Sep 15, 2009 3:26 pm     Reply with quote

I need help. How do I set a bit within a register?
Register 0x66, bit 0xD0, set to 1.
I'm using software SPI.
"SPI_XFER();" Using this function.
Thanks many.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Sep 15, 2009 3:34 pm     Reply with quote

If you want help with the SPI interface of a particular chip,
then post the chip's manufacturer and part number.

Also, post your PIC.

Post your compiler version.
Wayne_



Joined: 10 Oct 2007
Posts: 681

View user's profile Send private message

PostPosted: Wed Sep 16, 2009 2:09 am     Reply with quote

Generally you would read the register, make the change and then write it back.

As PCM Said, you need to give more info for the device as it may be a write only reg.

Also, Register 0x66, bit 0xD0, set to 1. 0xD0 = 0b11010000
That is 3 bits!
So
Code:

val = spi_xfer(0);  // you need to send reg number first but that depends on the device
val |= 0xD0;
spi_xfer(val); // you need to send reg number first but that depends on the device


If it is a write only reg then you would need to store the value locally in your code or read the info from other registers.
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