PM5: zero-init TMR2 input config in StartCountSspClk
StartCountSspClk() declared its tmr_input_config_type on the stack without initialising it and never set input_filter_value. tmr_input_channel_init() copies that field into TMR2 CM1.C2DF, so the digital input filter on the ssp_clk pin took whatever low nibble was left on the stack, and could change from call to call depending on the caller's stack contents. TMR2 is clocked by that filtered input (C2DF2, external clock mode A), so the filter decides which ssp_clk edges get counted. With fDTS at 288 MHz, filter values around 13 need ~556 ns of stable input against a ~590 ns ssp_clk half period (fc/16 in 14a reader modes). Edges are then dropped some of the time, and 14-15 drop every edge. In sniffer mode (fc/8) values from about 10 already break. Lost ticks delay frame timing derived from GetCountSspClk() (ReaderTransmit timing, sync_time loops) by a varying amount. This shows up as random nonce distance jitter and slow distance calibration in hf mf nested/autopwn on PM5. Zero-initialise the struct so the filter is off (C2DF = 0), matching StartLoEdgeCapture() in the same file. Reported by @adrian-stepien in #3709. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
74aded1d28
commit
4c9be69148
2 files changed
+2
-1
No files matched your search
@@ -180,7 +180,7 @@ void StartCountSspClk(void) {
|
||||
gpio_pin_mux_config(CRM_GPIO_COUNT_SSP_CLK, CRM_GPIO_COUNT_SSP_CLK_SOURCE, CRM_GPIO_COUNT_SSP_CLK_MUX); // important !!! remap gpio to be timer EXT(CHx) function.
|
||||
|
||||
// timer init
|
||||
tmr_input_config_type tmr_input_config_struct;
|
||||
tmr_input_config_type tmr_input_config_struct = {0};
|
||||
tmr_input_config_struct.input_channel_select = AT32_TMR_COUNT_SSP_CLK_IN_CH;
|
||||
tmr_input_config_struct.input_mapped_select = TMR_CC_CHANNEL_MAPPED_DIRECT;
|
||||
tmr_input_config_struct.input_polarity_select = TMR_INPUT_RISING_EDGE;
|
||||
|
||||
Reference in new issue
Block a user