Sign In

How To Make Freq Counter With Atmega8 With Four Seven Segment Display To Show Freq Upto 10.00 To 99.99mhz

prabhat mishra prabhatmishra938@gmail.com India

Hardware: Atmega8 Running At 16mhz Software: C Project Using Atmega8

i wanted to get the code for freq counter in atmega 8 with 4 segment for displaying 10.00 to 99.99mhz

Images

Program

i havent any program

Replies

R Avinash Gupta
2016-07-22 07:29:37
You have to hire and engineer to do you task. This is a problem and solution system. You cannot say that you haven't done a thing and want someone else to do your job.
R prabhat
2016-07-23 06:39:56
i had done some work but not knowing to interface timers countersinterface with controller with seven segment
R prabhat
2016-08-07 16:13:56
how i start my display from 10.00. and also want to make it stable.i am facing a problem there.if u can help me out please.....?????
#include <avr/io.h>
 #include <util/delay.h>
 #include <avr/interrupt.h>
 #include <string.h>
 #ifndef F_CPU
 #define F_CPU 16000000UL
 #endif
 
#define  PINPC0 0x01
#define  PINPC1 0X02
#define  PINPC2 0x04
#define  PINPC3 0X08
 #define SegOne   0x01
  #define SegTwo  0x02
   #define SegThree 0x04
   #define SegFour   0x08
   #define A (1<<PD0)
    #define B (1<<PD1)
	#define C (1<<PD2)
	 #define D (1<<PD3)
	  #define E (1<<PD4)
	  #define F (1<<PD5)
	  #define G (1<<PD6)
	  #define H (1<<PD7)
	  
	  
	  void wait()
	  {
		  int i;
		  for(i=0;i<10;i++)
		  {
			  _delay_ms(3);
		  }
	  }	
	  void print(int num)
	  {
		  
		  int i,j,temp;
		  if(num>10000)return;
		  while(num)
		  {
			  temp=num%10;
			  i++;
			  num=num/10;
		  }
		  for(j=0;j<4;j++);
	  }		  			  	  			  
   	int main() 
	   { 
	   char seg_code[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f}; 
int i, num, temp,j; /* Configure the ports as output */
 DDRD = 0xff; // Data lines
 
 DDRC = 0xff;
TCCR1B= (1<<WGM12)|(1<<CS12)|(1<<CS10);
 //TCCR1B=(1<<WGM12);
 TCCR1A=(1<<COM1A0);
 TIMSK |=(1<<OCIE1A);                          //(1<<TOIE1);
 TCNT1=1;
TIFR=(1<<TOV1);
TCNT1H=1;
 TCNT1L=0;
 DDRC=0xff;
 PORTC=0x0f;
 PORTD=0xff;
 PORTD=0x00;
 sei();
 
 
                            
 
  while (1) 
  {
	

for (i =0x00;i<9999;i++)
{
 
	 
for (j=i;j<10;j++)


{
	


 
 num = i;
 temp = num%1000;
 num = num%1000;
  PORTC = SegOne; 
  PORTD= seg_code[temp]; 
  _delay_ms(5);
  temp = num%100; 
  num = num%100;
  PORTC= SegTwo; 
  PORTD = seg_code[temp];
   _delay_ms(5); 
   temp = num%10;
   //num=num/10;
    PORTC = SegThree; 
	PORTD= seg_code[temp];
	 _delay_ms(5);
	 temp = num%10;
	 //num=num/10;
	 PORTC=SegFour;
	  PORTD= seg_code[temp];
	   _delay_ms(5);
	   print(i);
	   wait();
	   _delay_ms(5);
	  
}
 }

	}
	   }
	   void initADC()
	   {
		   ADMUX |=(1<<REFS0);
		   //ADEN=1;
		   while(!(ADCSRA &&(1<<ADIF)));
		   ADCSRA |=(1<<ADEN)|(1<<ADPS2)|(1<<ADPS1)|(1<<ADPS0);
	   }
	   int readADC(int ch)
	   {
		   ch=ch & 0b00000111;
		   ADMUX |=ch;
		   ADCSRA |=(1<<ADSC);
		   while(!(ADCSRA && (1<<ADIF)));
		   ADCSRA |=(1<<ADIF);
		   return(ADC);
	   }		   
		   		   	
	    ISR(TIMER1_COMPA_vect) 
		{
			
			int i;
			if(i==3)
			{
				
				i=0;
			}
			else
			{
				
				i++;
			}
			PORTC &=(0x0f);
			PORTC |=(1<<i);	
					
			}				
			

Post a reply to prabhat mishra

Think you can help prabhat mishra ? Then post your thoughts that might help prabhat mishra. You will earn a lot of reputation in the technical community.

If your program is in multiple files, then ZIP the entire folder and attach below

Images and Screenshots

These helps other better understand your suggestion.