From 53ed757fe867851b9dd19da0cb545de3d9fc7774 Mon Sep 17 00:00:00 2001 From: Terry Moore Date: Tue, 6 Feb 2018 22:33:36 -0500 Subject: [PATCH] Fix programming of RegPaConfig bits 3:0 (issue #50) --- src/lmic/radio.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/lmic/radio.c b/src/lmic/radio.c index abad6ef6..c3114e1b 100644 --- a/src/lmic/radio.c +++ b/src/lmic/radio.c @@ -423,15 +423,19 @@ static void configChannel () { static void configPower () { #ifdef CFG_sx1276_radio - // no boost used for now + // PA_BOOST output is assumed but not 20 dBm. s1_t pw = (s1_t)LMIC.txpow; - if(pw >= 17) { - pw = 15; + if(pw > 17) { + pw = 17; } else if(pw < 2) { pw = 2; } - // check board type for BOOST pin - writeReg(RegPaConfig, (u1_t)(0x80|(pw&0xf))); + // 0x80 forces use of PA_BOOST; but we don't + // turn on 20 dBm mode. So powers are: + // 0000 => 2dBm, 0001 => 3dBm, ... 1111 => 17dBm + // But we also enforce that the high-power mode + // is off by writing RegPaDac. + writeReg(RegPaConfig, (u1_t)(0x80|(pw - 2))); writeReg(RegPaDac, readReg(RegPaDac)|0x4); #elif CFG_sx1272_radio