I’m feeling pretty frustrated about now and could use some help. I’m trying to send and receive frame data between an XBee Pro 900HP and an Argon using SPI, and I’m missing something.
I’ve connected the Argon’s pins to the the pins of a Sparkfun XBee Explorer - Regulated as mapped for SPI in this doc from Digi (page 41). To do this, I soldered two 11-pin headers to the Sparkfun board and plugged it into 2 breadboards (it’s too wide for 1). This worked when testing a serial connection between the Argon, the XBee, and other XBees on the same mesh.
The test setup includes 3 XBee 900HPs. One is in the Sparkfun board connected to an Argon, the other 2 are in WaveShare XBee USB carriers connected to my windows dev machine. Using XCTU, the boards communicate as expected. In other words, I created a type 0x10 frame in XCTU and broadcast it across the mesh network. I know the XBee connected to the Argon receives the frame packet because the RSSI and DIN LEDs light on the Sparkfun board when I click “Send Selected Frame” in XCTU, and the data shows up in the XCTU Frames Log for the sending node and the node in the other USB carrier.
All 3 XBees are configured for API Mode 1. Encryption is off. The DL for all 3 XBees is FFFF, which broadcasts to all nodes on the mesh.
However, I can’t receive the data using the code I have written for the Argon. I’ve tried several variations, but this is the most recent…
SYSTEM_THREAD(ENABLED);
static uint8_t rx_buffer[64];
static uint8_t tx_buffer[64];
static uint32_t transfer_state = 0;
void setup() {
Serial.begin();
for (uint16_t i = 0; i < sizeof(tx_buffer); i++){
tx_buffer[i] = (uint8_t)i;
}
SPI.setBitOrder(MSBFIRST);
SPI.setDataMode(SPI_MODE0);
SPI.setClockSpeed(1, MHZ);
SPI.begin(SPI_MODE_MASTER, A5);
}
void loop() {
uint16_t availableBytes = SPI.available();
if (availableBytes>0){
Serial.println("Data available...");
SPI.transfer(tx_buffer, rx_buffer, sizeof(rx_buffer), onTransferFinished);
while(transfer_state==0);
for(uint16_t i=0; i<sizeof rx_buffer; i++){
Serial.print(rx_buffer[i], HEX);
}
transfer_state=0;
}
}
void onTransferFinished() {
Serial.println("In onTransferFinished");
transfer_state = 1;
}
I feel like I’ve overlooked something really dumb. I would suspect the Argon signals are being level-shifted by the Sparkfun “regulated” board if the Serial testing using the same board and headers hadn’t worked.
Any help much appreciated!! Meanwhile, I think I’ll enjoy a little primal scream therapy. And some Scotch. Maybe just Scotch.
Steve