| View previous topic :: View next topic   | 
	
	
	
		| Author | 
		Message | 
	
	
		
			Chris
 
 
  Joined: 11 Nov 2004 Posts: 8
  
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				| PIC16F684 PIN_C0 wont stay high when set. | 
			 
			
				 Posted: Wed Dec 29, 2004 11:21 am     | 
				     | 
			 
			
				
  | 
			 
			
				Hi All,
 
I am trying to finish a servo controller routine and noticed the motor gets very twitchy when running at certain speeds.
 
 
I isolated the faulty code and recreated the problem with the following snippet:
 
#include <16F684.h>
 
	           
 
#fuses HS,NOWDT,NOPUT,NOMCLR,NOPROTECT,NOBROWNOUT,NOIESO,NOFCMEN,NOCPD
 
#use delay(clock=20000000)
 
 
main()
 
{
 
	*0x91=0;			//clear ANSEL
 
	*0x1F=0;			//ADCON0
 
	*0x9F=0;			//ADCON1
 
	*0x85=0;			//TRISA
 
	*0x87=0;			//TRISC
 
	*0x19=0;			//CMCON0
 
	*0x16=0;			//PWM1CON
 
	while(1)
 
	{
 
		OUTPUT_high ( PIN_C0 );
 
		OUTPUT_high ( PIN_C2 );
 
		
 
	}
 
}
 
 
I tried clearing as many registers as possible so they arent configured as somthing else. Have I got them all?
 
 
I want this code to set C0 high and C2 high. What I get is C0 creates a high frequency pulse train. It goes high until C2 is set then it goes low until C0 is set high again. C2 stays low and never goes high. Odd?
 
 
I have already had advice which highlighted faults in the CCS compiler for the 684 CCP features (which affected the digital pins too) and now suspect either another compiler fault or I havent configured something correctly but I have spent lots of time trying to track down the fault.
 
 
I can run the final code perfectly on a PIC16F877 version of the hardware.
 
 
Advice appreciated please.
 
 
Best Regards
 
 
Chris | 
			 
		  | 
	
	
		  | 
	
	
		
			PCM programmer
 
 
  Joined: 06 Sep 2003 Posts: 21708
  
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Wed Dec 29, 2004 2:24 pm     | 
				     | 
			 
			
				
  | 
			 
			
				This question should be re-posted in the General Discussion Forum.
 
You posted it in the Programmers forum by mistake. | 
			 
		  | 
	
	
		  | 
	
	
		
			drh
 
 
  Joined: 12 Jul 2004 Posts: 193 Location: Hemet, California USA 
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Wed Dec 29, 2004 2:25 pm     | 
				     | 
			 
			
				
  | 
			 
			
				You need to read the data sheet, DS41202C, page 40. _________________ David | 
			 
		  | 
	
	
		  | 
	
	
		 |