Comments (1)
According to: https://projects.drogon.net/understanding-spi-on-the-raspberry-pi/
An important aspect of SPI is that the clock can (usually) be driven at varying speeds – the dependence is usually on the peripheral device being driven. E.g. the analog to digital converter on the Gertboard must be driven at a speed between 1MHz and 3MHz – however the upper limit is the voltage it’s supplied with (3MHz max. at 5v), so it’s important to know in-advance what limitations of the devices you are talking to.
To experiment with timings, I wrote a little test program to see the effects of the different speeds – starting at 0.5Mb/sec going up to 62Mb/sec. I simply looped the MOSI and MISO pins together and checked that the data received was the same as the data sent.
The first thing I found was that the Pi stops sending at clock speeds over 62Mb/sec., and that in-reality 32Mbs is the upper limit of the SPI clock.
Next, I noticed that for some clock speeds, the data rate doesn’t change – this is due to the rounding issues when calculating the clock divider value. What I have observed is that the speeds available are:
0.5 MHz
1 MHz
2 MHz
4 MHz
8 MHz
16 MHz and
32 MHz.You can see the progression, it’s powers of 2, and this reflects the clock divider values too.
The important thing to realise is that if you are clocking a part designed for a SPI clock rate of 25MHz, then setting the clock to 25MHz will really create a clock of 16MHz. There is no way to get an exact 25MHz clock speed. This probably isn’t important, and the reality of trying to send a 25MHz signal down a pair of wires or along a PCB track is that it’s highly likely to not work unless you take good care with the signal routing, shielding and so on.
Another observation was that the overheads in the Linux kernel increase with clock speed and the data throughput doesn’t quite increase linearly with clock speed. So with a clock at 1MHz we get a throughput of 0.108 MB/sec, at 2MHz it’s 0.214 MB/sec and it more or less doubles up to 16MHz (1.55MB/sec) but at 32Mb/sec clock, it’s barely 2.2MB/sec when you might expect it to be closer to 3MB/sec.
Finally, it’s worth while noting that the actual latency of calling the wiringPiSPIDataRW() function is rather high – an example I tested was sending 2 bytes at a time to the Gertboards digital to analog converter and rather than the 50,000 updates/sec I was expecting I was seeing barely half that, and a few experiments shows that it wasn’t that tied to the SPI clock frequency either.
from luma.core.
Related Issues (20)
- add test for SPI cs_high warning
- Reduce the build jobs on Travis ... or use Github Actions HOT 6
- Possible to use diff-algorithm with linux_framebuffer device? HOT 8
- Add docs for last luma.core that supports Python 2.7
- luma.core.device.device is missing in api documentation HOT 1
- Supporting 32-bit depth for linux_framebuffer HOT 2
- Use github actions to publish to pypi HOT 5
- Configure setup() using setup.cfg file
- IndexError: Font does not have ASCII code: 8211 (or 8212,8217,8220,8221) HOT 2
- VFD support in Luma HOT 9
- Crash @ Raspi3 install with "syntax error" ... already tried with Python 3.8.4 HOT 5
- Support for Orange Pi GPIO module HOT 4
- How do proper cleanup/release resources when using luma.core?
- Unnecessary delete statement in function (identified with LGTM.com) HOT 3
- remove deprecated cmdline.make_serial
- ftdi_spi doesn't appear to support chips with more than 8 GPIO's HOT 8
- Drop support for Python 3.6 HOT 1
- namespace_packages parameter is deprecated
- Pillow 10 deprecation warnings
- Array is incorrectly shifted for 96x16 OLEDs. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from luma.core.