From 86dfdfff895d0403f5d2259920dcca795fb1ebe9 Mon Sep 17 00:00:00 2001 From: dxl <64101226@qq.com> Date: Thu, 20 Aug 2026 00:34:16 +0800 Subject: [PATCH] Fixed a bug in reading hitagU and hitagS on RDV4. --- common_arm/ticks/ticks_hw_at91.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/common_arm/ticks/ticks_hw_at91.c b/common_arm/ticks/ticks_hw_at91.c index b1c186aa3..987bc95fd 100644 --- a/common_arm/ticks/ticks_hw_at91.c +++ b/common_arm/ticks/ticks_hw_at91.c @@ -272,10 +272,12 @@ uint16_t RAMFUNC GetLoEdgeCaptureCount(void) { } lo_edge_t RAMFUNC GetLoEdgeCaptureStatus(void) { - if (AT91C_BASE_TC1->TC_SR & INPUT_CAPTURE_EVT_RISING_EDGE) { + // Read Once Only: Reading TC_SR will simultaneously clear status bits such as LDRAS/LDRBS. + uint32_t sr = AT91C_BASE_TC1->TC_SR; + if (sr & INPUT_CAPTURE_EVT_RISING_EDGE) { return LO_EDGE_RISING; } - if (AT91C_BASE_TC1->TC_SR & INPUT_CAPTURE_EVT_FALLING_EDGE) { + if (sr & INPUT_CAPTURE_EVT_FALLING_EDGE) { return LO_EDGE_FALLING; } return LO_EDGE_NO;