Looking at this question: How to burn BT_FUSE_SEL on RT1050
there is some code that should enable burning of the BT_FUSE_SEL and FORCE_INTERNAL_BOOT fuses. However, when I try and do the re-calculation for ipg_clk of 150 MHz, I stumpled upon what I think is an error in the original code ?
I have a feeling that the timings above are not correct (or, very likely, I'm misunderstanding the numbers/calculations) ?
From the comments in the code from the link above, they are calculated for ipg_clk of 132 MHz, but if I calculate the resulting timing values using formulas in the Users Manual for 132 MHz also,
I get the following:
// Value at the start of line is [xx] which is number of nS at 132 MHz
// Timing values at 132 MHz:
// int timing = OCOTP_TIMING_STROBE_PROG(1325) | OCOTP_TIMING_RELAX(2) | OCOTP_TIMING_STROBE_READ(11) | OCOTP_TIMING_WAIT(24); // ipg_clk=132MHz, Calculation described at Chapter 22.4.3 OTP Read/Write Timing Parameters
//  WAIT = tSP_RD=(WAIT+1)/ipg_clk_freq, should be >= 150 ns
// [22.7] RELAX = tSP_PGM=tHP_PGM=(RELAX+1)/ipg_clk_freq, should be >= 100ns
//  STROBE_PROG = tPGM = [(STROBE_PROG+1) – 2×(RELAX_PROG+1)] / ipg_clk_freq (The tPGM should be configured within the range of 9000 ns < tPGM < 11000 ns, while its recommended value is 10000 ns)
// [30.3] STROBE_READ = tRD= [(STROBE_READ+1) – 2×(RELAX_READ+1)] / ipg_clk_freq (The tRD is required to be larger than 40 ns)
// [30.7] TIMING2.RELAX_READ = (RELAX_READ+1) / ipg_clk_freq, should be >= 10 ns.
//  TIMING2.RELAX_PROG = tSP_PG_AVDD = tHP_PG_AVDD = (RELAX_PROG+1)/ipg_clk_freq, should be >= 1000 ns.
// At default, RELAX_READ is 0x03 (3) and RELAX_PROG is 0x92 (146)
Using the numbers above, I get:
189 nS for the WAIT (must be >= 150 nS) so ok.
22.7 nS for the RELAX (must be >= 100 nS) so NOT ok
7818 nS for the STROBE_PROG (must be >9000 and <11000) so NOT ok
30.3 nS for STROBE_READ (must be > 40 nS) so NOT ok.
I have checked the RELAX_READ and RELAX_PROG in TIMING2 register, and they are 3 and 146.
Am I totally mis-calculating this, or is there something wrong in the original code ?