Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

UINT8 access/change bits SPI

Status
Not open for further replies.

nabla101

Junior Member level 3
Joined
Feb 8, 2011
Messages
30
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,600
HI, I'm using SPI of PIC18F46K80, and I want to write a function to feed it a 6-bit address, and a read/write bit. If I have the address as a UINT8 type, then how can I change the bits of the UINT8 to construct an 8-bit packet (Another UINT8) with the MSB bit set to '0', followed by the 6-bit adress (stored in the 8-bit UINT8) - bits 6-1, followed by the R/W bit (bit 0 - LSB)?

Alternatively, is there a 6-bit variable I can use to store the address (UINT6), and then append the other two bits onto the front/back of this variable to make a UINT8? If not, then can I create such a UINT6 variable myself?....this would be better, since I want to do the same thing with a 10-bit address (Making a 12 bit packet that is transmitted as two address bytes, with the last 4 bits irrelevant).

Thanks


p.s. OK, Its been a while since I've programmed, but just remembered I can use bitwise operators to do this..... still how can I create 6-bit and 10-bit variables? - this way I can avoid addresses that are too large being sent to the function in the first place.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top