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

max PWM problem PIC18F4520

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








max PWM problem PIC18F4520
PostPosted: Mon Jul 27, 2009 3:02 pm     Reply with quote

I cant seem to get a maximimum PWM output using timer2.

Theoretically I using a 4Mhz clock I should be able to get a 1Mhz PWM output. I have tested the following code and do not get any output from ccp1 or ccp2 in PWM mode. The does not work until a get preload a value of 50 or above.

I can't find any talk of a min preload or max pwm speeds relative to clock speed. Am i missing something here. What is the maximum PWM speed relative to clock that i can have?

PIC18F4520
compiler 4.083

Code:
#include <18F4520.h>
#fuses INTRC,MCLR
#fuses CCP2B3  //multiplex ccp2 to rb3
#use delay(clock=4000000)


//*********************************************************************
void main(){

set_tris_b(0x00);
set_tris_c(0x00);

setup_ccp1(CCP_PWM);
setup_ccp2(CCP_PWM);

setup_timer_2(T2_DIV_BY_1,0,1);//1mhz
//1/((4*1*(0+1)*1)/4Mhz) = 1 Mhz oscillation

set_pwm1_duty(50);//is this duty cycle or % time on!?
set_pwm2_duty(50);

while(1){

delay_ms(1);

}//while
}//main
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jul 27, 2009 3:18 pm     Reply with quote

No, it's not a percentage.

See Ttelmah's post at the end of this thread, which shows how to
get the maximum PWM frequency:
http://www.ccsinfo.com/forum/viewtopic.php?p=99719
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