| View previous topic :: View next topic   | 
	
	
	
		| Author | 
		Message | 
	
	
		
			volcane
 
 
  Joined: 23 Feb 2008 Posts: 29
  
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				| measure frequency prescaler | 
			 
			
				 Posted: Wed Mar 25, 2009 3:29 pm     | 
				     | 
			 
			
				
  | 
			 
			
				Hi!
 
 
I need a pin-out (example b5) on a 16F877 the exact frequency of timer1 prescaler? I would like to measure with frequency meter the frequency of the prescaler.
 
 
I recommended that code? | 
			 
		  | 
	
	
		  | 
	
	
		
			PCM programmer
 
 
  Joined: 06 Sep 2003 Posts: 21708
  
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Wed Mar 25, 2009 3:47 pm     | 
				     | 
			 
			
				
  | 
			 
			
				There is no way to bring the Timer1 Prescaler clock to an i/o pin.
 
 
There is no option in the 16F877 hardware to do this. | 
			 
		  | 
	
	
		  | 
	
	
		
			volcane
 
 
  Joined: 23 Feb 2008 Posts: 29
  
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Wed Mar 25, 2009 3:55 pm     | 
				     | 
			 
			
				
  | 
			 
			
				 	  | PCM programmer wrote: | 	 		  There is no way to bring the Timer1 Prescaler clock to an i/o pin.
 
 
There is no option in the 16F877 hardware to do this. | 	  
 
 
you can do with software? I would like to know the error of the oscillator | 
			 
		  | 
	
	
		  | 
	
	
		
			PCM programmer
 
 
  Joined: 06 Sep 2003 Posts: 21708
  
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Wed Mar 25, 2009 4:16 pm     | 
				     | 
			 
			
				
  | 
			 
			
				You have full control over the application program in the PIC.
 
You can create a loop that toggles a pin.  Example:
 
 	  | Code: | 	 		  #include <16F877.H> 
 
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP 
 
#use delay(clock=4000000) 
 
 
//======================================
 
void main() 
 
{ 
 
output_low(PIN_B5);
 
 
#use fast_io(b)
 
while(1)
 
 {
 
  output_high(PIN_B5);
 
  output_low(PIN_B5);
 
 }  
 
 
} | 	  
 
 
Then look at the .LST file to see what ASM code is generated by the 
 
compiler:
 
 	  | Code: | 	 		  .................... while(1) 
 
....................  { 
 
....................   output_high(PIN_B5); 
 
0010:  BSF    PORTB.5
 
....................   output_low(PIN_B5); 
 
0011:  BCF    PORTB.5
 
....................  }   
 
0012:  GOTO   010 | 	  
 
That's a total of 4 instruction clocks.  The BSF and BCF each take 1 clock.
 
The GOTO takes 2 clocks.  So the signal on pin B5 will be the instruction
 
clock divided by 4.   The instruction clock is 1/4 of the crystal frequency,
 
so it's 1 MHz.  Then the loop above divides it by 4, to give 250 KHz on
 
pin B5.   You can measure that with an oscillocope or frequency meter. | 
			 
		  | 
	
	
		  | 
	
	
		
			volcane
 
 
  Joined: 23 Feb 2008 Posts: 29
  
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Thu Mar 26, 2009 2:35 pm     | 
				     | 
			 
			
				
  | 
			 
			
				| Thanks works perfectly | 
			 
		  | 
	
	
		  | 
	
	
		 |