SPI Bit Order

111 views
Skip to first unread message

ricard...@gmail.com

unread,
Feb 16, 2017, 2:10:19 PM2/16/17
to Pi4J
Hello,

I am using a Pi hat on my board that comes with some nice c code in which they use SPI to talk to a DAC and change the power going to some LEDs on the board. I would like to convert it to java.

I'm running into the problem of my general setup. The SPI example does not show how to set bit order, which I suspect might be my problem. How would I do this?

Pi4J SPI Example:

Any help would be appreciated.

Robert Savage

unread,
Feb 21, 2017, 9:02:58 AM2/21/17
to Pi4J
Hi Ricardo,

Pi4J SPI is built on top of the WiringPi C library and unfortunately I don't see any method to control the bit order in WiringPi.  

I also was reading in the forums that some some users have stated that the RPI did not support changing the bit order in the hardware.  That information may have been old or may have only applied to SPI0, I'm not really sure.

Can you point me to C code example you are referring to?  I'm curious if they are using bit-banging in code to pull this offer or which library they may be using to communication SPI on the Pi.

Thanks, Robert

ricard...@gmail.com

unread,
Feb 27, 2017, 11:04:36 AM2/27/17
to Pi4J
Hi Robert,

Thanks for the quick reply. I'm trying to use a High-Precision AD/DA Board found here: http://www.waveshare.com/wiki/High-Precision_AD/DA_Board

My true goal is to convert their sample code (http://www.waveshare.com/wiki/File:High-Precision-AD-DA-Board-Code.7z) into java code. In C, i was able to combine both programs (ads1256_test.c and dac8532_test.c) to control the LED with their onboard potentiometer.

Any thoughts would be appreciated. 

Thank you,
Ricardo

ricard...@gmail.com

unread,
Mar 3, 2017, 7:46:13 AM3/3/17
to Pi4J
Hi Robert,

I bet you're right. I made a mistake on my setup, and it seems to have worked out. I assume bit order doesn't need to be set.

Thanks,
Ricardo
Reply all
Reply to author
Forward
0 new messages