Skip to content

Commit ba3d9e2

Browse files
authored
Merge pull request #1836 from weebl2000/fix-rak3401-sky66122-11-fem
Fix RAK3401 SKY66122-11 FEM control: enable CSD/CPS for proper PA/LNA operation
2 parents d7ad890 + 49d8313 commit ba3d9e2

4 files changed

Lines changed: 34 additions & 18 deletions

File tree

variants/rak3401/RAK3401Board.cpp

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,29 @@ void RAK3401Board::begin() {
2020

2121
Wire.begin();
2222

23+
// PIN_3V3_EN (WB_IO2, P0.34) controls the 3V3_S switched peripheral rail
24+
// AND the 5V boost regulator (U5) on the RAK13302 that powers the SKY66122 PA.
25+
// Must stay HIGH during radio operation — do not toggle for power saving.
2326
pinMode(PIN_3V3_EN, OUTPUT);
2427
digitalWrite(PIN_3V3_EN, HIGH);
2528

26-
#ifdef P_LORA_PA_EN
27-
// Initialize RAK13302 1W LoRa transceiver module PA control pin
28-
pinMode(P_LORA_PA_EN, OUTPUT);
29-
digitalWrite(P_LORA_PA_EN, LOW); // Start with PA disabled
30-
delay(10); // Allow PA module to initialize
29+
// Enable SKY66122-11 FEM on the RAK13302 module.
30+
// CSD and CPS are tied together on the RAK13302 PCB, routed to IO3 (P0.21).
31+
// HIGH = FEM active (LNA for RX, PA path available for TX).
32+
// TX/RX switching (CTX) is handled by SX1262 DIO2 via SetDIO2AsRfSwitchCtrl.
33+
pinMode(SX126X_POWER_EN, OUTPUT);
34+
digitalWrite(SX126X_POWER_EN, HIGH);
35+
delay(1); // SKY66122 turn-on settling time (tON = 3us typ)
36+
}
37+
38+
#ifdef NRF52_POWER_MANAGEMENT
39+
void RAK3401Board::initiateShutdown(uint8_t reason) {
40+
// Disable SKY66122 FEM (CSD+CPS LOW = shutdown, <1 uA)
41+
digitalWrite(SX126X_POWER_EN, LOW);
42+
43+
// Disable 3V3 switched peripherals and 5V boost
44+
digitalWrite(PIN_3V3_EN, LOW);
45+
46+
enterSystemOff(reason);
47+
}
3148
#endif
32-
}

variants/rak3401/RAK3401Board.h

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,6 @@ class RAK3401Board : public NRF52BoardDCDC {
3838
return "RAK 3401";
3939
}
4040

41-
#ifdef P_LORA_PA_EN
42-
void onBeforeTransmit() override {
43-
digitalWrite(P_LORA_PA_EN, HIGH); // Enable PA before transmission
44-
}
45-
46-
void onAfterTransmit() override {
47-
digitalWrite(P_LORA_PA_EN, LOW); // Disable PA after transmission to save power
48-
}
49-
#endif
41+
// TX/RX switching is handled by SX1262 DIO2 -> SKY66122 CTX (hardware-timed).
42+
// No onBeforeTransmit/onAfterTransmit overrides needed.
5043
};

variants/rak3401/platformio.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ build_flags = ${nrf52_base.build_flags}
1111
-D LORA_TX_POWER=22
1212
-D SX126X_CURRENT_LIMIT=140
1313
-D SX126X_RX_BOOSTED_GAIN=1
14+
-D SX126X_REGISTER_PATCH=1 ; Patch register 0x8B5 for improved RX with SKY66122 FEM
1415
build_src_filter = ${nrf52_base.build_src_filter}
1516
+<../variants/rak3401>
1617
+<helpers/sensors>

variants/rak3401/variant.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,15 @@ static const uint8_t AREF = PIN_AREF;
147147
#define SX126X_BUSY (9)
148148
#define SX126X_RESET (4)
149149

150-
#define SX126X_POWER_EN (21)
151-
// DIO2 controlls an antenna switch and the TCXO voltage is controlled by DIO3
150+
// SKY66122-11 FEM control on the RAK13302 module:
151+
// CSD + CPS are tied together on the PCB, routed to WisBlock IO3 (P0.21).
152+
// Setting IO3 HIGH enables the FEM (LNA for RX, PA path for TX).
153+
// CTX is connected to SX1262 DIO2 — the radio handles TX/RX switching
154+
// in hardware via SetDIO2AsRfSwitchCtrl (microsecond-accurate, no GPIO needed).
155+
// The 5V boost for the PA is enabled by WB_IO2 (P0.34 = PIN_3V3_EN).
156+
#define SX126X_POWER_EN (21) // P0.21 = IO3 -> SKY66122 CSD+CPS (FEM enable)
157+
158+
// CTX is driven by SX1262 DIO2, not a GPIO
152159
#define SX126X_DIO2_AS_RF_SWITCH
153160
#define SX126X_DIO3_TCXO_VOLTAGE 1.8
154161

@@ -159,7 +166,6 @@ static const uint8_t AREF = PIN_AREF;
159166
#define P_LORA_DIO_1 SX126X_DIO1
160167
#define P_LORA_BUSY SX126X_BUSY
161168
#define P_LORA_RESET SX126X_RESET
162-
#define P_LORA_PA_EN 31
163169

164170
// enables 3.3V periphery like GPS or IO Module
165171
// Do not toggle this for GPS power savings

0 commit comments

Comments
 (0)