Skip to content

Commit 593fbee

Browse files
committed
Fix RAK3401 SKY66122-11 FEM control: enable CSD/CPS for proper PA and LNA operation
The RAK13302 1W module uses a Skyworks SKY66122-11 front-end module with three digital control pins (CSD, CTX, CPS) that must be actively driven by the host MCU. The previous code only managed CTX (GPIO 31) — toggling it for TX/RX — but never initialized CSD (GPIO 24) or CPS (GPIO 21), leaving them floating with no pull-up/pull-down resistors on the PCB. With floating CSD and CPS, the SKY66122 was in an undefined operating mode: - The 30 dB TX PA may not have been reliably engaging - The 16 dB RX LNA was never reliably active, degrading receive sensitivity
1 parent f4748a7 commit 593fbee

3 files changed

Lines changed: 41 additions & 12 deletions

File tree

variants/rak3401/RAK3401Board.cpp

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,33 @@ void RAK3401Board::begin() {
2323
pinMode(PIN_3V3_EN, OUTPUT);
2424
digitalWrite(PIN_3V3_EN, HIGH);
2525

26-
#ifdef P_LORA_PA_EN
27-
// Initialize RAK13302 1W LoRa transceiver module PA control pin
26+
// Initialize SKY66122-11 FEM on the RAK13302 module.
27+
// CSD (P0.24) and CPS (P0.21) must be HIGH for both TX and RX modes.
28+
// CTX (P0.31) selects TX(HIGH) vs RX(LOW) and also enables the 5V boost
29+
// converter that powers the PA section (VCC1/VCC2).
30+
// The LNA section (VSUP1/VCC0) runs on 3.3V and works with boost off.
31+
pinMode(P_LORA_PA_CSD, OUTPUT);
32+
digitalWrite(P_LORA_PA_CSD, HIGH); // CSD=1: enable FEM
33+
34+
pinMode(SX126X_POWER_EN, OUTPUT);
35+
digitalWrite(SX126X_POWER_EN, HIGH); // CPS=1: enable TX/RX paths
36+
2837
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
38+
digitalWrite(P_LORA_PA_EN, LOW); // CTX=0: RX mode, boost off
39+
40+
delay(1); // SKY66122 turn-on settling time
41+
}
42+
43+
#ifdef NRF52_POWER_MANAGEMENT
44+
void RAK3401Board::initiateShutdown(uint8_t reason) {
45+
// Put SKY66122 in guaranteed <1 uA shutdown (Mode 4: CSD=0, CTX=0, CPS=0)
46+
digitalWrite(P_LORA_PA_EN, LOW); // CTX=0, boost off
47+
digitalWrite(SX126X_POWER_EN, LOW); // CPS=0
48+
digitalWrite(P_LORA_PA_CSD, LOW); // CSD=0
49+
50+
// Disable 3V3 switched peripherals
51+
digitalWrite(PIN_3V3_EN, LOW);
52+
53+
enterSystemOff(reason);
54+
}
3155
#endif
32-
}

variants/rak3401/RAK3401Board.h

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

41-
#ifdef P_LORA_PA_EN
41+
// SKY66122 FEM TX/RX switching via CTX pin.
42+
// CTX=HIGH: TX mode + 5V boost ON (PA powered from VCC1/VCC2)
43+
// CTX=LOW: RX mode + 5V boost OFF (LNA powered from VSUP1 at 3.3V)
4244
void onBeforeTransmit() override {
43-
digitalWrite(P_LORA_PA_EN, HIGH); // Enable PA before transmission
45+
digitalWrite(P_LORA_PA_EN, HIGH); // CTX=1: TX mode, boost on
4446
}
4547

4648
void onAfterTransmit() override {
47-
digitalWrite(P_LORA_PA_EN, LOW); // Disable PA after transmission to save power
49+
digitalWrite(P_LORA_PA_EN, LOW); // CTX=0: RX mode, boost off
4850
}
49-
#endif
5051
};

variants/rak3401/variant.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,14 @@ 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 pins (active HIGH, active LOW = shutdown <1uA)
151+
// CSD+CPS must be HIGH for TX and RX; CTX selects TX(HIGH) vs RX(LOW)
152+
// CTX also enables the 5V boost converter for the PA during TX
153+
#define P_LORA_PA_CSD (24) // P0.24 -> SKY66122 CSD (pin 11) - FEM enable
154+
#define SX126X_POWER_EN (21) // P0.21 -> SKY66122 CPS (pin 1) - path select
155+
#define P_LORA_PA_EN (31) // P0.31 -> SKY66122 CTX (pin 2) - TX/RX + boost EN
156+
157+
// DIO2 has a NC 0R footprint (R25) to CTX; not connected by default
152158
#define SX126X_DIO2_AS_RF_SWITCH
153159
#define SX126X_DIO3_TCXO_VOLTAGE 1.8
154160

@@ -159,7 +165,6 @@ static const uint8_t AREF = PIN_AREF;
159165
#define P_LORA_DIO_1 SX126X_DIO1
160166
#define P_LORA_BUSY SX126X_BUSY
161167
#define P_LORA_RESET SX126X_RESET
162-
#define P_LORA_PA_EN 31
163168

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

0 commit comments

Comments
 (0)