SPI 12-bit, sending data #15888
Replies: 3 comments
-
What hardware are you driving? The only chips I'm aware of that do 12-bit transfers are display drivers. In this case you are normally sending a whole buffer full of data; you can pack the 12-bit pixels into bytearrays and use normal transfers. Then every pair of pixels occupies three bytes. You may enjoy the challenge of figuring out how to code this. Otherwise give us more details of your setup and I'm sure we can help. |
Beta Was this translation helpful? Give feedback.
-
Ah, you're totally right - it's sent/received in larger, 8-aligned groups,
but parsed in 12s. Seems relatively straightforward to implement (or
certainly moreso than trying to make python parse nibbles)... Thanks for
your help!
…On Sat., Sep. 21, 2024, 03:57 Peter Hinch, ***@***.***> wrote:
What hardware are you driving? The only chips I'm aware of that do 12-bit
transfers are display drivers. In this case you are normally sending a
whole buffer full of data; you can pack the 12-bit pixels into bytearrays
and use normal transfers. Then every pair of pixels occupies three bytes.
You may enjoy the challenge of figuring out how to code this. Otherwise
give us more details of your setup and I'm sure we can help.
—
Reply to this email directly, view it on GitHub
<#15888 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AHIX6AVVQSGR2CTIB6GSJK3ZXURIJAVCNFSM6AAAAABOS6FFJ2VHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTANZRGE2TINA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
-
Since a byte is 8 bits, 12 bits can be split into: |
Beta Was this translation helpful? Give feedback.
-
Hello,
As the title says, I've configured my Raspberry Pi Pico's SPI bus for 12-bit interactions through
init
. This is fine - I haven't yet checked if my pico can natively support this, but right now I'm only really concerned about the code... How, in Python, can I send 12 bits, when the argument towrite
must be a bytearray? I couldn't find anything on the docs about this.The first idea that came to mind was that, perhaps it was just that two bytes need to be provided to the function... But then I questioned which order the 12 bits would be read in. With some fiddling, I can certainly figure it out if this is the case, but I'm no Python pro and this seems to be a hole in the documentation, so I figure I'll ask. If I find an answer myself, I'll document here for future use.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions