AGC

Hi All!

I’m trying to scan and analyze current air state to choose free channel for operation.
Everything, that I end up with is this code:

[code]
dwt_config_t dwt_config = {
1, /* Channel number. /
DWT_PRF_64M, /
Pulse repetition frequency. /
DWT_PLEN_64, /
Preamble length. /
DWT_PAC16, /
Preamble acquisition chunk size. Used in RX only. /
9, /
TX preamble code. Used in TX only. /
9, /
RX preamble code. Used in RX only. /
0, /
Use non-standard SFD (Boolean) /
DWT_BR_6M8, /
Data rate. /
DWT_PHRMODE_STD, /
PHY header mode. /
(65 + 8 - 16) /
SFD timeout (preamble length + 1 + SFD length - PAC size). Used in RX only. */
};
dwt_configure(&dwt_config);
dwt_setcallbacks(NULL, NULL, NULL, NULL);
dwt_setinterrupt(0
|DWT_INT_RFCG
|DWT_INT_RFTO
|DWT_INT_LDED
|DWT_INT_RPHE
|DWT_INT_RFCE
|DWT_INT_RFSL
|DWT_INT_RXOVRR
|DWT_INT_RXPTO
|DWT_INT_SFDT
|DWT_INT_TFRS
, 1);

dwt_write32bitoffsetreg(AGC_CTRL_ID, AGC_TUNE1_OFFSET, AGC_TUNE1_64M);
dwt_write32bitoffsetreg(AGC_CTRL_ID, AGC_TUNE2_OFFSET, AGC_TUNE2_VAL);
dwt_write32bitoffsetreg(AGC_CTRL_ID, AGC_TUNE3_OFFSET, AGC_TUNE3_VAL);
dwt_write32bitoffsetreg(AGC_CTRL_ID, AGC_CTRL1_OFFSET, 0);

dwt_rxenable(0);

// wait 32 us
dw1000_get_systime_u64(); // takes 11 us
dw1000_get_systime_u64();
dw1000_get_systime_u64();
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();

uint32_t edg1 = (res & AGC_STAT1_EDG1_MASK) >> 6;
uint32_t edg2 = (res & AGC_STAT1_EDG2_MASK) >> 11;[/code]

and with any channel settings I get edg1 = 21 and edg2 = 0… No matter, weither there are tags/ancors emitting around or not.
Do I miss something?

Stan