Site içi Arama

Ara

CCS C ve 16F628 ile yapılan kronometre devrsesi

Samet Yüzügüllü - 02.02.2013
CCS C ve 16F628 ile yapılan kronometre devrsesi



Ekler: kronometre.zip

Devrenin CCS C kodları:
#include <16F628A.h>

#FUSES NOWDT //No Watch Dog Timer
#FUSES INTRC_IO //Internal RC Osc, no CLKOUT
#FUSES NOPUT //No Power Up Timer
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOBROWNOUT //No brownout reset
#FUSES MCLR //Master Clear pin enabled
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD //No EE protection

#use delay(clock=4000000)
#include "new_lcd.c"
#use fast_io(b)
#use fast_io(a)
int8 sad=0,san=0,dak=0,saat=0,durum=0,kur1=1,set=0,atl=0,sadi=0,sani=0,daki=0,sat=0;//DEÐÝÞKENLERÝN TANIMLANMASI


#int_TIMER1 //GERÇEK ZAMANLI SAYIM ÝÇÝN TIMER1 KESMESÝ
void TIMER1_isr(void)
{
set_timer1(15510);
sad ;
sadi--;

}
//KURMA ALT PROGRAMI
void kur(){
if(input(pin_a1)){
san ;
while(input(pin_a1));
}
}
//ILERI SAYMASI ICIN ALT PROGRAM
void ileri(){
if(sad==10){
san ;
sad=0;
}
else if(san==60){
dak ;
san=0;
}

else if(dak==60){
saat ;
dak=0;
}

else if(saat==24)saat=0;

lcd_gotoxy(1,1);
printf(lcd_putc,"u:u:u:%u ileri ",saat,dak,san,sad);
sadi=sad;
daki=dak;
sat=saat;
sani=san;

}

//GERI SAYMASI ICIN ALT PROGRAM
void geri(){
if(sadi==255){
sani--;
sadi=9;
}
else if(sani==255){
daki--;
sani=59;
}

else if(daki==255){
sat--;
daki=59;
}
else if(sat==255)sat=23;

lcd_gotoxy(1,1);
printf(lcd_putc,"u:u:u:%u geri ",sat,daki,sani,sadi);

sad=sadi;
dak=daki;
saat=sat;
san=sani;
}


void main()
{

setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_ccp1(CCP_OFF);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
enable_interrupts(INT_TIMER1);
enable_interrupts(GLOBAL);

set_tris_b(0);
output_b(0);
set_tris_a(255);
output_a(0);
lcd_init();
delay_ms(10);
set_timer1(15510);


while(1){


if(input(pin_a0)&& atl==1){
setup_timer_1(T1_DISABLED);
lcd_gotoxy(1,2);
printf(lcd_putc,"u:u:u:%u u.tur ",saat,dak,san,sad,kur1);
kur1 ;
atl=0;
while(input(pin_a0));

}
else if(input(pin_a0)&& atl==0){
setup_timer_1(T1_INTERNAL|T1_DIV_BY_2);
atl ;
while(input(pin_a0));

}
if(atl==2)atl=0;
if(input(pin_a1)){
durum ;
while(input(pin_a1));
}
else if(durum==2)durum=0;

if(durum==0)ileri();
else if(durum==1)geri();


if(input(pin_a2)){
san=0;
dak=0;
saat=0;
sad=0;
sani=0;
daki=0;
sat=0;
sadi=0;
kur1=1;
lcd_gotoxy(1,2);
printf(lcd_putc,"u:u:u:%u ",saat,dak,san,sad);
setup_timer_1(T1_DISABLED);
atl=0;

while(input(pin_a2));
}
if(input(pin_a3)){
lcd_gotoxy(1,2);
printf(lcd_putc,"u:u:u:%u u.tur ",saat,dak,san,sad,kur1);
kur1 ;
while(input(pin_a3));
}
}


}





E-posta: samet_esk_26@hotmail.com
İçerik Yan Blok
Konular
Tasarım: Teknimer Teknoloji
Yukarı