/*基于52单片机程序在示波器上显示一个模拟时钟*/
#include
#define uchar unsigned char
#define uint unsigned int
***it cs=P2^2;
***it scl=P2^1;
***it din=P2^0;
//***it led=P2^0;
//void delaym()
//{;;;;}
uint code tableB[]={
3822,3811,3780,3728,3656,3565,3457,3331,3189,3034,2866,2688,2501,2308,2110,1911,
1711,1513,1320,1133,955,787,632,490,364,256,165,93,41,10,0,10,41,93,165,256,364,
490,632,787,955,1133,1320,1513,1711,1910,2110,2308,2501,2688,2866,3034,3189,3331,
3457,3565,3656,3728,3780,3811,1911};
uint code tableA[]={
1911,2110,2308,2501,2688,2866,3034,3189,3331,3457,3565,3656,3728,3780,3811,3821,
3811,3780,3728,3656,3565,3457,3331,3189,3034,2866,2688,2501,2308,2110,1911,1711,
1513,1320,1133,955,787,632,490,364,256,165,93,41,10,0,10,41,93,165,256,364,490,632,
787,955,1133,1320,1513,1711,1911};
uint code tableshiX[5][60]={
{2006,2005,2004,2001,1998,1993,1988,1981,1974,1967,1958,1949,1940,1930,1920,1911,
1901,1891,1881,1872,1863,1854,1847,1840,1833,1828,1823,1820,1817,1816,1815,1816,
1817,1820,1823,1828,1833,1840,1847,1854,1863,1872,1881,1891,1901,1910,1920,1930,
1940,1949,1958,1967,1974,1981,1988,1993,1998,2001,2004,2005},
{2197,2195,2191,2183,2172,2159,2142,2123,2102,2079,2054,2027,1999,1970,1940,1911,
1881,1851,1822,1794,1767,1742,1719,1698,1679,1662,1649,1638,1630,1626,1624,1626,
1630,1638,1649,1662,1679,1698,1719,1742,1767,1794,1822,1851,1881,1910,1940,1970,
1999,2027,2054,2079,2102,2123,2142,2159,2172,2183,2191,2195},
{2388,2385,2378,2365,2347,2324,2297,2265,2230,2191,2149,2105,2058,2010,1960,1911,
1861,1811,1763,1716,1672,1630,1591,1556,1524,1497,1474,1456,1443,1436,1433,1436,
1443,1456,1474,1497,1524,1556,1591,1630,1672,1716,1763,1811,1861,1910,1960,2010,
2058,2105,2149,2191,2230,2265,2297,2324,2347,2365,2378,2385},
{2579,2575,2564,2546,2521,2489,2451,2407,2358,2303,2245,2182,2117,2049,1980,1911,
1841,1772,1704,1639,1576,1518,1463,1414,1370,1332,1300,1275,1257,1246,1242,1246,
1257,1275,1300,1332,1370,1414,1463,1518,1576,1639,1704,1772,1841,1910,1980,2049,
2117,2182,2245,2303,2358,2407,2451,2489,2521,2546,2564,2575},
{2770,2765,2751,2728,2696,2655,2606,2549,2486,2416,2340,2260,2176,2089,2000,1911,
1821,1732,1645,1561,1481,1405,1335,1272,1215,1166,1125,1093,1070,1056,1051,1056,
1070,1093,1125,1166,1215,1272,1335,1405,1481,1561,1645,1732,1821,1910,2000,2089,
2176,2260,2340,2416,2486,2549,2606,2655,2696,2728,2751,2765}};
uint code tableshiY[5][60]={
{1911,1920,1930,1940,1949,1958,1967,1974,1981,1988,1993,1998,2001,2004,2005,2006,
2005,2004,2001,1998,1993,1988,1981,1974,1967,1958,1949,1940,1930,1920,1911,1901,
1891,1881,1872,1863,1854,1847,1840,1833,1828,1823,1820,1817,1816,1815,1816,1817,
1820,1823,1828,1833,1840,1847,1854,1863,1872,1881,1891,1901},
{1911,1940,1970,1999,2027,2054,2079,2102,2123,2142,2159,2172,2183,2191,2195,2197,
2195,2191,2183,2172,2159,2142,2123,2102,2079,2054,2027,1999,1970,1940,1911,1881,
1851,1822,1794,1767,1742,1719,1698,1679,1662,1649,1638,1630,1626,1624,1626,1630,
1638,1649,1662,1679,1698,1719,1742,1767,1794,1822,1851,1881},
{1911,1960,2010,2058,2105,2149,2191,2230,2265,2297,2324,2347,2365,2378,2385,2388,
2385,2378,2365,2347,2324,2297,2265,2230,2191,2149,2105,2058,2010,1960,1911,1861,
1811,1763,1716,1672,1630,1591,1556,1524,1497,1474,1456,1443,1436,1433,1436,1443,
1456,1474,1497,1524,1556,1591,1630,1672,1716,1763,1811,1861},
{1911,1980,2049,2117,2182,2245,2303,2358,2407,2451,2489,2521,2546,2564,2575,2579,
2575,2564,2546,2521,2489,2451,2407,2358,2303,2245,2182,2117,2049,1980,1911,1841,
1772,1704,1639,1576,1518,1463,1414,1370,1332,1300,1275,1257,1246,1242,1246,1257,
1275,1300,1332,1370,1414,1463,1518,1576,1639,1704,1772,1841},
{1911,2000,2089,2176,2260,2340,2416,2486,2549,2606,2655,2696,2728,2751,2765,2770,
2765,2751,2728,2696,2655,2606,2549,2486,2416,2340,2260,2176,2089,2000,1911,1821,
1732,1645,1561,1481,1405,1335,1272,1215,1166,1125,1093,1070,1056,1051,1056,1070,
1093,1125,1166,1215,1272,1335,1405,1481,1561,1645,1732,1821}};
uint code tablefenX[8][60]={
{2006,2005,2004,2001,1998,1993,1988,1981,1974,1967,1958,1949,1940,1930,1920,1911,
1901,1891,1881,1872,1863,1854,1847,1840,1833,1828,1823,1820,1817,1816,1815,1816,
1817,1820,1823,1828,1833,1840,1847,1854,1863,1872,1881,1891,1901,1910,1920,1930,
1940,1949,1958,1967,1974,1981,1988,1993,1998,2001,2004,2005},
{2197,2195,2191,2183,2172,2159,2142,2123,2102,2079,2054,2027,1999,1970,1940,1911,
1881,1851,1822,1794,1767,1742,1719,1698,1679,1662,1649,1638,1630,1626,1624,1626,
1630,1638,1649,1662,1679,1698,1719,1742,1767,1794,1822,1851,1881,1910,1940,1970,
1999,2027,2054,2079,2102,2123,2142,2159,2172,2183,2191,2195},
{2388,2385,2378,2365,2347,2324,2297,2265,2230,2191,2149,2105,2058,2010,1960,1911,
1861,1811,1763,1716,1672,1630,1591,1556,1524,1497,1474,1456,1443,1436,1433,1436,
1443,1456,1474,1497,1524,1556,1591,1630,1672,1716,1763,1811,1861,1910,1960,2010,
2058,2105,2149,2191,2230,2265,2297,2324,2347,2365,2378,2385},
{2579,2575,2564,2546,2521,2489,2451,2407,2358,2303,2245,2182,2117,2049,1980,1911,
1841,1772,1704,1639,1576,1518,1463,1414,1370,1332,1300,1275,1257,1246,1242,1246,
1257,1275,1300,1332,1370,1414,1463,1518,1576,1639,1704,1772,1841,1910,1980,2049,
2117,2182,2245,2303,2358,2407,2451,2489,2521,2546,2564,2575},
{2770,2765,2751,2728,2696,2655,2606,2549,2486,2416,2340,2260,2176,2089,2000,1911,
1821,1732,1645,1561,1481,1405,1335,1272,1215,1166,1125,1093,1070,1056,1051,1056,
1070,1093,1125,1166,1215,1272,1335,1405,1481,1561,1645,1732,1821,1910,2000,2089,
2176,2260,2340,2416,2486,2549,2606,2655,2696,2728,2751,2765},
{2961,2955,2938,2910,2870,2820,2760,2691,2613,2528,2436,2338,2235,2129,2020,1911,
1801,1692,1586,1483,1385,1293,1208,1130,1061,1001,951,911,883,866,860,866,883,911,
951,1001,1061,1130,1208,1293,1385,1483,1586,1692,1801,1910,2020,2129,2235,2338,
2436,2528,2613,2691,2760,2820,2870,2910,2938,2955},
{3152,3145,3125,3091,3045,2986,2915,2833,2741,2640,2531,2415,2294,2169,2040,1911,
1781,1652,1527,1406,1290,1181,1080,988,906,835,776,730,696,676,669,676,696,730,776,
835,906,988,1080,1181,1290,1406,1527,1652,1781,1910,2040,2169,2294,2415,2531,
2640,2741,2833,2915,2986,3045,3091,3125,3145},
{3343,3335,3312,3273,3219,3151,3069,2975,2869,2753,2627,2493,2353,2208,2060,1911,
1761,1613,1468,1328,1194,1068,952,846,752,670,602,548,509,486,478,486,509,548,602,
670,752,846,952,1068,1194,1328,1468,1613,1761,1910,2060,2208,2353,2493,2627,2753,
2869,2975,3069,3151,3219,3273,3312,3335}};
uint code tablefenY[8][60]={
{1911,1920,1930,1940,1949,1958,1967,1974,1981,1988,1993,1998,2001,2004,2005,2006,
2005,2004,2001,1998,1993,1988,1981,1974,1967,1958,1949,1940,1930,1920,1911,1901,
1891,1881,1872,1863,1854,1847,1840,1833,1828,1823,1820,1817,1816,1815,1816,1817,
1820,1823,1828,1833,1840,1847,1854,1863,1872,1881,1891,1901},
{1911,1940,1970,1999,2027,2054,2079,2102,2123,2142,2159,2172,2183,2191,2195,2197,
2195,2191,2183,2172,2159,2142,2123,2102,2079,2054,2027,1999,1970,1940,1911,1881,
1851,1822,1794,1767,1742,1719,1698,1679,1662,1649,1638,1630,1626,1624,1626,1630,
1638,1649,1662,1679,1698,1719,1742,1767,1794,1822,1851,1881},
{1911,1960,2010,2058,2105,2149,2191,2230,2265,2297,2324,2347,2365,2378,2385,2388,
2385,2378,2365,2347,2324,2297,2265,2230,2191,2149,2105,2058,2010,1960,1911,1861,
1811,1763,1716,1672,1630,1591,1556,1524,1497,1474,1456,1443,1436,1433,1436,1443,
1456,1474,1497,1524,1556,1591,1630,1672,1716,1763,1811,1861},
{1911,1980,2049,2117,2182,2245,2303,2358,2407,2451,2489,2521,2546,2564,2575,2579,
2575,2564,2546,2521,2489,2451,2407,2358,2303,2245,2182,2117,2049,1980,1911,1841,
1772,1704,1639,1576,1518,1463,1414,1370,1332,1300,1275,1257,1246,1242,1246,1257,
1275,1300,1332,1370,1414,1463,1518,1576,1639,1704,1772,1841},
{1911,2000,2089,2176,2260,2340,2416,2486,2549,2606,2655,2696,2728,2751,2765,2770,
2765,2751,2728,2696,2655,2606,2549,2486,2416,2340,2260,2176,2089,2000,1911,1821,
1732,1645,1561,1481,1405,1335,1272,1215,1166,1125,1093,1070,1056,1051,1056,1070,
1093,1125,1166,1215,1272,1335,1405,1481,1561,1645,1732,1821},
{1911,2020,2129,2235,2338,2436,2528,2613,2691,2760,2820,2870,2910,2938,2955,2961,
2955,2938,2910,2870,2820,2760,2691,2613,2528,2436,2338,2235,2129,2020,1911,1801,
1692,1586,1483,1385,1293,1208,1130,1061,1001,951,911,883,866,860,866,883,911,951,
1001,1061,1130,1208,1293,1385,1483,1586,1692,1801},
{1911,2040,2169,2294,2415,2531,2640,2741,2833,2915,2986,3045,3091,3125,3145,3152,
3145,3125,3091,3045,2986,2915,2833,2741,2640,2531,2415,2294,2169,2040,1911,1781,
1652,1527,1406,1290,1181,1080,988,906,835,776,730,696,676,669,676,696,730,776,835,
906,988,1080,1181,1290,1406,1527,1652,1781},
{1911,2060,2208,2353,2493,2627,2753,2869,2975,3069,3151,3219,3273,3312,3335,3343,
3335,3312,3273,3219,3151,3069,2975,2869,2753,2627,2493,2353,2208,2060,1911,1761,
1613,1468,1328,1194,1068,952,846,752,670,602,548,509,486,478,486,509,548,602,670
,752,846,952,1068,1194,1328,1468,1613,1761}};
uint code tablemiaoX[10][60]={
{2006,2005,2004,2001,1998,1993,1988,1981,1974,1967,1958,1949,1940,1930,1920,1911,
1901,1891,1881,1872,1863,1854,1847,1840,1833,1828,1823,1820,1817,1816,1815,1816,
1817,1820,1823,1828,1833,1840,1847,1854,1863,1872,1881,1891,1901,1910,1920,1930,
1940,1949,1958,1967,1974,1981,1988,1993,1998,2001,2004,2005},
{2197,2195,2191,2183,2172,2159,2142,2123,2102,2079,2054,2027,1999,1970,1940,1911,
1881,1851,1822,1794,1767,1742,1719,1698,1679,1662,1649,1638,1630,1626,1624,1626,
1630,1638,1649,1662,1679,1698,1719,1742,1767,1794,1822,1851,1881,1910,1940,1970,
1999,2027,2054,2079,2102,2123,2142,2159,2172,2183,2191,2195},
{2388,2385,2378,2365,2347,2324,2297,2265,2230,2191,2149,2105,2058,2010,1960,1911,
1861,1811,1763,1716,1672,1630,1591,1556,1524,1497,1474,1456,1443,1436,1433,1436,
1443,1456,1474,1497,1524,1556,1591,1630,1672,1716,1763,1811,1861,1910,1960,2010,
2058,2105,2149,2191,2230,2265,2297,2324,2347,2365,2378,2385},
{2579,2575,2564,2546,2521,2489,2451,2407,2358,2303,2245,2182,2117,2049,1980,1911,
1841,1772,1704,1639,1576,1518,1463,1414,1370,1332,1300,1275,1257,1246,1242,1246,
1257,1275,1300,1332,1370,1414,1463,1518,1576,1639,1704,1772,1841,1910,1980,2049,
2117,2182,2245,2303,2358,2407,2451,2489,2521,2546,2564,2575},
{2770,2765,2751,2728,2696,2655,2606,2549,2486,2416,2340,2260,2176,2089,2000,1911,
1821,1732,1645,1561,1481,1405,1335,1272,1215,1166,1125,1093,1070,1056,1051,1056,
1070,1093,1125,1166,1215,1272,1335,1405,1481,1561,1645,1732,1821,1910,2000,2089,
2176,2260,2340,2416,2486,2549,2606,2655,2696,2728,2751,2765},
{2961,2955,2938,2910,2870,2820,2760,2691,2613,2528,2436,2338,2235,2129,2020,1911,
1801,1692,1586,1483,1385,1293,1208,1130,1061,1001,951,911,883,866,860,866,883,911,
951,1001,1061,1130,1208,1293,1385,1483,1586,1692,1801,1910,2020,2129,2235,2338,
2436,2528,2613,2691,2760,2820,2870,2910,2938,2955},
{3152,3145,3125,3091,3045,2986,2915,2833,2741,2640,2531,2415,2294,2169,2040,1911,
1781,1652,1527,1406,1290,1181,1080,988,906,835,776,730,696,676,669,676,696,730,776,
835,906,988,1080,1181,1290,1406,1527,1652,1781,1910,2040,2169,2294,2415,2531,
2640,2741,2833,2915,2986,3045,3091,3125,3145},
{3343,3335,3312,3273,3219,3151,3069,2975,2869,2753,2627,2493,2353,2208,2060,1911,
1761,1613,1468,1328,1194,1068,952,846,752,670,602,548,509,486,478,486,509,548,602,
670,752,846,952,1068,1194,1328,1468,1613,1761,1910,2060,2208,2353,2493,2627,2753,
2869,2975,3069,3151,3219,3273,3312,3335},
{3534,3525,3499,3455,3394,3316,3224,3117,2997,2865,2722,2571,2412,2248,2080,1911,
1741,1573,1409,1250,1099,956,824,704,597,505,427,366,322,296,287,296,322,366,427,
505,597,704,824,956,1099,1250,1409,1573,1741,1910,2080,2248,2412,2571,2722,2865,
2997,3117,3224,3316,3394,3455,3499,3525},
{3725,3715,3685,3636,3568,3482,3378,3259,3125,2977,2818,2649,2471,2288,2100,1911,
1721,1533,1350,1172,1003,844,696,562,443,339,253,185,136,106,96,106,136,185,253,
339,443,562,696,844,1003,1172,1350,1533,1721,1910,2100,2288,2471,2649,2818,2977,
3125,3259,3378,3482,3568,3636,3685,3715}};
uint code tablemiaoY[10][60]={
{1911,1920,1930,1940,1949,1958,1967,1974,1981,1988,1993,1998,2001,2004,2005,2006,
2005,2004,2001,1998,1993,1988,1981,1974,1967,1958,1949,1940,1930,1920,1911,1901,
1891,1881,1872,1863,1854,1847,1840,1833,1828,1823,1820,1817,1816,1815,1816,1817,
1820,1823,1828,1833,1840,1847,1854,1863,1872,1881,1891,1901},
{1911,1940,1970,1999,2027,2054,2079,2102,2123,2142,2159,2172,2183,2191,2195,2197,
2195,2191,2183,2172,2159,2142,2123,2102,2079,2054,2027,1999,1970,1940,1911,1881,
1851,1822,1794,1767,1742,1719,1698,1679,1662,1649,1638,1630,1626,1624,1626,1630,
1638,1649,1662,1679,1698,1719,1742,1767,1794,1822,1851,1881},
{1911,1960,2010,2058,2105,2149,2191,2230,2265,2297,2324,2347,2365,2378,2385,2388,
2385,2378,2365,2347,2324,2297,2265,2230,2191,2149,2105,2058,2010,1960,1911,1861,
1811,1763,1716,1672,1630,1591,1556,1524,1497,1474,1456,1443,1436,1433,1436,1443,
1456,1474,1497,1524,1556,1591,1630,1672,1716,1763,1811,1861},
{1911,1980,2049,2117,2182,2245,2303,2358,2407,2451,2489,2521,2546,2564,2575,2579,
2575,2564,2546,2521,2489,2451,2407,2358,2303,2245,2182,2117,2049,1980,1911,1841,
1772,1704,1639,1576,1518,1463,1414,1370,1332,1300,1275,1257,1246,1242,1246,1257,
1275,1300,1332,1370,1414,1463,1518,1576,1639,1704,1772,1841},
{1911,2000,2089,2176,2260,2340,2416,2486,2549,2606,2655,2696,2728,2751,2765,2770,
2765,2751,2728,2696,2655,2606,2549,2486,2416,2340,2260,2176,2089,2000,1911,1821,
1732,1645,1561,1481,1405,1335,1272,1215,1166,1125,1093,1070,1056,1051,1056,1070,
1093,1125,1166,1215,1272,1335,1405,1481,1561,1645,1732,1821},
{1911,2020,2129,2235,2338,2436,2528,2613,2691,2760,2820,2870,2910,2938,2955,2961,
2955,2938,2910,2870,2820,2760,2691,2613,2528,2436,2338,2235,2129,2020,1911,1801,
1692,1586,1483,1385,1293,1208,1130,1061,1001,951,911,883,866,860,866,883,911,951,
1001,1061,1130,1208,1293,1385,1483,1586,1692,1801},
{1911,2040,2169,2294,2415,2531,2640,2741,2833,2915,2986,3045,3091,3125,3145,3152,
3145,3125,3091,3045,2986,2915,2833,2741,2640,2531,2415,2294,2169,2040,1911,1781,
1652,1527,1406,1290,1181,1080,988,906,835,776,730,696,676,669,676,696,730,776,835,
906,988,1080,1181,1290,1406,1527,1652,1781},
{1911,2060,2208,2353,2493,2627,2753,2869,2975,3069,3151,3219,3273,3312,3335,3343,
3335,3312,3273,3219,3151,3069,2975,2869,2753,2627,2493,2353,2208,2060,1911,1761,
1613,1468,1328,1194,1068,952,846,752,670,602,548,509,486,478,486,509,548,602,670,
752,846,952,1068,1194,1328,1468,1613,1761},
{1911,2080,2248,2412,2571,2722,2865,2997,3117,3224,3316,3394,3455,3499,3525,3534,
3525,3499,3455,3394,3316,3224,3117,2997,2865,2722,2571,2412,2248,2080,1911,1741,
1573,1409,1250,1099,956,824,704,597,505,427,366,322,296,287,296,322,366,427,505,
597,704,824,956,1099,1250,1409,1573,1741},
{1911,2100,2288,2471,2649,2818,2977,3125,3259,3378,3482,3568,3636,3685,3715,3725,
3715,3685,3636,3568,3482,3378,3259,3125,2977,2818,2649,2471,2288,2100,1911,1721,
1533,1350,1172,1003,844,696,562,443,339,253,185,136,106,96,106,136,185,253,339,443,
562,696,844,1003,1172,1350,1533,1721}};
void delay(uint x)
{
uint i,j;
for(i=x;i>0;i--)
for(j=110;j>0;j--);
}
void init()
{ din=1;
scl=1;
cs=1;
// led=0;
}
void xieshuju(uint x)
{
uint i;
scl=1;
cs=0;
for(i=0;i<16;i++)
{
scl=1;
if(x&0x8000)
din=1;
else
din=0;
x=x<<1;
scl=0;
}
cs=1;
}
void main()
{
uint i,j,k,h,r,a,b,c;
i=0;
j=0;
a=0;
b=0;
c=0;
init();
delay(1000);
while(1)
{
for(c=0;c<60;c++)
{
for(r=0;r<60;r++)
{
j=0;
if(r==12)c++;
if(r==24)c++;
if(r==36)c++;
if(r==48)c++;
while(j!=60)
{
for(j=0;j<60;j++)
{
k=14;
while(k)
{
for(i=0;i<61;i++)
{
xieshuju(0x1000+tableB);
xieshuju(0x8000+tableA);
// delaym();
}
for(h=0;h<10;h++)
{
xieshuju(0x1000+tablemiaoX[h][j]);
xieshuju(0x8000+tablemiaoY[h][j]);
// delaym();
}
for(a=0;a<8;a++)
{
xieshuju(0x1000+tablefenX[a][r]);
xieshuju(0x8000+tablefenY[a][r]);
//delaym();
}
for(b=0;b<5;b++)
{
xieshuju(0x1000+tableshiX[c]);
xieshuju(0x8000+tableshiY[c]);
//delaym();
}
k--;
}
// led=~led;
}
}
}
}
}
}
|