Lora-net / sx1302_hal

SX1302/SX1303 Hardware Abstraction Layer and Tools (packet forwarder...)
Other
219 stars 271 forks source link

the unit of the timestamp_cnt? #100

Closed chris-william0829 closed 1 year ago

chris-william0829 commented 1 year ago

hey guys, i'm using the sx1303's precise timestamp mode. The program offers a timestamp_cnt like: `
/ Packet timestamp (32MHz ) /

pkt->timestamp_cnt  = (uint32_t)((SX1302_PKT_TIMESTAMP_7_0(self->buffer, self->buffer_index + pkt->rxbytenb_modem) <<  0) & 0x000000FF);

pkt->timestamp_cnt |= (uint32_t)((SX1302_PKT_TIMESTAMP_15_8(self->buffer, self->buffer_index + pkt->rxbytenb_modem) <<  8) & 0x0000FF00);

pkt->timestamp_cnt |= (uint32_t)((SX1302_PKT_TIMESTAMP_23_16(self->buffer, self->buffer_index + pkt->rxbytenb_modem) << 16) & 0x00FF0000);

pkt->timestamp_cnt |= (uint32_t)((SX1302_PKT_TIMESTAMP_31_24(self->buffer, self->buffer_index + pkt->rxbytenb_modem) << 24) & 0xFF000000);`

and another tmst p->count_us

j = snprintf((char *)(buff_up + buff_index), TX_BUFF_SIZE-buff_index, ",\"tmst\":%u", p->count_us);

But when I set a node to send messages every 5s period. and i print the timestamp_cnt and p->count_us. it shows

timestamp_cnt - pre_timestamp_cnt = 161,666,888

count_us - pre_count_us = 5,052,090

i can understand the count_us is in microseconds.

but what is the unit of the timestamp_cnt?

mcoracin commented 1 year ago

Hello, timestamp_cnt is a 32MHz counter.

/* Scale 32 MHz packet timestamp to 1 MHz (microseconds) */
p->count_us = pkt.timestamp_cnt / 32;