Hello,
I'm trying this for days now and I'm desperate. Can you help me ? Here is the problem. I'm trying to communicate with a PN532 board (http://puu.sh/wVkAH/f8804a6549.jpg) via a LoPy board with SPI.
3.3v, GND, SCK(P10), MISO (P12), MOSI (P11) and SS(P9) are well connected on the LoPy board.
I re-wrote some PN532 c/cpp/python libraries for micropython thanks to some pieces of code on forums (here is my code: https://pastebin.com/6h3fuWjF)
Basically I'm sending initiating a SPI connection (SPI.MASTER, baudrate=1000000, polarity=0, phase=0, bits=8, firstbit=SPI.MSB)
First thing, in all libraries I found they all use SPI.LSB but in pycom lopy doc there is ONLY MSB (screenshot of the doc: http://puu.sh/wVkJY/9cf5c92e48.png)
Then to test the connection I'm checking the PN5xx firmware by sending a frame, I logged it:
writeframe (decimal)
TX: 1
TX: 0
TX: 0
TX: 255
TX: 2
TX: 254
TX: 212
TX: 2
TX: 42
TX: 0
end frame
Then the PN5xx update its register, when data is ready I'm supposed to make a "Status read" call by sending 0x02 to the PN5xx here is the log:
Read status
TX: 2
RX: 0
And that's my problem whatever I send I always get 0x00 data. Sometimes magically I receive 0x10(16) whatever frame I send. I thought it was coming from the MSB/LSB problem (0x10 => 0x01) and 0x01 is what I'm expected to get, but when I try to read the register I'm still getting 0x00
I'm sure the PN5xx is working, I've tried to use an Arduino UNO + AdafruitPN532_SPI lib and it worked pretty well. I logged the frame, it's the same as mine with my python code but when it comes to Read status arduino uno gets a 0x01 response code. (And SPI.cpp lib is using firstbit=LSB)
So 1st, why I can't use LSB instead of MSB on my LoPy and 2nd, Why I'm always getting error response from the PN5xx
Thanks for help !
(Btw, I'm writing this in one block just after 3 days of this thing which is driving me crazy sorry for my english)
LoPy PN532 SPI issue
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: LoPy PN532 SPI issue
You're more likely to get support on the PyCom forum https://forum.pycom.io/ where people actually own PyCom hardware.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.