@@ -236,13 +236,19 @@ static void swdptap_linereset_measured(bool no_delay)
236236 /* for robustness, we use 60 HIGH cycles and 4 idle cycles */
237237 swd_proc .seq_out (0xffffffffU , 32U );
238238 swd_proc .seq_out (0x0fffffffU , 32U );
239+ swd_proc .seq_out (0xffffffffU , 32U );
240+ swd_proc .seq_out (0x0fffffffU , 32U );
241+ swd_proc .seq_out (0xffffffffU , 32U );
242+ swd_proc .seq_out (0x0fffffffU , 32U );
243+ swd_proc .seq_out (0xffffffffU , 32U );
244+ swd_proc .seq_out (0x0fffffffU , 32U );
239245 const uint32_t ts_post = dwt_read_cycle_counter ();
240246 const uint32_t cycles_spent = ts_post - ts_pre ;
241247 /* Subtract the overhead of function calls */
242- const uint32_t fncall_corr = no_delay ? (88U ) : (140U );
243- /* Split the *64 into 16*4 for 216-240MHz clocks to not overflow a uint32_t */
244- const uint32_t freq_measured = rcc_ahb_frequency * 16U / (cycles_spent - fncall_corr ) * 4U ;
245- gdb_outf ("Estimating %lu Hz (%lu cycles - %ld corr)\n" , freq_measured , cycles_spent , fncall_corr );
248+ const uint32_t fncall_corr = no_delay ? (243U ) : (133U );
249+ /* Split the 64*4 into 16*16 for 216-240MHz clocks to not overflow a uint32_t */
250+ const uint32_t freq_measured = rcc_ahb_frequency * 16U / (cycles_spent - fncall_corr ) * 16U ;
251+ gdb_outf ("Estimated %7lu Hz (%5lu cycles - %ld corr)\n" , freq_measured , cycles_spent , fncall_corr );
246252}
247253
248254static bool cmd_swdptap_calibration (target_s * target , int argc , const char * * argv )
0 commit comments