This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2540 SPI help required

Other Parts Discussed in Thread: CC2540

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.

  • Hi,

    Comparing the two schematics I see the following differences:

    - Addition of a 32k crystal to allow for sleep modes on the CC2540
    - Connecting RST pin from CC2540 to NXP to allow CC2540 to reset the NXP.
    - Connected vibr and buzz nodes, presumably to a buzzer and actuator of some kind.

    The first thing I would check would be to probe the SPI lines with a low-capacitance oscilloscope probe to verify the signal integrity.

    What I am most worried about is the NXP reset pin being connected without any sort of decoupling, which might lead to spurious resets of the NXP device if there is too much noise coupling between the MISO/MOSI and RST lines.

    - Are there any differences in current draw? Do you enable the vibration/buzzing during operation of SPI?
    - Are there any code differences (e.g. use of POWER_SAVING on the BLE side) since you have added the crystal?

    Regards,
    Svend

  • Hi Svend,

    I hadn't even noticed the RST pin had been connected and had it setup as output which must have been resetting the NXP.

    You saved my sanity! Thank you!