-
Notifications
You must be signed in to change notification settings - Fork 328
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SPI readings corrupted on Raspberry Pi #57
Comments
its probably due to the weird way we use the SPI peripheral locking & CS lines. i can fix if i get some example code |
Do you just want the code that fails -- here is an example -- If you leave the first temperature reading comment out, it will fails and the temperature will be corrupted -- If you read it twice - the second reading is OK.
|
I can try to come up with a better minimal case using a different SPI device instead of the LoRa |
but for now this is a bit more minimal
the line before the while() loop to set the tx power -- causes the sensor reading to be corrupted - if you comment it out, then the first reading is OK and subsequent reading fail. If you comment out the last line then only th firs reading is bad and it reads normally after that since there is no communication to the rfm9x in the loop. |
here is a simpler example using the lsm9ds1 and a bmp280 - same issue
|
even simpler test case
and output
|
nice - thank you |
could be - but 99% of sensors use MODE 0 so i dont think thats all of it! i mean, i know where the problem probably is, its how we configure the SPI device when we send data, something amiss there |
OK -- I'll go back to other projects for awhile -- Let me know if you need anything else. |
npnp |
Just throwing in my 2c FWIW: The SPIDevice context manager notionally takes care of configuring the port each time: On the RPi, this is also notionally happening. The blinka The python spidev module is just doing ioctl under the hood to the linux spidev kernel module. |
ok did a little more lookin yeah this is due to us sharing an SPI peripheral amongst multiple devices. and yeah it only happens with mixed modes |
https://learn.adafruit.com/circuitpython-on-raspberrypi-linux/faq-troubleshooting lol the LSM9DS1 is the only board that has this issue, nice work finding the one incompatibility, isn't that how it always is with programming :D |
Thanks for digging into it. There's always one troublemaker ;-) |
closing as this is now documented |
We ran into an interesting issue when using an lsm9ds1 and an rfm9x on a RaspBerry Pi
Both boards worked fine individually but when run together, the first sesor reading from the lsm9ds1 AFTER any communication with the rfm9x was corrupted.
There is a lengthy forum discussion
https://forums.adafruit.com/viewtopic.php?f=50&t=143689&start=30#p71264
I also ran the same test on a feather_m4 express and did not see the same behavior
I wonder if it is related to the difference in SPI mode (polarity and phase) being used on the rfm9x vs lsm9ds1.
Is there some problem with the transition between the modes. It only appears to impact the lsm9ds1, the rfm9x appears to be operating normally, but there is a lot more traffic to the rfm9x and it is possible that a bad command may not be immediately apparent.
The issue is not present if the I2C interface to the lsm9ds1 is used.
I'll try to get some cleaner examples of the issue but wanted to post this so you are aware of it.
The text was updated successfully, but these errors were encountered: