Haberler:

Forum kuralları güncellendi LÜTFEN  okuyunuz:  https://bit.ly/2IjR3ME

Ana Menü

frekansmetre

Başlatan turan33, 16 Mayıs 2011, 17:50:37

turan33

0-100 hz arası karedalda ölçümü yapanfrekansmetre yapmak ist. kodda ne gibi hatalar var yardım edin lütfen... prog acemiyim. 16f628a kul.
#include "C:\Users\TURAN\Desktop\Yeni klasör\main.h"
#int_CCP1

unsigned char rakam[10]={0X3F,0X06,0X5B,0X4F,0X66,0X6D,0X7D,0XD7,0X7F,0X6F};
unsigned char secme[4]={1,2,4,8};
unsigned int sayac,deger,kalan1,kalan2,kontrol=0;
float frekans;
unsigned char a,i,display[5],veri;
#byte CCPR1H=0X16
#byte CCPR1L=0x15
#byte TMR1H=0x0F
#byte TMR1L=0X0E
#bit GIE=0X0B.7
#bit CCP1IF=0X0C.2
#byte PORTA=0X05
#byte PORTB=0X06
void  CCP1_isr(void)

{TMR1H=0;
TMR1L=0;
kontrol=1;
GIE=0;
CCP1IF=0;
GIE=1;
}
void main()
{

   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
   setup_timer_1(T1_INTERNAL|T1_DIV_BY_1);
   setup_timer_2(T2_DISABLED,0,1);
   setup_ccp1(CCP_CAPTURE_FE);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);
   enable_interrupts(INT_CCP1);
   enable_interrupts(GLOBAL);
//Setup_Oscillator parameter not selected from Intr Oscillator Config tab
set_tris_a(0b00000);
set_tris_b(0x08);

  while(TRUE)
  {
  sayac=256*CCPR1H+CCPR1L;
  if(kontrol==1)
  frekans=100000000/sayac;
  if(kontrol==0)
  frekans=0;
  if(sayac<10000){
  frekans=0;
  kontrol=0;}
 
  for(a=0;a<25;a++)
  {
  deger=(int)frekans;
  display[1]=deger/1000;
kalan1=deger-display[1]*1000;
display[2]=kalan1/100;
kalan2=kalan1-display[2]*100;
display[3]=kalan2/10;
display[4]=kalan2-display[3]*10;

for(i=0;i<4;i+4){
PORTB=0;
PORTA=0;
veri=rakam[display[i+1]];
PORTB=veri&0x07;
veri=veri<<1;
PORTB=(veri&0XF0);
PORTA=secme(i);
delay_ms(3);
}}
  }}