miguelbalboa / rfid

Arduino RFID Library for MFRC522
The Unlicense
2.74k stars 1.43k forks source link

SPISettings is set with wrong value for SPI clock speed #545

Closed Rotzbua closed 3 years ago

Rotzbua commented 3 years ago

Step 1: Describe your environment

Step 2: Describe the problem

Observed Results:

Expected Results:

Relevant Code:

SPI.beginTransaction(SPISettings(SPI_CLOCK_DIV4, MSBFIRST, SPI_MODE0)); // Set the settings to work with SPI bus

Introduces with commit https://github.com/miguelbalboa/rfid/commit/3c3ffa07e73b7d9da8794ab3713ae40f560b0b9c . There are many wrong examples with this code in the internet.

Required is:

SPISettings(uint32_t clock, uint8_t bitOrder, uint8_t dataMode)

SPI_CLOCK_DIV4 does not represent the clock speed. Just a number (between ~0-100). So can not be used for clock.

References

Seems to be measured here: https://github.com/miguelbalboa/rfid/issues/269#issuecomment-293256613

Initial #544

Reason https://github.com/arduino/ArduinoCore-mbed/issues/113#issuecomment-752446383