Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of DecaWave by
Revision 38:8ef3b8d8b908, committed 2015-02-22
- Comitter:
- manumaet
- Date:
- Sun Feb 22 11:41:18 2015 +0000
- Parent:
- 37:40f94c634c3e
- Child:
- 39:bb57aa77b015
- Commit message:
- new crashs after 10 secs
Changed in this revision
--- a/DW1000/DW1000.cpp Fri Feb 20 13:21:06 2015 +0000
+++ b/DW1000/DW1000.cpp Sun Feb 22 11:41:18 2015 +0000
@@ -11,8 +11,9 @@
loadLDE(); // important everytime DW1000 initialises/awakes otherwise the LDE algorithm must be turned of or there's receiving malfunction see User Manual LDELOAD on p22 & p158
// Configuration TODO: make method for that
- writeRegister8(DW1000_SYS_CFG, 3, 0x20); // enable auto reenabling receiver after error
- //writeRegister8(DW1000_SYS_CFG, 2, 0x03); // enable 1024 byte frames TODO: is this really what stated in the comment?
+ writeRegister8(DW1000_SYS_CFG, 3, 0x20); // enable auto reenabling receiver after error
+ writeRegister8(DW1000_SYS_CFG, 2, 0x40); // enable special receiving option for 110kbps!! (0x40) see p.64 of DW1000 User Manual [DO NOT enable 1024 byte frames (0x03) becuase it generates disturbance of ranging don't know why...]
+ writeRegister16(DW1000_TX_FCTRL, 1, 0x2800 | 0x0100 | 0x0080); // use 2048 symbols preable (0x2800), 16MHz pulse repetition frequency (0x0100), 110kbps bit rate (0x0080) see p.69 of DW1000 User Manual
irq.rise(this, &DW1000::ISR); // attach Interrupt handler to rising edge
}
@@ -80,19 +81,20 @@
}
void DW1000::sendFrame(uint8_t* message, uint16_t length) {
- if (length >= 1021) length = 1021; // check for maximim length a frame can have TODO: 127 Byte mode?
+ //if (length >= 1021) length = 1021; // check for maximim length a frame can have with 1024 Byte frames [not used, see constructor]
+ if (length >= 125) length = 125; // check for maximim length a frame can have with 127 Byte frames
writeRegister(DW1000_TX_BUFFER, 0, message, length); // fill buffer
#if 0 // switch draft for slower data rate and original working 6.8Mbps
uint8_t backup = readRegister8(DW1000_TX_FCTRL, 1); // put length of frame
length += 2; // including 2 CRC Bytes
//length = ((backup & 0xFC) << 8) | (length & 0x03FF);
- length = ((0xA0 & 0xFC) << 8) | (length & 0x03FF); // for slower data rate and therefore more range TODO: put in a modular configuration not a fixed value
+ length = ((0x80 & 0xFC) << 8) | (length & 0x03FF); // for slower data rate and therefore more range TODO: put in a modular configuration not a fixed value
writeRegister16(DW1000_TX_FCTRL, 0, length);
backup = readRegister8(DW1000_TX_FCTRL, 2); // change preamble length
uint8_t preamble_reg = (backup & 0xC0) | (0x29 & 0x3F); // for longer preamble to match slower data rate TODO: put in a modular configuration not a fixed value
- writeRegister8(DW1000_TX_FCTRL, 2, preamble_reg);
+ //writeRegister8(DW1000_TX_FCTRL, 2, preamble_reg);
#else
uint8_t backup = readRegister8(DW1000_TX_FCTRL, 1); // put length of frame
length += 2; // including 2 CRC Bytes
--- a/MMRanging/MMRanging.cpp Fri Feb 20 13:21:06 2015 +0000
+++ b/MMRanging/MMRanging.cpp Sun Feb 22 11:41:18 2015 +0000
@@ -33,14 +33,14 @@
default : break;
}
- event[event_i][0] = '!';
+ /*event[event_i][0] = '!';
event[event_i][1] = 'R';
event[event_i][2] = ' ';
sprintf(&event[event_i][3], "%d>%d / %d %d", RX.source, RX.destination, RX.sequence_number, RX.type);
if (event_i == 8)
event_i = 0;
else
- event_i++;
+ event_i++;*/
dw.startRX();
}
@@ -57,14 +57,14 @@
default: break;
}
- event[event_i][0] = '!';
+ /*event[event_i][0] = '!';
event[event_i][1] = 'S';
event[event_i][2] = ' ';
sprintf(&event[event_i][3], "%d>%d / %d %d", TX.source, TX.destination, TX.sequence_number, TX.type);
if (event_i == 8)
event_i = 0;
else
- event_i++;
+ event_i++;*/
}
void MMRanging::requestRanging(uint8_t destination) {
--- a/main.cpp Fri Feb 20 13:21:06 2015 +0000
+++ b/main.cpp Sun Feb 22 11:41:18 2015 +0000
@@ -15,16 +15,17 @@
dw.setEUI(0xFAEDCD01FAEDCD01); // basic methods called to check if we have a working SPI connection
pc.printf("DEVICE_ID register: 0x%X\r\n", dw.getDeviceID());
pc.printf("EUI register: %016llX\r\n", dw.getEUI());
- pc.printf("Voltage: %f\r\n", dw.getVoltage());
- pc.printf("Size of Frame: %d\r\n", sizeof(r.TX));
+ pc.printf("Voltage: %fV\r\n", dw.getVoltage());
+ pc.printf("System Configuration: %llX\r\n", dw.readRegister40(DW1000_SYS_CFG, 0));
+ pc.printf("Size of Rangingframe: %d\r\n", sizeof(r.TX));
- uint16_t setdelay = 32768; // TODO: = 2^15
+ uint16_t setdelay = 32300;//768; // TODO: = 2^15
dw.writeRegister16(DW1000_TX_ANTD, 0, setdelay);
pc.printf("Antenna Delay TX: %d\r\n", dw.readRegister16(DW1000_TX_ANTD, 0));
pc.printf("Antenna Delay RX: %d\r\n", dw.readRegister16(DW1000_LDE_CTRL, 0x1804));
r.receiver = true;
if (r.receiver)
- r.address = 1;
+ r.address = 2;
else
r.address = 0; // sender node has address 0
pc.printf("Address: %d\r\n", r.address);
@@ -34,17 +35,23 @@
if (!r.receiver) { // Request ranging
r.requestRanging(1); // TODO: ask all available nodes!
wait(0.005);
+ r.requestRanging(2);
+ wait(0.005);
}
- // Output bar on console
- for(int j = 0; j < 1; j++)
- //pc.printf("%f ", r.tofs[j]*MMRANGING_TIMEUNIT_NS);
- pc.printf("%lld [", r.tofs[1]);
- int dots = r.tofs[1]*70/1400;
- if (abs(dots) < 100000)
- for(int j = 0; j < dots; j++)
- pc.printf("=");
- pc.printf("]\r\n");
+ //pc.printf("%lld\r\n", r.tofs[2]); // logging output
+
+ #if 1 // Output bars on console
+ for(int i = 1; i < 3; i++) {
+ //pc.printf("%f ", r.tofs[j]*MMRANGING_TIMEUNIT_NS);
+ pc.printf("%lld [", r.tofs[i]);
+ int dots = r.tofs[i]*70/1400;
+ if (abs(dots) < 10000)
+ for(int j = 0; j < dots; j++)
+ pc.printf("=");
+ pc.printf("]\r\n");
+ }
+ #endif
#if 1 // Output events for debugging
for(int j = 0; j < 10; j++)
@@ -56,8 +63,8 @@
#endif
pc.printf("Status: %llX\r\n", dw.getStatus());
pc.printf("TX Control: %llX\r\n", dw.readRegister40(DW1000_TX_FCTRL, 0));
-
- wait(0.01);
+ //pc.printf("\r\n");
+ //wait(0.05);
wait(0.2);
}
}
\ No newline at end of file
