[ create a new paste ] login | about

Link: http://codepad.org/JSHfL124    [ raw code | output | fork ]

C, pasted on Mar 13:
#include <REGX52.H>
 unsigned char count1=0;
	unsigned char t=40;
	unsigned int count;
		unsigned char dem1=0;
unsigned char code Code7Seg[10] = {0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8, 0x80, 0x90};

/// ham hien thi led 7 thanh******************
void hienthi(unsigned int b)  
 {
 	unsigned int chuc,dvi;
 chuc = b/10;		
 dvi = b%10;
 switch(dem1)
 {
 case 0:
 P3=0x40;
 LED_PORT = Code7Seg[chuc];
 dem1++;
 break;
 case 1:
 P3=0x80;
 	LED_PORT = Code7Seg[dvi];
	dem1=0;
	break;
 }
 } led 7 doan
/// ham ngat qued
void quetled() interrupt 1		 // 10ms xay ra 1 lan
 {
    TR0=0;
    TH0=0xDC;    //Nap lai gia tri	  10ms thach anh 11.0592Mhz
    TL0=0x00; 
    
	count++;
	hienthi(t);
	if(count==100)
	{
		t--;
	count=0;
	 count1++;
	}
	if(count1>=0 && count1<=40)
	{
	P1=0xFB; // den xanh 40s
	if(t==0) // gan lai bien hiển thị t=3 
	t=3;
	}
	else if(count1>40 && count1<=43)
	{
	P1=0xFD;/// den vang 3s
	if(t=0)
	t=33;// gán lại biến hiển thị t=33
	}
	else if(count1>43 && count1 <=76)
	{
	P1=0xFE;// den do 33s
	}
	else if(count1>76)
	{
	count1=0;
	t=40; // gán lại t=40
	}
	TR0=1;
}
 void main()
{
 P1=0xFB;
 TMOD=0x21;
TH0=0xDC;	   //10ms
TL0=0x00;
 TR0=1;
 ET0=1;//Ngat timer0
 EA=1;//Cho phep ngat
Uart_Init();
while(1)
{ 	
}
}


Output:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Line 19: error: REGX52.H: No such file or directory
Line 6: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'Code7Seg'
In function 'hienthi':
Line 17: error: 'P3' undeclared (first use in this function)
Line 17: error: (Each undeclared identifier is reported only once
Line 17: error: for each function it appears in.)
Line 18: error: 'LED_PORT' undeclared (first use in this function)
Line 18: error: 'Code7Seg' undeclared (first use in this function)
t.c: At top level:
Line 27: error: expected '=', ',', ';', 'asm' or '__attribute__' before numeric constant
In function 'main':
Line 68: error: 'P1' undeclared (first use in this function)
Line 69: error: 'TMOD' undeclared (first use in this function)
Line 70: error: 'TH0' undeclared (first use in this function)
Line 71: error: 'TL0' undeclared (first use in this function)
Line 72: error: 'TR0' undeclared (first use in this function)
Line 73: error: 'ET0' undeclared (first use in this function)
Line 74: error: 'EA' undeclared (first use in this function)
Line 67: warning: return type of 'main' is not 'int'


Create a new paste based on this one


Comments: