3 Eylül 2016 Cumartesi

Ccs Pic timer0 Application For 16F628A

I wanna explain how to use timer0 interrupts for 16f628a microprocessor..First time coding timer0 is difficult for me.At that time I have investigated timer0 .Actually it so easy .May be it is different than 16f877a etc.But it s so simply

Here We Go :


#include "E:\ENGİNEERİNG\MİCRO DENETLEYİCİLER\çalışmalarım 6\628a deneme\2\timer0 kesmesi"

#include <16f628a .h="">
#FUSES NOWDT                    //No Watch Dog Timer
#FUSES xt                       //Crystal  Osc with CLKOUT
#FUSES NOPUT                    //No Power Up Timer
#FUSES NOCPD                    //No EE protection

#use delay(clock=4000000)

#use fast_io(b)
#use fast_io(a)

int i=0;

#int_rtcc     // tmer0  kesmesini bu sekilde tanımlıyoruz 628a da
rtcc_isr( )
{
set_timer0(60);
i++;
if(i==40)
{
output_high(pin_b7);
delay_ms(100);
output_low(pin_b7);
delay_ms(10);
i=0;

}


}


void main()

{

   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_256);

   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);
//Setup_Oscillator parameter not selected from Intr Oscillator Config tab

   // TODO: USER CODE!!

set_tris_b(0x01);
set_tris_a(0xff);
output_a(0x00);
output_b(0x00);


 set_timer0(60); // TMR0 değeri belirleniyor


 while(1){


 enable_interrupts(INT_timer0); // int_timer0 kesmesini aktif yapar

 enable_interrupts(GLOBAL);


 }


}


IF YOU DEFıNE TİMER0 ; as the  following

#int_timer0
void timer0 ()
{

set_timer0(60)

}

this codes are not working


I hope this code list can be  usefull and beneficial for you






Hiç yorum yok:

Yorum Gönder