ST25R3916 - SPI issue
Hello everyone,
I'm working with the NFC08A1 (ST25R3916) reader, and I'm encountering an issue with SPI communication when trying to read the ST25R3916 registers.
I’ve written a simple function to read a register, as shown below:
uint8_t Read_A_RegSpace(uint8_t reg)
{
uint8_t tx_frame = 0;
uint8_t rxData = 0;
HAL_StatusTypeDef status;
tx_frame = reg | 0x40;
SPI_CS_Select();
status = HAL_SPI_Transmit(&hspi1, &tx_frame, 1, HAL_MAX_DELAY);
if (status != HAL_OK) {
UART1_WriteString("Errore nel Transmit!\r\n");
return 0xFF;
}
status = HAL_SPI_Receive(&hspi1, &rxData, 1, HAL_MAX_DELAY);
if (status != HAL_OK) {
UART1_WriteString("Errore nel Receive!\r\n");
return 0xFF;
}
SPI_CS_Deselect();
UART1_WriteString("Value: ");
UART1_WriteHex(rxData);
return rxData;
}
where:
void UART1_WriteHex(uint8_t number)
{
char buffer[256] = {0};
sprintf(buffer,"0x%x\r\n", number);
UART1_WriteString(buffer);
}
void SPI_CS_Select(void)
{
HAL_GPIO_WritePin(ST25R_NSS_GPIO_Port, ST25R_NSS_Pin, GPIO_PIN_RESET);
}
void SPI_CS_Deselect(void)
{
HAL_GPIO_WritePin(ST25R_NSS_GPIO_Port, ST25R_NSS_Pin, GPIO_PIN_SET);
}
Whenever I attempt to read different registers using this function, I receive the same value for all registers (0x31 or 0x98). I'm confident that the SPI initialization is correct, and the chip select logic seems fine.
Does anyone know what could be causing this issue? Are there any specific steps or initialization procedures required to enable the correct use of SPI with the ST25R3916?
Any help or suggestions would be greatly appreciated!
