交流信號測量儀
如有朋友做AD方面的東西,相互交流
完整的源碼下載:http://www.51hei.com/f/jiaoliu.rar
以下是部分代碼:
#include#include #include #define nop() _nop_()#define N0 65336#define uint unsigned int#define uchar unsigned char #define ulong unsigned longuchar code xian[]={"Welcome"};uchar code xian1[]={"Designed by WJJ"};uchar tab[7];uchar tab2[7];uchar tab3[5];uchar tab4[8]={" "};sbit EOC=P2^6;sbit OE=P2^5;sbit START=P2^7;sbit lcdrs=P3^5;sbit lcdrw=P3^6;sbit lcden=P3^7;uint vmax=0; // 電壓測量運算變量uint count1; //電壓測量控制變量uint count; //頻率測量控制變量ulong mt=0; // 頻率測量運算變量ulong vs=0;ulong t;bit flag=0; //是否顯示標志位 對頻率void DelayNS(uint dly) { uint i;for(; dly>0; dly--)for(i=0; i<100; i++);}bit lcd_busy(){bit result;lcdrw = 1;lcdrs = 0;lcden = 1;nop();nop();nop();nop();result = (bit)(P1&0x80);lcden = 0;return(result);}void write_com(uchar com){while(lcd_busy()); //LCD忙等待lcdrs = 0;lcdrw = 0;P1 = com;DelayNS(5);lcden = 1;DelayNS(5);lcden = 0;}void write_data(uchar date){while(lcd_busy()); //LCD忙等待lcdrs = 1;lcdrw = 0;P1 = date;DelayNS(5);lcden = 1;DelayNS(5);lcden = 0;}void lcd_init(){lcden = 0;write_com(0x38);DelayNS(5);write_com(0x0c);DelayNS(5);write_com(0x04);DelayNS(5);write_com(0x01);}void timer_init() {EA = 1;EX0=1;IT0=1;TMOD = 0x11;TH0=0;TL0=0;}
評論