| View previous topic :: View next topic   | 
	
	
	
		| Author | 
		Message | 
	
	
		
			theteaman
 
 
  Joined: 04 Aug 2006 Posts: 98
  
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				| Quick PIC question RE Hz | 
			 
			
				 Posted: Wed Sep 13, 2006 4:56 pm     | 
				     | 
			 
			
				
  | 
			 
			
				Hi
 
 
If I use a 20MHz crystal, the PIC runs at 5MHz or 5,000,000 Hz.... Also, most instructions run for one cycle, with some running for 2 or 3 cycles. 
 
 
Then, say I have a loop that simply toggles an output pin on/off, and say, one iteration of the loop is approximately 10 cycles, would the output pulse of the pin equal 5MHz/10 = 500kHz?
 
 
thanks | 
			 
		  | 
	
	
		  | 
	
	
		
			Douglas Kennedy
 
 
  Joined: 07 Sep 2003 Posts: 755 Location: Florida 
			
			 
			 
			
			
			 
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Wed Sep 13, 2006 5:56 pm     | 
				     | 
			 
			
				
  | 
			 
			
				| Yes goto statements take up two cycles everything else one cycle so if 10 cycles is your total in your loop  the pin will go high and low 5 mhz/10 or 500 khz. | 
			 
		  | 
	
	
		  | 
	
	
		
			theteaman
 
 
  Joined: 04 Aug 2006 Posts: 98
  
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Wed Sep 13, 2006 5:59 pm     | 
				     | 
			 
			
				
  | 
			 
			
				| great, thanks! | 
			 
		  | 
	
	
		  | 
	
	
		 |