Why does XBee 868LP SPI not respond when connected to Atmega328P MCU

I have connected CLK, MISO, MOSI, CSel and ATTN lines to a standalone Atmel Atmega328P chip, loaded with the Arduino bootloader and running on its internal 8MHz oscillator at Vcc = 3.3V. On the XBee, GND, VCC (also 3.3V) and either [CLK, MISO, MOSI, CSel and ATTN] or [DOUT and DIN] are connected.

The Atmega chip can transmit data (“Hello world”) in API mode 1 (non-escaped) via UART to a second XBee which is connected to a PC via USB. When I disconnect the UART lines and connect the SPI lines, the XBee does not transmit anything. Moreover, upon a hard reset of the XBee, no status frame is received on the SPI bus and the ATTN line always remains HIGH. When I send a RF data frame from the PC XBee, it is received in UART mode, but again SPI does not respond and ATTN remains high.

I have checked the outgoing signals from the Atmega MCU. The waveforms are as expected for CLK, MOSI and CSel (3.3V, mode 0, MSB first, leading edge rises).

The MISO line however remains high constantly. I have connected a flash-memory chip using the same SPI interface and it works correctly.

I have tried the following, to no avail:

  • connecting the DOUT to ground and resetting the XBee.
  • setting the DOUT and DIN to ‘disabled’ using XCTU.
  • setting all disconnected DIO pins to disabled, input, output low and output high.
  • disabling the pullup/down resistors on the SPI lines
  • SPI communication at different speeds (2, 1, 0.5, 0.25, 0.125, 0.0625 MHz)
  • repeating the abovementioned tests with a second XBee module

There is simply no reponse from the XBee in SPI mode. When UART lines are connected, the XBee always works. This suggests that the XBee never enters SPI mode. I have read the 868LP manual, and the following posts:

, but they have not helped. I would be grateful if you could provide some advice and perhaps some more detailed information on the SPI implementation on the XBee 868LP. Am I missing some essential step? Do you know of anyone successfully using XBee + Atmega328 with SPI interface? Thank you for your time.

Try restoring the XBee to defaults. Then enable the SPI ports and disable the UART pins and don’t do anything else. Then reset the module with the SPI lines connected. To then receive data from the SPI of the XBee, trigger your SPI ATTN line and feed it 0xFF’s. You should then get back a valid API frame. That is if there is any data to be sent out the UART.

I thought that the ATTN line is an output from the Xbee? By triggering it, do you mean send ATTN 0xFF? I don’t understand why one should do this when the ATTN line is supposed to signal that data is ready?

SPI lines go both ways. You need to listen to the attn line on your UART and issue 0xFF packets to receive valid API frames back from the radio.