libnfc icon indicating copy to clipboard operation
libnfc copied to clipboard

serial speed for pn532

Open paweljasinski opened this issue 1 year ago • 5 comments

Are serial speeds other than 115200 supported when using pn532? Both: device.connstring = "pn532_uart:/dev/ttyUSB0:57600 and device.connstring = "pn532_uart:/dev/ttyUSB0:460800 produce a code dump.

paweljasinski avatar Jan 15 '24 00:01 paweljasinski

hi,paweljasinski: Speed value must be one of these constants: 9600 (default), 19200, 38400, 57600, 115200, 230400 or 460800.", uiPortSpeed); It's in the file “uart.c”. But 115200 is the PN532's default value. If you want to use other baud, you must use "SetSerialBaudRate" command first. image

NFC-funs avatar Mar 07 '24 04:03 NFC-funs

To be sure I am not misunderstanding anything.

  • establish communication with the default 115200,
  • issue the SetSerialBaudRate
  • re-establish communication with a new speed

paweljasinski avatar Mar 11 '24 15:03 paweljasinski

Please refer to the diagram: image To be sure that the baud rate-"Real HSU Freq" error is not greater than 4%: image

PN532 User Manual V0.2.pdf PN532_C1.pdf

NFC-funs avatar Mar 13 '24 08:03 NFC-funs

already have a basic communication with 230.4.

To be sure that the baud rate-"Real HSU Freq" error is not greater than 4%: Do I have to adjust registers value (HSU_CNT and HSU_PRE) myself, or it happens as part of SetSerialBaudRate?

I have another question: Once the comm speed is changed from default, it is persistent until reset or power cycle. For now I am coding with assumption that libnfc works with the board after reset and starts with 115200 and changes to requested speed. The code is not trying to reestablished communication after program terminated but board did not get reset and is still using the altered speed. Is this something you would considered to be acceptable in PR?

paweljasinski avatar Mar 13 '24 09:03 paweljasinski

Poll the command "SAMConfiguration" at different baud rates before communication, such as: 55 55 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF 03 FD D4 14 01 17 00, and receive the right ACK.

NFC-funs avatar Mar 13 '24 09:03 NFC-funs