Hello there,
I am testing the DWM1001-DEV SPI API to communicate with an Arduino Nano. First, I connect the MOSI MISO CLK GND CS and 5V pins to the nano.
I am not sure about the spi setting of DWM1001 so I set the speed to 8000000, the bit order to MSBFIRST(Most Significant bit first), and the SPI_MODE0
[color=#4f4e4e][size=medium][font=TyponineSans Text 16]Mode [color=#4f4e4e][size=medium]Clock Polarity (CPOL) [color=#4f4e4e][size=medium]Clock Phase (CPHA) [color=#4f4e4e][size=medium]Output Edge [color=#4f4e4e][size=medium]Data Capture[/size][/color][/size][/color][/size][/color][/size][/color][/font]
SPI_MODE0 0 0 Falling Rising[/size][/color]
I wanted to get the position data. In each loop, I transfer 0x02 and 0x00 at first, and keep sending 0xFF to dwm1001 until I get the return Size byte != 0x00, and then I keep transfer Size bytes of 0xFF to get the data back. I followed exactly what the SPI Example diagram shows in the dwm1001-api-guide.
However, the data I got back doesn’t look good. I supposed I would get two 0xFF bytes back as I was sending the get_position TLV request (0x02, 0x00), I got random bytes back instead. What’s more, I keep getting 0xFF back from DWM1001. I will post my code below and the Serial monitor result to show what I got back from DWM1001.
Can anyone give me some help? Really appreciate it!
Thanks in advance
Richard
code:
[code]#include <SPI.h>
SPISettings settingsA(8000000,MSBFIRST,SPI_MODE0);
void setup() {
// pinMode(SS,OUTPUT);
Serial.begin(115200);
SPI.begin();
}
void loop() {
Serial.println("request for pos start ");
SPI.beginTransaction(settingsA);
digitalWrite(SS,LOW);
Serial.print("Sending command, getting back these bytes: “);
Serial.print(SPI.transfer(0x02));
Serial.print(” “);
Serial.print(SPI.transfer(0x00));
Serial.println(” ");
// get the SIZE
uint8_t rxSize = 0x00;
while (rxSize == 0x00) {
rxSize = SPI.transfer(0xFF);
}
Serial.print(“Size:”);
Serial.print(rxSize,DEC);
Serial.println("");
Serial.print(“here are the data DWM1001 sent back:”);
for (byte i = 0; i < rxSize; i++) {
Serial.print(SPI.transfer(0xFF),HEX);
Serial.print(" “);
}
Serial.println(”");
Serial.println("------------------");
SPI.endTransaction();
digitalWrite(SS,HIGH);
delay(5000);
}
[/code]
RESULTS:
request for pos start
Sending command, getting back these bytes: 18 1
Size:255
here are the data DWM1001 sent back:FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
request for pos start
Sending command, getting back these bytes: 64 1
Size:65
here are the data DWM1001 sent back:D 26 FF FF FF 50 1 0 0 1B FF FF FF 0 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
request for pos start
Sending command, getting back these bytes: 255 255
Size:255
here are the data DWM1001 sent back:FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
request for pos start
Sending command, getting back these bytes: 18 1
Size:255
here are the data DWM1001 sent back:FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
request for pos start
Sending command, getting back these bytes: 64 1
Size:65
here are the data DWM1001 sent back:D 7C FC FF FF 42 1 0 0 BC FF FF FF 0 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
request for pos start
Sending command, getting back these bytes: 255 255
Size:255
here are the data DWM1001 sent back:FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
request for pos start
Sending command, getting back these bytes: 18 1
Size:255
here are the data DWM1001 sent back:FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
request for pos start
Sending command, getting back these bytes: 64 1
Size:65
here are the data DWM1001 sent back:D 4A 2 0 0 A3 FF FF FF 94 FF FF FF 0 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF