From 97d065641d4989f73bbde3ea8c5314c76a7e4732 Mon Sep 17 00:00:00 2001 From: egzumer Date: Fri, 1 Dec 2023 23:59:18 +0100 Subject: [PATCH] Created Development (markdown) --- Development.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Development.md diff --git a/Development.md b/Development.md new file mode 100644 index 0000000..3a2235f --- /dev/null +++ b/Development.md @@ -0,0 +1,32 @@ +# AGC (Automatic Gain Control) of BK4819 + +## Registers used by AGC + +| Register | Default | Description | +|---|---|---| +| REG_7E<15> | 0 | AGC fix mode:
1: Fix
0: Auto | +| REG_7E<14:12> | 0b011 | AGC fix index:
011: Max.

100: Min. | +| REG_7E<11:6> | | Signal strength indicator
(not in the docs, my interpretation) | +| REG_10<15:0> | 0x0038 | RX AGC Gain Table[0] (Index for max. to min.: 3, 2, 1, 0, -1)
<9:8>: LNA Gain Short
11: 0 dB; 10: -11 dB; 01: -16 dB; 00: -19 dB
<7:5>: LNA Gain
111: 0 dB; 110: -2 dB; 101: -4 dB; 100: -6 dB;
011: -9 dB; 010: -14 dB; 001: -19 dB; 000: -24 dB
<4:3>: MIXER Gain
11: 0 dB; 10: -3 dB; 01: -6 dB; 00: -8 dB
<2:0>: PGA Gain
111: 0 dB; 110: -3 dB; 101: -6 dB; 100: -9 dB;
011: -15 dB; 010: -21 dB; 001: -27 dB; 000: -33 dB | +| REG_11<15:0> | 0x025a | RX AGC Gain Table[1]
The description is the same as REG_10. | +| REG_12<15:0> | 0x037b | RX AGC Gain Table[2]
The description is the same as REG_10. | +| REG_13<15:0> | 0x03de | RX AGC Gain Table[3]
The description is the same as REG_10. | +| REG_14<15:0> | 0x0000 | RX AGC Gain Table[-1]
The description is the same as REG_10. | +| REG_49<13:7> | 0x50 | RF AGC high threshold, 1 dB/LSB | +| REG_49<6:0> | 0x30 | RF AGC low threshold, 1 dB/LSB | +| REG_7B<15:0> | 0xae34 | RSSI table | +| REG_7C<15:0> | 0x8000 | RSSI table | + +## How it works + +`AGC fix index` (3-bits signed integer, 0b111/0x7 is -1, values from 3 to -1) is an index in the `RX AGC Gain Table`. The LNA short, LNA, MIXER, PGA gains are setup according to the current value from the table item pointed by the index. + +In `fix mode` the index is user configurable and doesn't change on its own. + +In `auto mode` the RF chip compares the signal strength (`REG_7E<11:6>`) to the high and low thresholds (`REG_49<13:7>`, `REG_49<6:0>`). If signal is higher than "high threshold" it decreases the `AGC fix index`, if it is lower than "low threshold" then it increases it. This way it tries to keep the signal strength between given threshold levels, thus preventing distortion and clipping. + +This is in theory. In practice there are some issues. At least in AM mode it doesn't work as it should. Lets assume we have a very strong signal. When AGC is in fix mode, index is set to 3, and value at index 3 is set to 0 the RSSI (read from other register) is around 170. When auto mode is activated (default values in gains table) the index goes to -1, gains at index -1 are 0, so we should get 170 as before. Instead we get RSSI over 300. All of this can be simulated using another radio, even if it only transmits in FM. + +Register `REG_7B<15:0>` also plays some role. When it is set to 0x8420 the RSSI will go down to 170 in the fix mode. But if 0x318C value is used it won't. + +Another thing, the index sometimes will go to -2 !!?? \ No newline at end of file