Вы находитесь на странице: 1из 6

sbit

sbit
sbit
sbit
sbit
sbit
sbit
sbit
sbit
sbit

LCD_D0 at PORTC0_bit;
LCD_D1 at PORTC1_bit;
LCD_D2 at PORTC2_bit;
LCD_D3 at PORTC3_bit;
LCD_D4 at PORTC4_bit;
LCD_D5 at PORTC5_bit;
LCD_D6 at PORTC6_bit;
LCD_D7 at PORTC7_bit;
LCD_RS at PORTA0_bit;
LCD_EN at PORTA1_bit;

sbit
sbit
sbit
sbit
sbit
sbit
sbit
sbit
sbit
sbit

LCD_D0_Direction at DDC0_bit;
LCD_D1_Direction at DDC1_bit;
LCD_D2_Direction at DDC2_bit;
LCD_D3_Direction at DDC3_bit;
LCD_D4_Direction at DDC4_bit;
LCD_D5_Direction at DDC5_bit;
LCD_D6_Direction at DDC6_bit;
LCD_D7_Direction at DDC7_bit;
LCD_RS_Direction at DDA0_bit;
LCD_EN_Direction at DDA1_bit;

unsigned int i, j=0, cont=0, L, H, c;


unsigned long int ov, fre;
char num[5];
int num1[4];
float fre1;
void con() iv IVT_ADDR_TIMER1_OVF ics ICS_AUTO
{
ov++;
}
void com() iv IVT_ADDR_TIMER0_COMP ics ICS_AUTO
{
j++;
if(j==4)
{
TCCR1B=0x00;
TCCR0=0x08;
L=TCNT1L;
H=TCNT1H;
ov=ov*65536;
H=H*256;
fre=ov+H+L;
fre1=fre;
if(fre>=1000)
{
fre1=fre1/1000;

FloatToStr(fre1,num1);
c=1;
}
if(fre<1000)
{
IntToStr(fre,num);
c=2;
}
ov=0;
TCNT1H=0x00;
TCNT1L=0x00;
j=0;
TCCR1B=0x07;
TCCR0=0x0D;
}
}
void main()
{
PORTC=0xFF;
PORTA=0x03;
Lcd_Init();
delay_ms(100);
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);
Lcd_Out(1,2,"Iniciando...");
Delay_ms(500);
Lcd_Cmd(_LCD_CLEAR);
SREG_I_BIT=1;
TCCR0=0x0D;
OCR0=0xF3;
TCCR1A=0x00;
TCCR1B=0x07;
TIMSK=0x06;
while(1)
{
Lcd_Out(1,3,"Frecuencia:");
if(c==1)
{
Lcd_Out(2,6,num1);
Lcd_Out(2,1,"Khz");
}
if(c==2)
{
Lcd_Out(2,7,num);
Lcd_Out(2,1,"hz
");

}
}
}
LCD1

LM016L

D0
D1
D2
D3
D4
D5
D6
D7
7
8
9
10
11
12
13
14

RS
RW
E
4
5
6

1
2
3

VSS
VDD
VEE

LCD1(VDD)

17%

RV1

330

U1
+

AM

FM

1
2
3
4
5
6
7
8
14
15
16
17
18
19
20
21
13
12
9

PB0/T0/XCK
PB1/T1
PB2/AIN0/INT2
PB3/AIN1/OC0
PB4/SS
PB5/MOSI
PB6/MISO
PB7/SCK
PD0/RXD
PD1/TXD
PD2/INT0
PD3/INT1
PD4/OC1B
PD5/OC1A
PD6/ICP1
PD7/OC2

PA0/ADC0
PA1/ADC1
PA2/ADC2
PA3/ADC3
PA4/ADC4
PA5/ADC5
PA6/ADC6
PA7/ADC7
PC0/SCL
PC1/SDA
PC2
PC3
PC4
PC5
PC6/TOSC1
PC7/TOSC2

XTAL1
XTAL2
RESET

AREF
AVCC

ATMEGA8535

char A,i;
int Iniciar();
int Limpiar();
int Escribir();
unsigned char itcm[6]= {'I','T','C','M','.','.'},
equipodsp[10]={'E','Q','U','I','P','O',' ','D','S','P'};
int Iniciar()
{
PORTA.B0&=0;
PORTC=0X38;
PORTA.B1|=1;
PORTA.B1&=0;

40
39
38
37
36
35
34
33
22
23
24
25
26
27
28
29
32
30

Delay_us(100);
PORTA.B0&=0;
PORTC=0X0E;
PORTA.B1|=1;
PORTA.B1&=0;
Delay_us(100);
PORTA.B0&=0;
PORTC=0X06;
PORTA.B1|=1;
PORTA.B1&=0;
Delay_us(100);
}
int Limpiar()
{
PORTA.B0&=0;
PORTC=0X01;
PORTA.B1|=1;
PORTA.B1&=0;
Delay_us(200);
}
int Escribir()
{
PORTA.B0|=1;
PORTC=A;
PORTA.B1|=1;
PORTA.B1&=0;
Delay_us(50);
}
int Linea1()
{
PORTA.B0&=0;
PORTC=0X85;
PORTA.B1|=1;
PORTA.B1&=0;
Delay_us(200);
}
int Linea2()
{
PORTA.B0&=0;
PORTC=0XC3;
PORTA.B1|=1;
PORTA.B1&=0;
Delay_us(200);
}
void main()

{
DDRA=0X03;
DDRC=0XFF;
Delay_us(200);
Iniciar();
while(1)
{
Limpiar();
Linea1();
for(i=0;i<6;i++)
{
A=itcm[i];
Escribir();
}
Linea2();
for(i=0;i<10;i++)
{
A=equipodsp[i];
Escribir();
}
Delay_ms(2000);
}
}

LCD1

LM016L

D0
D1
D2
D3
D4
D5
D6
D7
7
8
9
10
11
12
13
14

RS
RW
E
4
5
6

1
2
3

VSS
VDD
VEE

LCD1(VDD)

17%

RV1

330

U1
+

AM

FM

1
2
3
4
5
6
7
8
14
15
16
17
18
19
20
21
13
12
9

PB0/T0/XCK
PB1/T1
PB2/AIN0/INT2
PB3/AIN1/OC0
PB4/SS
PB5/MOSI
PB6/MISO
PB7/SCK
PD0/RXD
PD1/TXD
PD2/INT0
PD3/INT1
PD4/OC1B
PD5/OC1A
PD6/ICP1
PD7/OC2
XTAL1
XTAL2
RESET

PA0/ADC0
PA1/ADC1
PA2/ADC2
PA3/ADC3
PA4/ADC4
PA5/ADC5
PA6/ADC6
PA7/ADC7
PC0/SCL
PC1/SDA
PC2
PC3
PC4
PC5
PC6/TOSC1
PC7/TOSC2
AREF
AVCC

ATMEGA8535

40
39
38
37
36
35
34
33
22
23
24
25
26
27
28
29
32
30

Вам также может понравиться