Hello, everyone!
I am struggling to read some meaningful out of EDV2 and EDG1 fields of AGC_CTRL register (0x23), sub-register - AGC_STAT1 (0x1E).
dwt_write32bitoffsetreg(AGC_CTRL_ID, AGC_CTRL1_OFFSET, 0);
dwt_rxenable(0);
uint64_t timestamp = esp_timer_get_time();
while (esp_timer_get_time() < timestamp + 32); // wait for recommended 32 microseconds
dwt_write32bitoffsetreg(AGC_CTRL_ID, AGC_CTRL1_OFFSET, AGC_CTRL1_DIS_AM);
uint32_t res = dwt_read32bitoffsetreg(AGC_CTRL_ID, AGC_STAT1_OFFSET);
//dwt_forcetrxoff();
uint16_t edv2 = (res & AGC_STAT1_EDG2_MASK) >> 11;
uint16_t edg1 = (res & AGC_STAT1_EDG1_MASK) >> 6;
double noise_energy = ((double)edv2 - 40.0) * pow(10.0, (double)edg1);
printf("EDV2: %u; EDG1: %u; Noise Energy: %f\n", edv2, edg1, noise_energy);
I keep getting EDV2: 0, EDG1: 21. I tried running it in a loop and there I got weird results of around 170 for EDV2 and 20 for EDG1. Has anyone read those values correctly? Can anyone help with the minimal example?
Thank you very much in advance!