- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Every one,
My questions looks confusing at start but its pretty straight forward explaining below.
I have an external DAC (DAC8563) which i want to set using spi communication. I want to send 24 bits from PSOC program via SPI Master to my dac chip.
But i dont have the possibility to send directly 24 bits. So i decided to do zero padding or adding don't care bits.
Now my bits looks like this : txdata = (c << 29) || (a << 26) || (x << 10); // 32 bit data input register.
txdata = xx0000001111111111111111xxxxxxxx
Now i want to split these bits into three 8 bits, so that i can directly write these bits.
I was thinking to split these bits into "txdada_hi, txdada_middle, txdada_lo ". But i dont know how i can do this.
I need help regarding this or any better solution is also welcome.
Looking forward for your suggestion.
Best Regards
Awais
Solved! Go to Solution.
- Labels:
-
PSoC 5LP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Well, something like
uint32 TxData;
uint8 A,C;
uint16 D;
TxData = (((uint32)A & 0x07) << 16) | ((uint32)C&0x07 << 19) | (uint32)D;
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
(c << 29) || (a << 26) || (x << 10); // 32 bit data input
|| is the logical OR, the binary OR you nneed is only one |
what are c, a and x in your above line?
To extract "txdada_hi " from a 32bit signed int "Data" use
txdada_hi = (uint8)((Data & 0x00ff0000) >> 16);
accordingly
txdada_med = (uint8)((Data & 0x0000ff00)>> 8);
and
txdata_Low = (uint8)(Data & 0x000000ff);
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thankyou Bob for your reply.
Here are these:
uint8 c = 0x000; // control values
uint8 a = 0x000; // address select (000- DAC-A)
uint16 data = 0xffff;// 16 bit Data (all 1s)
int32 txdata = 0;
Regards
Awais
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
uint8 a = 0x000; // address select (000- DAC-A)
That does not fit into an uint8
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ahan!
Then how should i put them?
Looking forward for your reply.
Regards
Awais
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
each hexadecimal digit occupies 4 bits, so uint8 c = 0x000; would mean to have a 12bit constant pressed into an 8bit variable.
Try to describe exactly how you want your 24bit to be built.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Well, something like
uint32 TxData;
uint8 A,C;
uint16 D;
TxData = (((uint32)A & 0x07) << 16) | ((uint32)C&0x07 << 19) | (uint32)D;
Bob