#include <errno.h>
. . .
int status = ioctl(fd, SPI_IOC_MESSAGE(1), &transfer);
if(status == -1)
/* Google the error messege - Pay close attention to
stackoverflow.com posts */
printf("error: %s\n", strerror(errno));
. . .
On Tue, Sep 29, 2015 at 5:25 PM, Larry M <[email protected]> wrote:
> I'm looking for help from someone much more knowledgeable than me, or my
> BBB is likely to go flying out the window!
>
> I am running Debian Jessie 8.2
> (BBB-eMMC-flasher-debian-8.2-lxqt-4gb-armhf-2015-09-20-4gb) on a BBB Rev C,
> with Kernel 4.0.8 PREEMPT RT.
>
> I have spidev1.0 enabled, currently connected with an SPI device (a MS5611
> barometer, if curious). In running my code, sometimes my SPI command goes
> out, sometimes nothing goes out (all channels are flat-lined). I would say
> only about 1/3 of the commands actually go out. It is very repeatable
> (exactly the same behavior every time the code runs), and depends on what I
> compile in my code (e.g., if I add a printf statement, different SPI
> commands will fail).
>
> Here is an example from a logic analyzer. SPI is in mode 3, command is
> 0xA2, exactly what I wanted to see. I slowed the clock down to 100 kHz
> even though the barometer is capable of 20 MHz, just to make sure the
> timing wasn't too fast for the BBB. (Note: the reply is supposed to be 2
> bytes, but clock stops after 1 byte, so clearly I need to figure out what
> is going on there. However, at least the right command is going out the
> door.)
>
>
> <https://lh3.googleusercontent.com/-h-Node0Hp1I/VgsoHAnbh2I/AAAAAAAAAGM/bvCFP6Sq9To/s1600/Capture1.PNG>
> <https://lh3.googleusercontent.com/-h-Node0Hp1I/VgsoHAnbh2I/AAAAAAAAAGM/bvCFP6Sq9To/s1600/Capture1.PNG>
>
>
> When it doesn't work, the ioctl command returns -1 and the logic analyzer
> shows that all of the signals are flatline. Not even the clock or CS
> lines! This is what happens at least 2 out of 3 times, maybe more.
>
> Here is a snippet from the code, in case someone spots an error. In this
> case, Tx would have been 0xA2, and length would be 2.
>
> transfer.tx_buf = (unsigned long) send; //the buffer for sending
> data
> transfer.rx_buf = (unsigned long) receive; //the buffer for receiving
> data
> transfer.len = length; //the length of buffer
> transfer.speed_hz = 100000; //the speed in Hz
> transfer.bits_per_word = 8; //bits per word
> transfer.delay_usecs = 0; //delay in us
>
> // send the SPI message (all of the above fields, inc. buffers)
> int status = ioctl(fd, SPI_IOC_MESSAGE(1), &transfer);
>
>
>
> So.... HELP!! Does anyone have a reasonable idea on what might be
> happening, or how I can fix it? I've wasted more than 24 solid hours
> trying to debug this, to no avail. I'm counting on you experts out there...
>
> Thanks (in advance)!!
> Larry
>
> --
> For more options, visit http://beagleboard.org/discuss
> ---
> You received this message because you are subscribed to the Google Groups
> "BeagleBoard" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>
--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.