Tighten up non-reading TCB0 ISR timing

This commit is contained in:
Allen Hill
2026-08-13 16:27:22 -07:00
parent f45a0f5e92
commit 95dae572a0
+9 -6
View File
@@ -225,15 +225,18 @@ ISR(TCB0_INT_vect) {
// last_tcb1 = cur_tcb1;
// #endif
READING_BYTE <<= 1;
// If the logical `0` pulse was less than the sync + data period threshold,
// bit was a 1
pulsewidth = TCB0.CCMP;
if (pulsewidth < (uint16_t)AVCLAN_READBIT_THRESHOLD) {
READING_BYTE++;
READING_PARITY++;
uint16_t tmp = pulsewidth = TCB0.CCMP; // non-volatile tmp saves re-read in
// read-bit-threshold comparison
if (READING_NBITS) {
READING_BYTE <<= 1;
if (tmp < (uint16_t)AVCLAN_READBIT_THRESHOLD) {
READING_BYTE++;
READING_PARITY++;
}
READING_NBITS--;
}
READING_NBITS--;
}
// Read `len` bits on the AVCLAN bus; returns the even parity