How To split 32 Bits into three 8 bits or two 16 bits, inorder to transfer 24 bits via SPI Master? | Cypress Semiconductor
How To split 32 Bits into three 8 bits or two 16 bits, inorder to transfer 24 bits via SPI Master?
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.