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

what is CCP_PWM_PLUS_3

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



Joined: 07 Mar 2005
Posts: 2

View user's profile Send private message Visit poster's website MSN Messenger

what is CCP_PWM_PLUS_3
PostPosted: Mon Mar 07, 2005 11:50 am     Reply with quote

hi, first I want to apologize for my English, all that I write in this forum is with the help of a translator.

seeing the help of the CCS, I find like option of configuration of the PWM, the option CCP_PWM_PLUS_3, but in the help of PCW I canīt find answer about so that this configuration is used.
if somebody could inform that it is this option.
thanks to all

for if to somebody it interests him, I am carrying out a project with the integrated ADXL202 (2-Axis Acceleration Sensor), all info is in Spanish but there is good graphics of some test and the calibration.

for some info visit www.nodolujan.com.ar/gabrielsosa

bye
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Mar 07, 2005 12:50 pm     Reply with quote

CCS provides two methods to set the 10-bit PWM duty cycle.
In one method, you give a 16-bit value to the set_pwm_duty1()
function. (The lower 10 bits is the duty cycle).

In the other method, you give an 8-bit value to the set_pwm_duty1().
This sets the upper 8 bits of the 10-bit value. Then the lower 2 bits are
set by giving a special constant value to the setup_ccp1() function.
These constants are:
Code:

CCP_PWM                  lower 2 bits = 0
CCP_PWM_PLUS_1      lower 2 bits = 1
CCP_PWM_PLUS_2      lower 2 bits = 2
CCP_PWM_PLUS_3      lower 2 bits = 3


Both methods give the same result. Compile the program below
and run it. It programs the duty cycle with each method, and then
it reads the PWM registers and displays these results:

CCPR1L register value = 40
CCP1CON register value = 03
CCPR1L register value = 40
CCP1CON register value = 03

It's easier to use the 10-bit method. I think the CCP_PWM_PLUS_x
method was probably used by the earliest versions of the compiler.
Then they got the idea of using the 10-bit method and added it.

Code:
#include <16F877.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

#byte CCPR1L = 0x15
#byte CCP1CON = 0x17

void display_CCP_regs(void)
{
printf("CCPR1L register value = %x\n\r", CCPR1L);
printf("CCP1CON register value = %x\n\r", (CCP1CON >> 4) & 0x3);
}

//============================
main()
{

// Program the 10-bit duty cycle using the "long" parameter method.
setup_ccp1(CCP_PWM);
set_pwm1_duty(0x103);  // Give a 10 bit value to the function.
display_CCP_regs();

// Program the 10-bit duty cycle using 8 bit method.
setup_ccp1(CCP_PWM_PLUS_3);   // Set the LSB = 3
set_pwm1_duty(0x40);    //  Give an 8-bit value to the function.
display_CCP_regs();

while(1);
}
pendexgabo



Joined: 07 Mar 2005
Posts: 2

View user's profile Send private message Visit poster's website MSN Messenger

what is CCP_PWM_PLUS_3
PostPosted: Mon Mar 07, 2005 3:47 pm     Reply with quote

I could understand.

do I want to wonder, is one able to what I write?

tanks for all
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