字體:小 中 大 | |
|
|
2012/10/19 11:39:49瀏覽86|回應0|推薦0 | |
#include #include #define nop() _nop_() sbit SPI_CLK = P1^7; sbit SPI_DATA = P1^5; sbit CS_DA = P1^4; code unsigned int DA_data[260]={ 0x200,0x20C,0x219,0x225,0x232,0x23E,0x24B,0x257,0x263,0x270, 0x27C,0x288,0x294,0x2A0,0x2AC,0x2B8,0x2C3,0x2CF,0x2DA,0x2E6, 0x2F1,0x2FC,0x307,0x311,0x31C,0x326,0x330,0x33A,0x344,0x34E, 0x357,0x361,0x36A,0x372,0x37B,0x383,0x38B,0x393,0x39B,0x3A2, 0x3A9,0x3B0,0x3B7,0x3BD,0x3C3,0x3C9,0x3CE,0x3D4,0x3D9,0x3DD, 0x3E2,0x3E6,0x3E9,0x3ED,0x3F0,0x3F3,0x3F6,0x3F8,0x3FA,0x3FC, 0x3FD,0x3FE,0x3FF,0x3FF,0x3FF,0x3FF,0x3FF,0x3FE,0x3FD,0x3FC, 0x3FA,0x3F8,0x3F6,0x3F3,0x3F0,0x3ED,0x3E9,0x3E6,0x3E2,0x3DD, 0x3D9,0x3D4,0x3CE,0x3C9,0x3C3,0x3BD,0x3B7,0x3B0,0x3A9,0x3A2, 0x39B,0x393,0x38B,0x383,0x37B,0x372,0x36A,0x361,0x357,0x34E, 0x344,0x33A,0x330,0x326,0x31C,0x311,0x307,0x2FC,0x2F1,0x2E6, 0x2DA,0x2CF,0x2C3,0x2B8,0x2AC,0x2A0,0x294,0x288,0x27C,0x270, 0x263,0x257,0x24B,0x23E,0x232,0x225,0x219,0x20C,0x200,0x1F3, 0x1E6,0x1DA,0x1CD,0x1C1,0x1B4,0x1A8,0x19C,0x18F,0x183,0x177, 0x16B,0x15F,0x153,0x147,0x13C,0x130,0x125,0x119,0x10E,0x103, 0xF8,0xEE,0xE3,0xD9,0xCF,0xC5,0xBB,0xB1,0xA8,0x9E,0x95,0x8D, 0x84,0x7C,0x74,0x6C,0x64,0x5D,0x56,0x4F,0x48,0x42,0x3C,0x36, 0x31,0x2B,0x26,0x22,0x1D,0x19,0x16,0x12,0xF,0xC,0x9,0x7,0x5, 0x3,0x2,0x1,0x0,0x0,0x0,0x0,0x0,0x1,0x2,0x3,0x5,0x7,0x9,0xC, 0xF,0x12,0x16,0x19,0x1D,0x22,0x26,0x2B,0x31,0x36,0x3C,0x42, 0x48,0x4F,0x56,0x5D,0x64,0x6C,0x74,0x7C,0x84,0x8D,0x95,0x9E, 0xA8,0xB1,0xBB,0xC5,0xCF,0xD9,0xE3,0xEE,0xF8,0x103,0x10E, 0x119,0x125,0x130,0x13C,0x147,0x153,0x15F,0x16B,0x177,0x183, 0x18F,0x19C,0x1A8,0x1B4,0x1C1,0x1CD,0x1DA,0x1E6,0x1F3,0x1FF }; void delay_1m(unsigned int dly); void da5615(unsigned int da); void int4_drv(void) interrupt 4 { if (RI == 1) { P0 = ~SBUF; RI = 0; } else { TI = 0; } } void main() { unsigned int k; TMOD = 0x20; PCON &= 0x7F; TH1 = 0xFA; //19200, 22.118 , C51ED2 SCON = 0x50; IP = 0x10; IE = 0x90; TR1 = 1; while(1) { k++; if(k>=256) k=0; da5615(DA_data[k]); } } void da5615(unsigned int da) { unsigned char i; SPI_CLK=0; CS_DA=0; for (i=0;i<12;i++) br=""> { if((da&0x800)==0) { SPI_DATA=0; } else SPI_DATA=1; SPI_CLK=1; da=da<<1; br=""> SPI_CLK=0; } CS_DA=1; } |
|
( 心情隨筆|心情日記 ) |