Hot answers tagged

12

Many ways. You can sort of bit bang the slave selects, i.e. connect all the devices with shared MISO/MOSI/SCLK and ground but separate CS. Just set CS low for the device you want before calling the SPI driver. The SPI driver will try to set an CS but won't know it is not connected. The Pis with the 40 pin expansion header have another SPI device with 3 ...


10

The preliminary Raspberry Pi 4 Model B datasheet, section "5.1.1 GPIO Pin Assignments" says: As well as being able to be used as straightforward software controlled input and output (with programmable pulls), GPIO pins can be switched (multiplexed) into various other modes backed by dedicated peripheral blocks such as I2C, UART and SPI. In ...


9

The Raspberry Pis with the 40 pin expansion header do expose the GPIOs needed for the Pi to act as a SPI slave (GPIOs 18, 19, 20, 21). See pages 102 and 160 SPI/BSC SLAVE BCM2835 ARM Peripherals. However there is NO usable driver available for the Pi to act in this mode and personally I would not hold my breath waiting for one to appear. See the latest ...


7

They are the SPI (Serial Peripheral Interface) interface pins. SPI is an interface bus used to exchange data between microntrollers and peripherals. It uses four pins MOSI which stands for master out slave in, MISO is Master in slave out, SS is slave select and a clock line (CLK). You can read more on the SPI protocol on wikipedia and from sparkfun


7

As you have noticed the default maximum SPI transfer is 4096 bytes with the standard Linux driver. To change the default add spidev.bufsiz=65536 to /boot/cmdline.txt and reboot. Where 65536 is the maximum size you want to allow. Note that /boot/cmdline.txt is a single line. After the above change mine looked like: dwc_otg.lpm_enable=0 console=tty1 root=/...


7

A SPI bus has usually the following signals SCLK, The clock signal, driven by the master CS, Chip select (CS) or slave select (SS), driven by the master, usually active-low and used to select the slave (since it is possible to connect multiple slave on the same bus). MOSI, Master Out Slave In, driven by the master, the data for the slave will appear on this ...


7

Any answer might only be of limited help to you as long as you have not understood how SPI actually works, so you should take a detailed look at this interface. Concerning question 1: SPI is a master-slave-system where any interaction has to be initiated by the master. The sensor itself is not able to write to the master, instead it is read by the master (...


6

Not impossible, but here are the obstacles to overcome: First, the SD card knows nothing about FAT, ext4fs, or any other file system. What it does is accept commands from the host interface and either store the data given to it, or retrieve data and send them back to the host. The filesystem interface is implemented at a higher layer. Whatever you create ...


6

It looks you don't know what "clock" means. A clock is something that synchronizes. Say you are supposed to arrive at work at 9 o'clock. When your boss' clock reaches 9 o'clock, he will check if you are absent and flag you as arriving late if so. When your clock reaches 9 o'clock, you check if you have arrived and bang your head against the wall if not. In ...


5

ALL the Pi GPIO are 3V3. NONE of them are tolerant of voltages outside the range 0 to 3.3V. EDITED TO ADD: The only pin which feeds into the Pi will be that connected to MISO (Master In Slave Out). The simplest thing to do is use a voltage divider on that line to cut the ADC 5V output to a Pi safe 3V3. A voltage divider is typically a pair of resistors. ...


5

The module spi-bcm2708 has been replaced with the updated kernel module spi-bcm2835. Generally you should no longer load modules with modprobe or by putting them in /etc/modules (there are exceptions). Recent kernels use a method called device tree. SPI is now enabled by adding the following line to /boot/config.txt dtparam=spi=on Note, the above is ...


5

Edit /boot/config.txt, add the following line, and reboot. dtoverlay=spi1-3cs You should then have the following devices. $ ls /dev/sp* /dev/spidev0.0 /dev/spidev0.1 /dev/spidev1.0 /dev/spidev1.1 /dev/spidev1.2 Then try the Python spidev module.


5

In addition to the other answer about the SPI protocol I notice that the product page you linked to shows that, as well as the SPI CS pin on GPIO 15 (BCM22), the ADS1256 ADC has a "Data Ready" pin connected to GPIO 11 (BCM17). You could monitor this and only fetch a new sample when the data is available rather than just reading the data back constantly --- ...


4

There are tradeoffs for each of the interfaces you mention: UART: setting up and reading/writing fron/to a UART port is fairly easy. However, UARTs typically cannot be driven at very high speeds and there could be issues with baud rate inaccuracies as well as insuring that the baud rate is the same on both sides. I2C: since the master drives the clock, ...


4

Error fixed. Thanks to @dastaan for spotting. My bad. I was using a 26 pin reference and hence was doing a wrong connection. I used this reference given below and it started working for me.


4

by scruss » Wed Feb 15, 2017 3:27 am They're under ‘5 Interfacing Options’ now. https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=174529


4

I doubt you can disable device tree anymore, that was intended to be a temporary directive to smooth the introduction of device tree. Just add the device tree SPI entry. Do not use gpio load spi. That is deprecated. As long as there /dev/spidev* entries you can use SPI. To summarise remove device_tree= from /boot/config.txt add dtparam=spi=on to /boot/...


4

According to Raspberry Pi Foundation: The SPI master driver is disabled by default on Raspbian. To enable it, use raspi-config, or ensure the line dtparam=spi=on isn't commented out in /boot/config.txt, and reboot. If the SPI driver was loaded, you should see the device /dev/spidev0.0. So, try to reboot your board after enabling SPI.


4

It was a stupid error on my side. SPI_IOC_MESSAGE ioctl call expects pointer to the first spi_ioc_transfer element in the argument. I passed a pointer to pointer instead, because I saw many samples passing &array there, and I’ve forgot about this. I’ve fixed my C++ code, and it works now. Meanwhile, cat /dev/spidev0.0 & command still prints ...


4

As far as I am aware you will need to bit bang the protocol yourself. This will mean that you will only be able to reliably support comparatively low clock rates. The Pi contains hardware to support SPI in a slave mode but it does not appear to work. This post on the raspberrypi.org forums documents my unsuccessful attempts to drive the hardware from ...


4

You have misunderstood the usage of the set and clear registers. If bit x is 1 in the set register then GPIO x is set high. If bit x is 0 then the level of GPIO x is not affected (i.e. if high it stays high, if low it stays low). If bit x is 1 in the clear register then GPIO x is set low. If bit x is 0 then the level of GPIO x is not affected (i.e. if ...


4

You can use raspi-config non-interactively to get the SPI status: sudo raspi-config nonint get_spi Which returns 0 (enabled) or 1 (disabled) Similarly, enable with: sudo raspi-config nonint do_spi 0


3

OMG. After staring at this for hours, I finally figured it out. Looks like in my haste of breaking apart my breadboard and recabling a more basic circuit I inadvertently removed the wires tying GND and 3.3VDC from one side of the board to the other. Thus, when I tested the ADC against GND and +3VDC, I was not connecting them to anything. So, in summary, ...


3

You are right that the RaspberryPi does provide only two chip selects at its SPI bus (see here). And I assume that the SPI drivers and software solutions rely on that fact (although @joan's answer suggests that different libraries handle it differently and the official driver will allow arbitrary GPIO pins to be used as chip selects in the future). You have ...


3

There is a project called Raspberry♯ (RaspberrySharp) At the site you find a sub project called raspberry-sharp-io which contians examples on how to use the SPI, I2C, GPIO and some other general purpose things. You can get the GPIO using Nuget Install-Package Raspberry.IO.GeneralPurpose but to use the SPI you will need to compile or add the ...


3

You are probably referring to an out of date web-site. I thought that raspi-blacklist.conf was deprecated and no longer used. I2C/SPI are not enabled by default because not many people use them. If they were enabled by default it might confuse users who wanted to use the I2C/SPI gpios as ordinary inputs/outputs. There is unlikely to be any power ...


3

RPi.GPIO (as far as I am aware) has no support for setting the clocks. You could access the raw clock device from Python using code similar to that shown at http://www.raspberrypi.org/forums/viewtopic.php?p=641670#p641670 I have an example standalone C program which sets the clock frequency "Minimal clock access" at http://abyz.me.uk/rpi/pigpio/examples....


3

The documentation is really vague about what a "block" is, but you might want to try sending your bytes using two separate calls: spi.xfer2([0x03], 500000, 9000) # leave CS asserted after first byte, 9 ms delay spi.xfer([0x00], 500000, 0) # transfer second byte, negate CS


3

You have misread the eLinux site. SPI on the Pi can manage a transmission bit rate of 32 Mbps, i.e. bits per second not samples per second. The "official" SPI driver tops out at about 20ktps (twenty thousand transactions per second). If you talk directly to the SPI hardware you can manage perhaps 100ksps for 12 bit samples. E.g. http://lb.raspberrypi.org/...


3

You could bit bang I2C on any spare gpios, so you could use the RTC on other gpios. However I expect you want the RTC module to automatically assign the time to the Pi when it is booted. To do that it must be connected to I2C bus 1 (gpios 2 and 3 on pins 3 and 5). I2C is a bus so more than one device may be connected at a time as long as there is no ...


Only top voted, non community-wiki answers of a minimum length are eligible