CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

PWM,CCP5,Timer4,PIC18F45K22

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
norm



Joined: 19 Aug 2010
Posts: 4

View user's profile Send private message

PWM,CCP5,Timer4,PIC18F45K22
PostPosted: Fri Sep 10, 2010 1:07 pm     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group