SPI1 does not seem to work correctly. #1831
Replies: 2 comments 1 reply
-
Sorry, but there's not really anything to go on here. Especially since you're working with custom, external hardware and boards only you have. Some general things:
|
Beta Was this translation helpful? Give feedback.
-
I did a quick check using the SPItoMyself.ino example. (by the way it does not compile if you set the SPI debug flag). So, out of the box and using the wiring in the comments, it works perfectly. I switched the SPIs, So that SPI1 is used on Core0 and SPI0 is used on Core1. It works perfectly also. I then switched the pins to GP12, GP13, GP14, GP15 (also SPI1) and it still is perfect. So... it the problem is in my setup/code....., I eventually found it, and it is now working. I am still confused as to why, it the same code worked on SPI0, but let's close this conversation. Sorry for the interruption! and great work on the overall arduino-pico port. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi Earle,
I am using a PICO to communicate with a ADS1220 module. (I am porting the following Arduino example over to the Pico)
https://how2electronics.com/how-to-use-ads1220-24-bit-adc-module-with-arduino/#:~:text=The%20Module%20can%20be%20easily,to%20fed%20the%20input%20voltage.
I am able to get it to work on SPI0 (default pins #define PIN_SPI0_MISO (16u), #define PIN_SPI0_MOSI (19u), #define PIN_SPI0_SCK (18u) and #define PIN_SPI0_SS (17u))
In our application, we are using SPI0 for a W5500 ethernet chip. So I need the ADS1220 to work on SPI1.
When I switch the settings to use SPI1, it does not work. It might have to do with the interrupt masks not being set correctly when SPI1 is being used. (this is a guess based on the difference in output between SPI0 and SPI1....
SPI debug when SPI0 is being used......
16:57:15.644 -> Begining loop code!
16:57:17.675 -> SPI::beginTransaction(clk=4000000, bo=MSB)
16:57:17.675 -> SPI: Reusing existing initted SPI
16:57:17.675 -> SPI: IRQ masks before = 00000000 00000000 00000000 00000000
16:57:17.675 -> SPI: IRQ masks after = 00000000 00000000 00000000 00000000
16:57:17.675 -> SPI::transfer(20), cpol=0, cpha=1
16:57:17.675 -> SPI: read back 32
16:57:17.675 -> SPI::transfer(00), cpol=0, cpha=1
16:57:17.675 -> SPI: read back d1
16:57:17.675 -> SPI::endTransaction()
16:57:17.675 -> SPI: IRQ masks = 00000000 00000000 00000000 00000000
16:57:17.675 -> SPI::beginTransaction(clk=4000000, bo=MSB)
16:57:17.675 -> SPI: Reusing existing initted SPI
16:57:17.675 -> SPI: IRQ masks before = 00000000 00000000 00000000 00000000
16:57:17.675 -> SPI: IRQ masks after = 00000000 00000000 00000000 00000000
16:57:17.675 -> SPI::transfer(20), cpol=0, cpha=1
16:57:17.675 -> SPI: read back ff
16:57:17.675 -> SPI::transfer(00), cpol=0, cpha=1
16:57:17.675 -> SPI: read back d1
16:57:17.675 -> SPI::endTransaction()
(a board reset will work, i.e. the Beginning loop code text will be displayed)
SPI debug output when SPI1 is being used....(after download)
17:01:20.119 ->
17:01:20.119 -> SPI::begin(0), rx=12, cs=13, sck=14, tx=15
17:01:20.119 -> SPI::beginTransaction(clk=4000000, bo=MSB)
17:01:28.133 -> SPI: initting SPI
17:01:28.133 -> SPI: actual baudrate=4000000
17:01:28.133 -> SPI: IRQ masks before = 00000000 00000000 00000000 00000000
17:01:28.133 -> SPI: IRQ masks after = 00000000 00000000 00000000 00000000
17:01:28.133 -> SPI::endTransaction()
17:01:28.133 -> SPI: IRQ masks = 00000000 00000000 00000000 00000000
17:01:28.133 -> SPI::beginTransaction(clk=4000000, bo=MSB)
17:01:28.133 -> SPI: deinitting currently active SPI
17:01:28.133 -> SPI: initting SPI
17:01:28.133 -> SPI: actual baudrate=4000000
17:01:28.133 -> SPI: IRQ masks bSPI::endTransaction()
17:01:28.133 -> SPI: IRQ masks = 00000000 00000000 0000000SPI::beginTransaction(clk=4000000, bo=MSB)
17:01:28.133 -> SPI: Reusing existing initted SPI
17:01:28.133 -> SPI: IRQ masks before = 00000000 00000000 00000000 SPI::endTransaction()
17:01:28.133 -> SPI: IRQ masks = 00000000 00000000 0000000SPI::beginTransaction(clk=4000000, bo=MSB)
17:01:28.133 -> SPI: Reusing existingSPI::transfer(20), cpol=0, cpha=1
17:01:28.133 -> SPI: read back ff
17:01:28.133 -> SPI::transfer(00), cpol=0, cpha=1
17:01:28.133 -> SPI: read back 01
17:01:28.133 -> SPI::endTransaction()
17:01:28.133 -> SPI: IRQ masks = 00000000 00000000 00000000 00000000
17:01:28.133 -> SPI::beginTransaction(clk=4000000, bo=MSB)
17:01:28.133 -> SPI: Reusing existing initted SPI
17:01:28.133 -> SPI: IRQ masks before = 00000000 00000000 00000000 00000000
17:01:28.133 -> SPI: IRQ masks after = 00000000 00000000 00000000 00000000
17:01:28.133 -> SPI::transfer(40), cpol=0, cpha=1
17:01:28.133 -> SPI: read back ff
17:01:28.133 -> SPI::transfer(01), cpol=0, cpha=1
17:01:28.133 -> SPI: read back ff
17:01:28.133 -> SPI::endTransaction()
The board reset does not recover the board
Let me know if you need a code example of what I am changing between versions. I will continue to investigate on my end. I need to get the picoDebugger connected and put the SPI debug output on Serial1. In the meantime if you spot something I might be missing, or if you can confirm that you tested SPI0 and SPI1 on some SPI example, let me know. ( this evening, I might try to modify your SPI master SPI Slave example to use SPI1 and see if it works...)
Thanks
Martin
Beta Was this translation helpful? Give feedback.
All reactions