norm
 
 
  Joined: 19 Aug 2010 Posts: 4
  
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				| PWM,CCP5,Timer4,PIC18F45K22 | 
			 
			
				 Posted: Fri Sep 10, 2010 1:07 pm     | 
				     | 
			 
			
				
  | 
			 
			
				I can't get a PWM signal to come out of the RE2 pin 27.
 
 
Has anyone else been successful implementing this?
 
 
Watching in the MPLAB, CCPR5H never gets loaded from the CCPR5L.
 
 	  | Code: | 	 		  
 
#include <18F45K22.H>
 
 
#fuses INTRC_IO, NOLVP, NOPROTECT, NOWDT, NOPUT, BROWNOUT, NOPBADEN, CCP2C1
 
#use delay(clock=16000000)
 
 
#byte ADCON1 = 0xFC1
 
#bit  TRIGSEL = ADCON1.7
 
#byte CCP5CON = 0xF54
 
#bit  DC5B1 = CCP5CON.5
 
#bit  DC5B0 = CCP5CON.4
 
#byte CCPTMRS1 = 0xF48
 
#bit  C5TSEL1 = CCPTMRS1.3
 
#bit  C5TSEL0 = CCPTMRS1.2
 
#byte PR4 = 0xF52
 
#byte TMR4 = 0xF53
 
#byte CCPR5L = 0xF55
 
#byte CCPR5H = 0xF56
 
#byte T4CON = 0xF51
 
#bit  TMR4ON = T4CON.2
 
#byte PIR5 = 0xF7E
 
#bit  TMR4IF = PIR5.0
 
 
void main()
 
{
 
char dummy=0;
 
  
 
  setup_oscillator(OSC_16MHZ,0);
 
  disable_interrupts(GLOBAL);
 
  enable_interrupts(GLOBAL);
 
  C5TSEL1 = 0;  // Select Timer 4
 
  C5TSEL0 = 1;  // Select Timer 4
 
  setup_timer_4(T4_DIV_BY_1,160,1);
 
  setup_ccp5(CCP_PWM);
 
  set_pwm5_duty(100L);
 
  while (1)
 
  {
 
  dummy++;
 
  }
 
} /*********************** end of main *************/
 
 | 	  
 
Section of List file
 
 	  | Code: | 	 		  
 
....................   C5TSEL1 = 0; 
 
003E:  MOVLB  F
 
0040:  BCF    x48.3
 
....................   C5TSEL0 = 1; 
 
0042:  BSF    x48.2
 
....................   setup_timer_4(T4_DIV_BY_1,160,1); 
 
0044:  MOVLW  00
 
0046:  IORLW  04
 
0048:  MOVWF  x51
 
004A:  MOVLW  A0
 
004C:  MOVWF  x52
 
....................   setup_ccp5(CCP_PWM); 
 
004E:  BCF    F96.2
 
0050:  BCF    F8D.2
 
0052:  MOVLW  0C
 
0054:  MOVWF  x54
 
....................   set_pwm5_duty(100L); 
 
0056:  MOVLW  19
 
0058:  MOVWF  x55
 
005A:  MOVF   x54,W
 
005C:  ANDLW  CF
 
005E:  MOVWF  x54
 
 | 	  
 
I'm surprised to see this in the list, some statements make use of it, and others don't.
 
003E:  MOVLB  F
 
 
Thanks  Norm | 
			 
		  |