View previous topic :: View next topic |
Author |
Message |
VINE (Guest) Guest
|
SPI |
Posted: Tue Sep 15, 2009 3:26 pm |
|
|
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
|
|
Posted: Tue Sep 15, 2009 3:34 pm |
|
|
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
|
|
Posted: Wed Sep 16, 2009 2:09 am |
|
|
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. |
|
|
|