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???