0
\$\begingroup\$

I'm using RFID reader Rc522 communicating with the STM32f030c8 via SPI1 and EEPROM communicating via SPI2. System clock : 48 Mhz (via the Internal PLL system) APB peripheral clock which has the SPI's : 48Mhz

SPI Init for Rc522

  SPI1_Config.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
  SPI1_Config.SPI_Mode = SPI_Mode_Master;
  SPI1_Config.SPI_DataSize = SPI_DataSize_8b;
  SPI1_Config.SPI_CPOL = SPI_CPOL_Low;
  SPI1_Config.SPI_CPHA = SPI_CPHA_1Edge;
  SPI1_Config.SPI_NSS = SPI_NSS_Hard;
  SPI1_Config.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_8; // 48/8 = 6MHZ
  SPI1_Config.SPI_FirstBit = SPI_FirstBit_MSB;
  SPI1_Config.SPI_CRCPolynomial = 7;

SPI Init for EEPROM

  SPI2_Config.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
  SPI2_Config.SPI_Mode = SPI_Mode_Master;
  SPI2_Config.SPI_DataSize = SPI_DataSize_8b;
  SPI2_Config.SPI_CPOL = SPI_CPOL_Low;
  SPI2_Config.SPI_CPHA = SPI_CPHA_1Edge;
  SPI2_Config.SPI_NSS = SPI_NSS_Hard;
  SPI2_Config.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_16; // 48/16 = 3Mhz
  SPI2_Config.SPI_FirstBit = SPI_FirstBit_MSB;
  SPI2_Config.SPI_CRCPolynomial = 7;

Now when i try to access both the SPI's sequentially ie accessing EEPROM while communicating with the reader the EEPROM contents gives ambiguous results. I tried to lower the speed for EEPROM to SPI_BaudRatePrescaler_64 and it the EEPROM and Rc522 works as intended. Is there any trade off or any limitation while using 2 SPI's of this STM controller? I wish to use my EEPROM around 6 Mhz along with Rc522.

Is there any work-around so that i can use both the peripherals at around the same speed (5-10 Mhz) without such ambiguous results???

Thank you.

\$\endgroup\$
  • 2
    \$\begingroup\$ The correct way to write the SI unit of frequency \$\endgroup\$ – Andy aka Mar 5 '18 at 9:44
  • 1
    \$\begingroup\$ Show the circuit please. \$\endgroup\$ – AndreyB Mar 5 '18 at 10:52
  • \$\begingroup\$ In addition to supplying the schematic, as requested already: (a) Please give the part number of the EEPROM and a link to its datasheet; (b) Please supply close-up, in-focus photos of your hardware, showing all wiring between the various parts; (c) Have you used an oscilloscope to view the SPI signals during "good" and "bad" behaviour? (d) What exactly are those "ambiguous results"? (e) "when i try to access both the SPI's sequentially ie accessing EEPROM while communicating with the reader" If you are accessing both SPI devices at the same time, then don't you mean simultaneously? \$\endgroup\$ – SamGibson Mar 5 '18 at 14:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.