Skip to content

Commit 3ac22ff

Browse files
committed
Adjust RX TOCK to later in period for low duty cycle rates
1 parent a7cb9c4 commit 3ac22ff

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/src/rx_main.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -707,8 +707,6 @@ void ICACHE_RAM_ATTR updatePhaseLock()
707707

708708
void ICACHE_RAM_ATTR HWtimerCallbackTick() // this is 180 out of phase with the other callback, occurs mid-packet reception
709709
{
710-
updatePhaseLock();
711-
712710
if (ExpressLRS_currAirRate_Modparams->numOfSends == 1)
713711
{
714712
// Save the LQ value before the inc() reduces it by 1
@@ -853,6 +851,7 @@ void ICACHE_RAM_ATTR HWtimerCallbackTock()
853851
OtaNonce++;
854852
updateDiversity();
855853
tlmSent = HandleSendTelemetryResponse();
854+
updatePhaseLock();
856855

857856
#if defined(DEBUG_RX_SCOREBOARD)
858857
static bool lastPacketWasTelemetry = false;
@@ -1171,7 +1170,12 @@ bool ICACHE_RAM_ATTR ProcessRFPacket(SX12xxDriverCommon::rx_status const status)
11711170
return false;
11721171
}
11731172

1174-
PFDloop.extEvent(beginProcessing + PACKET_TO_TOCK_SLACK);
1173+
// The extEvent defines where TOCK timer ISR is to be synced to, i.e. where the packet period begins.
1174+
// For rates where the TOA is longer than half the packet period schedule the TOCK for rougly 1x TOA before
1175+
// the TX's end of the period so telemetry is received by the TX in the correct period. For all others,
1176+
// schedule TOCK to be PACKET_TO_TOCK_SLACK (us) after RX packet reception.
1177+
int32_t slack = std::max(ExpressLRS_currAirRate_Modparams->interval - 2 * ExpressLRS_currAirRate_RFperfParams->TOA, (int32_t)PACKET_TO_TOCK_SLACK);
1178+
PFDloop.extEvent(beginProcessing + slack);
11751179

11761180
doStartTimer = false;
11771181
unsigned long now = millis();

0 commit comments

Comments
 (0)