用单片机生成随机数算法,伪随机,使用姚老板的12c5a60s2芯片,详情见文档
输入[0,65536)
输出[0,65536)
-
-
-
U16 rand65536( CU16 seed )/*2018.04.13Python+excel验证*/
{
code U8 table[256] =
{
108,166,74,119,198,161,224,60,106,227,26,20,44,55,172,91,69,194,70,125,249,188,113,8,155,114,
205,37,63,47,57,217,177,71,244,65,52,61,132,123,196,242,43,73,12,187,247,151,184,81,90,255,
175,51,143,59,239,27,186,7,2,46,24,131,109,96,203,42,218,146,174,72,110,102,160,169,222,56,
207,13,180,250,116,67,171,84,100,9,137,6,129,141,154,240,122,202,219,163,130,216,75,135,221,98,
157,88,226,253,33,101,103,138,204,121,127,193,89,85,62,94,139,86,34,115,168,152,142,16,126,170,
120,15,76,10,147,29,183,4,148,40,66,32,87,105,124,214,162,140,234,235,68,104,220,92,167,212,
233,14,248,78,210,144,236,112,209,201,19,93,97,182,58,118,153,38,211,50,192,45,35,254,165,
0,229,237,25,208,1,23,17,158,21,95,195,164,223,243,48,199,181,145,53,228,83,190,117,5,
173,54,197,18,80,231,159,200,213,252,128,215,31,150,49,64,251,179,3,82,28,206,230,246,225,
11,36,149,136,245,22,232,30,238,185,191,176,241,77,39,156,41,99,189,134,79,133,178,111,107
};
auto xdata U16 t1, t2;
t1 = seed / 256;
t2 = seed % 256;
return( table[( t1 + t2 ) % 256 ] * 256 + table[ 255 - t2 ] );
}
问题是好的adc能做到dc下95%恒定率,其余5%也就+-1。。。
一周热门 更多>