Hello,
I have been working on a custom board with a CC2540 that interfaces with a NXP via SPI. I am using a modified version of SimpleBLEPeripheral. The first custom board was working correctly and I can read NFC tags and pass them through BLE. I have since had a new custom board made with some minor alterations and it is no longer interfacing correctly. I have found the line of code that it seems to have trouble passing:
PCD_ReadRegister(ComIrqReg); // ComIrqReg[7..0] bits are: Set1 TxIRq RxIRq IdleIRq HiAlertIRq LoAlertIRq ErrIRq TimerIRq
// From MFRC522 data sheet: http://www.nxp.com/documents/data_sheet/MFRC522.pdf
ComIrqReg = 0x04 << 1 // interrupt request bits
This is the PCD_ReadRegister code:
uint8 PCD_ReadRegister( uint8 reg ) // The register to read from. One of the PCD_Register enums. { uint8 value; HalSPISelectSlave(); // Select slave (void)HalSPIWriteRead(0x80 | (reg & 0x7E)); // MSB == 1 is for reading. LSB is not used in address. Datasheet section 8.1.2.3. value = HalSPIWriteRead(0); // Read the value back. Send 0 to stop reading. HalSPIDeselectSlave(); // Release slave again return value; }
HalSPIWriteRead, HalSPIDeselectSlave and HalSPISelectSlave are the default code from hal_spi.c in the software stack:
uint8 HalSPIWriteRead(uint8 byteTx) { uint8 byteRx = 0; // Write byte to USART0 buffer (transmit data). U0DBUF = byteTx; // Check if byte is transmitted. while(!(U0CSR & U0CSR_TX_BYTE)); // Clear transmit byte status. U0CSR &= ~U0CSR_TX_BYTE; byteRx = U0DBUF; return byteRx; }
void HalSPISelectSlave(void) { SSPin = 0; } void HalSPIDeselectSlave(void) { SSPin = 1; }
Attached are some schematics of the new and old setup.
I've been staring at this for a couple of days and can't see where I'm going wrong? Thank you for in advance for any assistance with this.