Bit layout for the freq_value is as follow:
http://s24.postimg.org/ftzr6e7w5/freq_value.jpgOD can have values between 0 and 3
R can have values between 0 and 31
F can have values between 0 and 127
BS can have only 0 or 1
From page 6 of BM1382 spec (
https://www.bitmaintech.com/files/download/BM1382_Datasheet_v3.0.pdf) you get:
NR = R + 1
NF = 2 * (F + 1)
NO value from OD value (see Table 4 from same spec page)
Fref = Fin / NR
Fvco = Fout * NO
Fout = Fin * NF / (NR*NO)
So Fout is "chip_freq" and can be calculated based on valued from above ("OD", "R" and "F"). BS select "high-band" or "low-band" (see page 7 from BM1382 spec for valid freq values for each band).
chip_freq = 50 * ( F + 1 ) / ( ( R + 1 ) * POWER( 2 , OD ) )
For timeout I used following formula:
timeout = 4000 / chip_freq
I suggest to calculate all 3 Fref, Fvco and Fout and make sure all 3 value are in range described on page 7 for the band specified by "BS" value.
Hi folks, given the above, I have thus calculated EVERY POSSIBLE valid frequency and register value. I don't know about the time out, so for that I just used JakeTri's timeout formula to get the time out and then took the integer value:
Assuming:
Fin = 25
Fref Fvco Chip Speed Register Value TimeOut
12.5 800 100.0000 0x 0 F 8 6 40
25.0 800 100.0000 0x 0 7 8 3 40
12.5 825 103.1250 0x 1 0 0 6 38
12.5 850 106.2500 0x 1 0 8 6 37
25.0 850 106.2500 0x 0 8 0 3 37
12.5 875 109.3750 0x 1 1 0 6 36
12.5 900 112.5000 0x 1 1 8 6 35
25.0 900 112.5000 0x 0 8 8 3 35
12.5 925 115.6250 0x 1 2 0 6 34
12.5 950 118.7500 0x 1 2 8 6 33
25.0 950 118.7500 0x 0 9 0 3 33
12.5 975 121.8750 0x 1 3 0 6 32
12.5 1000 125.0000 0x 1 3 8 6 32
25.0 1000 125.0000 0x 0 9 8 3 32
12.5 1025 128.1250 0x 1 4 0 6 31
12.5 1050 131.2500 0x 1 4 8 6 30
25.0 1050 131.2500 0x 0 A 0 3 30
12.5 1075 134.3750 0x 1 5 0 6 29
12.5 1100 137.5000 0x 1 5 8 6 29
25.0 1100 137.5000 0x 0 A 8 3 29
12.5 1125 140.6250 0x 1 6 0 6 28
12.5 1150 143.7500 0x 1 6 8 6 27
25.0 1150 143.7500 0x 0 B 0 3 27
12.5 1175 146.8750 0x 1 7 0 6 27
12.5 1200 150.0000 0x 1 7 8 6 26
25.0 1200 150.0000 0x 0 B 8 3 26
12.5 1225 153.1250 0x 1 8 0 6 26
12.5 1250 156.2500 0x 1 8 8 6 25
25.0 1250 156.2500 0x 0 C 0 3 25
12.5 1275 159.3750 0x 1 9 0 6 25
12.5 1300 162.5000 0x 1 9 8 6 24
25.0 1300 162.5000 0x 0 C 8 3 24
12.5 1325 165.6250 0x 1 A 0 6 24
12.5 1350 168.7500 0x 1 A 8 6 23
25.0 1350 168.7500 0x 0 D 0 3 23
12.5 1375 171.8750 0x 1 B 0 6 23
12.5 1400 175.0000 0x 1 B 8 6 22
25.0 1400 175.0000 0x 0 D 8 3 22
12.5 1425 178.1250 0x 1 C 0 6 22
12.5 1450 181.2500 0x 1 C 8 6 22
25.0 1450 181.2500 0x 0 E 0 3 22
12.5 1475 184.3750 0x 1 D 0 6 21
12.5 1500 187.5000 0x 1 D 8 6 21
25.0 1500 187.5000 0x 0 E 8 3 21
12.5 1525 190.6250 0x 1 E 0 6 20
12.5 1550 193.7500 0x 1 E 8 6 20
25.0 1550 193.7500 0x 0 F 0 3 20
12.5 1575 196.8750 0x 1 F 0 6 20
12.5 800 200.0000 0x 0 F 8 4 20
25.0 800 200.0000 0x 0 7 8 2 20
12.5 1600 200.0000 0x 1 F 8 6 20
25.0 1600 200.0000 0x 0 F 8 3 20
12.5 825 206.2500 0x 1 0 0 4 19
25.0 1650 206.2500 0x 5 0 0 3 19
12.5 850 212.5000 0x 1 0 8 4 18
25.0 850 212.5000 0x 0 8 0 2 18
25.0 1700 212.5000 0x 5 0 8 3 18
12.5 875 218.7500 0x 1 1 0 4 18
25.0 1750 218.7500 0x 5 1 0 3 18
12.5 900 225.0000 0x 1 1 8 4 17
25.0 900 225.0000 0x 0 8 8 2 17
25.0 1800 225.0000 0x 5 1 8 3 17
12.5 925 231.2500 0x 1 2 0 4 17
25.0 1850 231.2500 0x 5 2 0 3 17
12.5 950 237.5000 0x 1 2 8 4 16
25.0 950 237.5000 0x 0 9 0 2 16
25.0 1900 237.5000 0x 5 2 8 3 16
12.5 975 243.7500 0x 1 3 0 4 16
25.0 1950 243.7500 0x 5 3 0 3 16
12.5 1000 250.0000 0x 1 3 8 4 16
25.0 1000 250.0000 0x 0 9 8 2 16
25.0 2000 250.0000 0x 5 3 8 3 16
12.5 1025 256.2500 0x 1 4 0 4 15
25.0 2050 256.2500 0x 5 4 0 3 15
12.5 1050 262.5000 0x 1 4 8 4 15
25.0 1050 262.5000 0x 0 A 0 2 15
25.0 2100 262.5000 0x 5 4 8 3 15
12.5 1075 268.7500 0x 1 5 0 4 14
25.0 2150 268.7500 0x 5 5 0 3 14
12.5 1100 275.0000 0x 1 5 8 4 14
25.0 1100 275.0000 0x 0 A 8 2 14
25.0 2200 275.0000 0x 5 5 8 3 14
12.5 1125 281.2500 0x 1 6 0 4 14
25.0 2250 281.2500 0x 5 6 0 3 14
12.5 1150 287.5000 0x 1 6 8 4 13
25.0 1150 287.5000 0x 0 B 0 2 13
25.0 2300 287.5000 0x 5 6 8 3 13
12.5 1175 293.7500 0x 1 7 0 4 13
25.0 2350 293.7500 0x 5 7 0 3 13
12.5 1200 300.0000 0x 1 7 8 4 13
25.0 1200 300.0000 0x 0 B 8 2 13
25.0 2400 300.0000 0x 5 7 8 3 13
12.5 1225 306.2500 0x 1 8 0 4 13
25.0 2450 306.2500 0x 5 8 0 3 13
12.5 1250 312.5000 0x 1 8 8 4 12
25.0 1250 312.5000 0x 0 C 0 2 12
25.0 2500 312.5000 0x 5 8 8 3 12
12.5 1275 318.7500 0x 1 9 0 4 12
25.0 2550 318.7500 0x 5 9 0 3 12
12.5 1300 325.0000 0x 1 9 8 4 12
25.0 1300 325.0000 0x 0 C 8 2 12
25.0 2600 325.0000 0x 5 9 8 3 12
12.5 1325 331.2500 0x 1 A 0 4 12
25.0 2650 331.2500 0x 5 A 0 3 12
12.5 1350 337.5000 0x 1 A 8 4 11
25.0 1350 337.5000 0x 0 D 0 2 11
25.0 2700 337.5000 0x 5 A 8 3 11
12.5 1375 343.7500 0x 1 B 0 4 11
25.0 2750 343.7500 0x 5 B 0 3 11
12.5 1400 350.0000 0x 1 B 8 4 11
25.0 1400 350.0000 0x 0 D 8 2 11
25.0 2800 350.0000 0x 5 B 8 3 11
12.5 1425 356.2500 0x 1 C 0 4 11
25.0 2850 356.2500 0x 5 C 0 3 11
12.5 1450 362.5000 0x 1 C 8 4 11
25.0 1450 362.5000 0x 0 E 0 2 11
25.0 2900 362.5000 0x 5 C 8 3 11
12.5 1475 368.7500 0x 1 D 0 4 10
25.0 2950 368.7500 0x 5 D 0 3 10
12.5 1500 375.0000 0x 1 D 8 4 10
25.0 1500 375.0000 0x 0 E 8 2 10
25.0 3000 375.0000 0x 5 D 8 3 10
12.5 1525 381.2500 0x 1 E 0 4 10
12.5 1550 387.5000 0x 1 E 8 4 10
25.0 1550 387.5000 0x 0 F 0 2 10
12.5 1575 393.7500 0x 1 F 0 4 10
12.5 800 400.0000 0x 0 F 8 2 10
25.0 800 400.0000 0x 0 7 8 1 10
12.5 1600 400.0000 0x 1 F 8 4 10
25.0 1600 400.0000 0x 0 F 8 2 10
For the above paste, in the interest of space I only presented speeds up to 400.
Note that if the frequency does not show on this list, it does NOT exist, (except for ones above 400mhz) as these values were calculated from EVERY possible binary value of the register, then filtered for valid values based on the criteria in the datasheet.
I do not know the implications of the Fref and Fvco values, so I sorted everything from lowest to highest. For a clock speed of 200mhz is it best to use a Fvco of 800 or 1600? furthermore, within those results, is it best for Fref to be 12.5 or 25? Given BitMain's example in the datasheet, evidence would suggest they want us sticking in the low range bank, with Fref=25. If there's any good reason for that then that reduces the possibilities to:
Fvco Chip Speed Register Value TimeOut
800 100.0000 0x 0 7 8 3 40
850 106.2500 0x 0 8 0 3 37
900 112.5000 0x 0 8 8 3 35
950 118.7500 0x 0 9 0 3 33
1000 125.0000 0x 0 9 8 3 32
1050 131.2500 0x 0 A 0 3 30
1100 137.5000 0x 0 A 8 3 29
1150 143.7500 0x 0 B 0 3 27
1200 150.0000 0x 0 B 8 3 26
1250 156.2500 0x 0 C 0 3 25
1300 162.5000 0x 0 C 8 3 24
1350 168.7500 0x 0 D 0 3 23
1400 175.0000 0x 0 D 8 3 22
1450 181.2500 0x 0 E 0 3 22
1500 187.5000 0x 0 E 8 3 21
1550 193.7500 0x 0 F 0 3 20
800 200.0000 0x 0 7 8 2 20
1600 200.0000 0x 0 F 8 3 20
850 212.5000 0x 0 8 0 2 18
900 225.0000 0x 0 8 8 2 17
950 237.5000 0x 0 9 0 2 16
1000 250.0000 0x 0 9 8 2 16
1050 262.5000 0x 0 A 0 2 15
1100 275.0000 0x 0 A 8 2 14
1150 287.5000 0x 0 B 0 2 13
1200 300.0000 0x 0 B 8 2 13
1250 312.5000 0x 0 C 0 2 12
1300 325.0000 0x 0 C 8 2 12
1350 337.5000 0x 0 D 0 2 11
1400 350.0000 0x 0 D 8 2 11
1450 362.5000 0x 0 E 0 2 11
1500 375.0000 0x 0 E 8 2 10
1550 387.5000 0x 0 F 0 2 10
800 400.0000 0x 0 7 8 1 10
1600 400.0000 0x 0 F 8 2 10
But i imagine people are willing to try other than just these values, since folks are asking for speeds between 237.5 and 250 (the only one is 243.75 but with two options) and i assume 243.75 has been tried/tested by now?
I can post my excel file so people can check my work, and/or if people want to see valid chip speeds up to 3000mhz (i'm pretty sure you will NOT be able to run at 3000mhz! so don't get any bright ideas)
If any of this proves useful, feel free to donate BTC at 1Lq8HMwSCR65RpApfYmWpCrP5wobsbcLDE