PCM programmer
 
 
  Joined: 06 Sep 2003 Posts: 21708
  
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Sat May 05, 2007 1:00 am     | 
				     | 
			 
			
				
  | 
			 
			
				With respect pin to C5, it's behaving correctly for the Full Bridge mode.
 
It's the P1A pin in that mode.   According to Figure 11-6 in the 16F685
 
data sheet, pin C5 will be either a constant high or a constant low,
 
depending upon whether you're going in forward or reverse.   
 
So pin C5 is OK.
 
 
 
There is a note in Section 11.5 of the data sheet (PWM Enhanced mode).
 
It says:
 
 	  | Quote: | 	 		  | The TRIS register value for each PWM output must be configured appropriately. | 	  
 
However, the ASM code generated by the compiler doesn't do this.
 
It only sets pin C5 as a low-level output pin.   It leaves the other pins
 
(C2, C3, C4) in the default state, which is as input pins.
 
 
Here's something you could try.   Add a line of code after each
 
setup_ccp1() function, to manually force pins C2-C5 to be outputs.
 
Add the lines shown in bold below.
 
 	  | Quote: | 	 		  
 
#include <16F685.h>
 
#fuses XT,NOWDT,BROWNOUT,PUT 
 
#use delay (clock=4000000) 
 
 
//================================= 
 
void main() 
 
{ 
 
 
// Setup the ECCP for PWM in full bridge mode. 
 
setup_ccp1(CCP_PWM_FULL_BRIDGE | CCP_PWM_H_H);
 
set_tris_c(0xC3); // Set pins C2-C5 as outputs 
 
setup_timer_2(T2_DIV_BY_1, 255, 1); 
 
 
set_pwm1_duty(100); 
 
    
 
 
// Switch the H-Bridge outputs between forward 
 
// and reverse every 5 seconds. 
 
while(1) 
 
  { 
 
   // Run forward for 5 seconds. 
 
   setup_ccp1(CCP_PWM_FULL_BRIDGE | CCP_PWM_H_H); 
 
   set_tris_c(0xC3);  // Set pins C2-C5 as outputs
 
   delay_ms(5000); 
 
 
   // Run in reverse for 5 seconds. 
 
   setup_ccp1(CCP_PWM_FULL_BRIDGE_REV  | CCP_PWM_H_H); 
 
   set_tris_c(0xC3);  // Set pins C2-C5 as outputs
 
   delay_ms(5000); 
 
  } 
 
 
} | 	  
 
Then compile it and program it.   Then when it's running, look at pin C2
 
in forward mode, and pin C4 in reverse mode.    You should see PWM
 
pulses on them. | 
			 
		  |