]> git.tnoah.ca Git - lora-radio.git/commitdiff
SX1262 calibration in RC mode
authorMark Qvist <mark@unsigned.io>
Sun, 11 Feb 2024 19:02:17 +0000 (20:02 +0100)
committerMark Qvist <mark@unsigned.io>
Sun, 11 Feb 2024 19:02:17 +0000 (20:02 +0100)
Release/console_image.bin
sx126x.cpp

index b02795a1e0ad17ea0938693d5c3841f5b5b22e29..5ccbbbaaa5f4c3f3de254b3337a9c529be0a156e 100644 (file)
Binary files a/Release/console_image.bin and b/Release/console_image.bin differ
index d2b2f3b7f714e5da5521c9e7cec14774cdebd2cf..7587e3bd59b3ec238b8cf3fe4cedd86bffdc267f 100644 (file)
@@ -365,17 +365,27 @@ int sx126x::begin(long frequency)
     }
   }
 
-  loraMode();
-  // cannot access registers in sleep mode on sx1262, set to idle instead
-  idle();
+  if (_rxen != -1) {
+      pinMode(_rxen, OUTPUT);
+  }
+
+  // Put in STDBY_RC mode before calibration
+  uint8_t mode_byte = 0x00;
+  executeOpcode(OP_STANDBY_6X, &mode_byte, 1); 
+
+  // calibrate RC64k, RC13M, PLL, ADC and image
+  uint8_t calibrate = 0x7F; 
+  executeOpcode(OP_CALIBRATE_6X, &calibrate, 1);
 
   #if HAS_TCXO
     enableTCXO();
   #endif
 
-  if (_rxen != -1) {
-      pinMode(_rxen, OUTPUT);
-  }
+  loraMode();
+  idle();
+
+  // Set sync word
+  setSyncWord(SYNC_WORD_6X);
 
   #if DIO2_AS_RF_SWITCH
     // enable dio2 rf switch
@@ -385,13 +395,6 @@ int sx126x::begin(long frequency)
 
   rxAntEnable();
 
-  // Set sync word
-  setSyncWord(SYNC_WORD_6X);
-
-  // calibrate RC64k, RC13M, PLL, ADC and image
-  uint8_t calibrate = 0x7F; 
-  executeOpcode(OP_CALIBRATE_6X, &calibrate, 1);
-
   setFrequency(frequency);
 
   // set output power to 2 dBm