The documentation has similar, but not identical, APis for SPI communication under the top pyb module and under the secondary pyb.machine module. What's the difference and what criteria determine which module I should use?
Thanks.
pyb.SPI vs pyb.machine.SPI?
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: pyb.SPI vs pyb.machine.SPI?
The pyb library is only available for STM processors (e.g. the Pyboard). So if you're using something else or want to write portable code you need to use machine.
On STM kit it's up to you. I tend to use pyb. It's rock-solid reliable as it's been around for a long time, has some STM specific functionality and is perhaps better documented.
On STM kit it's up to you. I tend to use pyb. It's rock-solid reliable as it's been around for a long time, has some STM specific functionality and is perhaps better documented.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: pyb.SPI vs pyb.machine.SPI?
Thank you. I've have had no luck with SPI communications yet. I don't know if I'm using the PyBoard SPI library incorrectly or if I'm accessing the other devices' SPI APIs incorrectly (probably the latter of course). It's driving me crazy. I2C works fine, but I've had no luck with SPI yet.
Re: pyb.SPI vs pyb.machine.SPI?
Hello,
I know this is a late post, but most of my SPI problems have been because the Mode has not been set right or because the wiring (especially when hacking together a development board) did not support the speeds.
I would double check the mode the device is designed for, and then lower the speed quite low to start, starting at 1Mhz is a good place.
If you did find a resolution, probably not bad to post here for others to learn from it.
I know this is a late post, but most of my SPI problems have been because the Mode has not been set right or because the wiring (especially when hacking together a development board) did not support the speeds.
I would double check the mode the device is designed for, and then lower the speed quite low to start, starting at 1Mhz is a good place.
If you did find a resolution, probably not bad to post here for others to learn from it.
_______________
Travis Travelstead
Travis Travelstead
Re: pyb.SPI vs pyb.machine.SPI?
I'd recommend getting a logic analyser. Helps you visualise whats being sent back and forth.
Saleae Logic 8 - $579 AUD
https://www.saleae.com/
If that's way out of your price range, you can get a cheap clone for around $6-10, which also works with the Saleae software.
https://www.aliexpress.com/item/1pcs-Ne ... 00856.html
If you can afford it, support the devs and get a legit board. It's heaps faster, better quality and much more reliable test clips.
Saleae Logic 8 - $579 AUD
https://www.saleae.com/
If that's way out of your price range, you can get a cheap clone for around $6-10, which also works with the Saleae software.
https://www.aliexpress.com/item/1pcs-Ne ... 00856.html
If you can afford it, support the devs and get a legit board. It's heaps faster, better quality and much more reliable test clips.