Learning microcontroller series based on Proteus (9) - AD conversion and its application--TLC5615

Project download

    click to download

1. Circuit diagram


2. Procedure

        Only the main function is posted here, and the rest, please click on the above (click to download) to download, it is too troublesome.

main function

#include<reg51.h>
#include<intrins.h>
#define uchar unsigned char
#define uint unsigned int
#include<TLC5615.c>
uchar cp1, cp2;
uint moni, that;
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 = that * 0.489;
		that = that + 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);
}


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324599846&siteId=291194637
Recommended