TMR0 timing off 4x (Fosc/4 not Fosc) and tx_emulator baud rate hardcoded #24
Labels
No labels
bug
duplicate
enhancement
help wanted
invalid
question
wait-to-fix
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
daru/PICsense#24
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The firmware Timer0 formula
256 - (_XTAL_FREQ / (TX_BAUD * 2))assumed Fosc as the Timer0 clock source, but PIC12LF1840 Timer0 uses Fosc/4 (Section 20.1, Figure 20-1 of the datasheet). At 500kHz Fosc this means 125kHz Timer0 clock, 8μs ticks instead of 2μs, resulting in 500 bps actual data rate instead of the intended 2000 bps. The rtl_433 decoder and tx_emulator were both configured for 2000 bps, so none of the three components were actually aligned. Fix: divide by 4 in the TMR0_RELOAD formula (131→225, half-bit 1000μs→248μs). Also add--tx-baudCLI argument to tx_emulator to derive its half-bit rate from the firmware's TX_BAUD instead of hardcoding 4000.