Hello everybody,
As stated in the title, I'm trying to use a the hard-SPI interface SPI0. I'm using the SPI bus to sample some devices and I need an SPI frequency greater than 500 kHz, which is why I need to use a hardware SPI. Here is the version I'm using :
Image:
v0.3.8h, 5 January 2023
Core code:
Last updated on '29 Aug 2025 16:37:39 '
from file '/root/Bela/updates/Bela-master.zip'
via 'make update'
Update was successful
Git desc: 'e43b8abe-dirty'
After navigating through some posts related to SPI on this forum, I understand now that the SPI0 interface/pins are already in use to communicate with the ADC for analog inputs. I don't need these in my project so I assume I can safely disable them as stated here or here.
I'm not very familiar with Linux kernel and I'm having trouble finding how to disable the analog inputs properly, or what flags are being referred to in the second link.
Using the IDE switch button for "Use Analog" and disabling it, it appears I managed to disable the analog inputs (I checked by printing BelaContext values). I then modified the SPI communication example (that is used for Bela Mini) and changed the struct use for setup by this :
spiDevice.setup({
.device = "/dev/spidev3.0", // Device to open
.speed = 500000, // Clock speed in Hz
.delay = 0, // Delay after last transfer before deselecting the device
.numBits = 8, // No. of bits per transaction word
.mode = Spi::MODE1 // Spi mode
});
I modified the device field according to bela_hw_settings.h and the mode field to suit my device.
However I have the following issue when trying to run the example code :
PRU interrupt timeout, -1 110 Connection timed out
McASP error, abort
So here are my questions :
- 1) How do you properly disable analog inputs only ? Which flags is @giuliomoro talking about ?
- 2) What is causing PRU interrupts to timeout (I guess this is related to McASP failing) ?
- 3) I know that PRU can be programmed to run a soft-SPI at 8Mhz according to the reply below. I might also give this method a try. Regarding the GPIO, I guess I should use the available I/Os described here ?
giuliomoro If you need higher bandwidth you could also use the other PRU to "bitbang" one of the PRU's GPIOs. I got this to work at 8MHz here.