基于Proteus学习单片机系列(九)——DA转换及其应用--TLC5615

2019-04-15 12:28发布

项目下载    点击下载
1.电路图
2.程序        只在这里贴出主函数,其余的请点击上面(点击下载)进行下载,实在太麻烦。主函数#include #include #define uchar unsigned char #define uint unsigned int #include uchar cp1,cp2; uint moni,dat; void timer0_init(void) { TMOD = 0x01; TL0 = (65536 - 2000) % 256; TH0 = (65536 - 2000) / 256; EA = 1; TR0 = 1; ET0 = 1; } void timer0_isr()interrupt 1 { TL0 = (65536 - 2000) % 256; TH0 = (65536 - 2000) / 256; cp1++; if(cp1 >= 500) { cp1 = 0; tlc5615(dat); if(dat >= 962) dat = 0; moni = dat * 0.489; dat = dat + 10; } P0 = 0xff; switch(cp2) { case 0: P0 = seven_seg[moni % 10];P2 = 0xfe;break; case 1: P0 = seven_seg[moni / 10 % 10];P2 = 0xfd;break; case 2: P0 = seven_seg[moni / 100] & 0x7f;P2 = 0xfb;break; } cp2++; if(cp2 >= 3) cp2 = 0; } void main(void) { timer0_init(); while(1); }