SPI readinto() 'write' parameter #10520
-
I've written a script to communicate with MicroChip PICs using SPI. The script worked fine on a PyBoard and ESP32 with several PIC types. But the same script fails with an RP2040 Pico. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
That's indeed strange because the implementation of spi.readinto() itself is not port-specific. It calls however a port specific transfer function. May it be that other parameters have to be aligned like phase or polarity, and the difference between the ports is some subtle timing, which may differ? Does SoftSPI have different as well? |
Beta Was this translation helpful? Give feedback.
-
This is indeed very odd. Just to clarify what @robert-hh is saying, the only place that second argument is used is to memset the buffer. It is not passed into the port-specific code. Do you have a logic analyser and can see what's going on? Does your PIC code care about the bits that are written during the write? (i.e. what does the PIC code expect to be transmitted on the controller's SDO during the read?) |
Beta Was this translation helpful? Give feedback.
-
My apologies: wiring error! Brief explanation: But even after check and recheck I overlooked a wrong connection. It was pure coincidence that it worked by specifying readinto(buf3, 0xFF). After fixing the wiring a readinto(buf3) is OK. SPI of the RP2 works like with PyBoard and ESP32. |
Beta Was this translation helpful? Give feedback.
My apologies: wiring error! Brief explanation:
The communications with the PIC is half duplex and on the side of the PIC I use one Pin (PGD in the picture below) for input and output. Therefore I use the following wiring 'trick':
But even after check and recheck I overlooked a wrong connection. It was pure coincidence that it worked by specifying readinto(buf3, 0xFF). After fixing the wiring a readinto(buf3) is OK. SPI of the RP2 works like with PyBoard and ESP32.