Rehan

Rehan

SPI not working on beaglebone

Hi all,

I’m running Nerves on a BeagleBone Black and trying to use SPI from Circuits.SPI.

I can see the devices in /dev:

/dev/spidev0.0
/dev/spidev0.1
/dev/spidev1.0
/dev/spidev1.1

But I’m having trouble confirming which header pins (P9/P8) are actually mapped to these devices under Nerves.

Questions:

  1. What is the correct mapping between /dev/spidev0.0 and BeagleBone header pins when using Nerves?
  2. How can I verify from the Nerves IEx console (using only File.read!, /proc/device-tree, or /sys/devices) that a given pin is really configured for SPI mode?
  3. Is there a recommended way to enable or switch pinmux for SPI pins under Nerves since config-pin is not available?

So far, I’ve opened SPI in IEx like this:

iex(1)> {:ok, ref}=Circuits.SPI.open("spidev0.0", speed_hz: 1_000_000, mode: 3)
{:ok, #Reference<0.2697461337.148504581.45500>}                                                                          
iex(2)> Circuits.SPI.transfer(ref, <<0x80, 0x00>>)
{:ok, <<0, 0>>}  

I’m not getting any response from the SPI slave. I’m using ADXL345 sensor expecting 0xE5 for above read operation

Example wiring to ADXL345 (3.3V SPI sensor)

  • P9_17 (CS0)** → **ADXL345 CS
  • P9_22 (SCLK)** → **ADXL345 SCL
  • P9_18 (MOSI)** → **ADXL345 SDA (data in)
  • P9_21 (MISO)** → **ADXL345 SDO (data out)

Am I Connecting to correct pins? Or pin mapping is different for spidev0.0

Thanks in advance.

Where Next?

Popular in Questions Top

Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set? Thanks.
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
LegitStack
I’m trying to make a websocket server in Phoenix or raw Elixir. I heard about gun, I think I could use cowboy, but since I’m not that sma...
New
johnnyicon
Hi all, I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I'm trying to use Postg...
New
hpopp
To simplify some tasks at work, I wrote and published this package yesterday. It’s a simple macro that enables Access behaviour on struct...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New

Other popular topics Top

sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
977 41022 311
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 35421 110
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list....
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers' Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New

We're in Beta

About us Mission Statement