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

DSP33FJ56MC710- PWM

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



Joined: 21 Feb 2008
Posts: 7

View user's profile Send private message

DSP33FJ56MC710- PWM
PostPosted: Sun Feb 24, 2008 10:08 pm     Reply with quote

HI,
Can anyone help me, to setup pwm for DSP33FJ56MC710. I have try this


setup_ccp2(ccp_pwm); //c1 for pwm
setup_timer_2(T2_DIV_BY_1,127,1); //40khz
set_pwm2_duty(mtspeed); // mtspeed=MY VALUE

but it showing error. please guide me. 10q. Idea
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Feb 25, 2008 12:35 am     Reply with quote

Look in this example file for PWM code for the PCD compiler:
Quote:
c:\Program Files\picc\Examples\Ex_pwm.c
sivaganapathy



Joined: 21 Feb 2008
Posts: 7

View user's profile Send private message

can't find for pcd
PostPosted: Mon Feb 25, 2008 3:16 am     Reply with quote

hi'
i still can't find 4 pcd.
in my example they just have 4 pcm and pch.can u help me? in my C:\Program Files\PICC\Examples\EX_PWM it just have this:


#if defined(__PCM__)
#include <16F877.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=10000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, BRGH1OK) // Jumpers: 8 to 11, 7 to 12

#elif defined(__PCH__)
#include <18F452.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=10000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, BRGH1OK) // Jumpers: 8 to 11, 7 to 12
#endif


void main() {
char selection;
byte value;


printf("\r\nFrequency:\r\n");
printf(" 1) 19.5 khz\r\n");
printf(" 2) 4.9 khz\r\n");
printf(" 3) 1.2 khz\r\n");

do {
selection=getc();
} while((selection<'1')||(selection>'3'));


setup_ccp1(CCP_PWM); // Configure CCP1 as a PWM

// The cycle time will be (1/clock)*4*t2div*(period+1)
// In this program clock=10000000 and period=127 (below)
// For the three possible selections the cycle time is:
// (1/10000000)*4*1*128 = 51.2 us or 19.5 khz
// (1/10000000)*4*4*128 = 204.8 us or 4.9 khz
// (1/10000000)*4*16*128= 819.2 us or 1.2 khz

switch(selection) {
case '1' : setup_timer_2(T2_DIV_BY_1, 127, 1);
break;
case '2' : setup_timer_2(T2_DIV_BY_4, 127, 1);
break;
case '3' : setup_timer_2(T2_DIV_BY_16, 127, 1);
break;
}



setup_port_a(ALL_ANALOG);
setup_adc(adc_clock_internal);
set_adc_channel( 0 );
printf("%c\r\n",selection);

while( TRUE ) {
value=read_adc();

printf("%2X\r",value);

set_pwm1_duty(value); // This sets the time the pulse is
// high each cycle. We use the A/D
// input to make a easy demo.
// the high time will be:
// if value is LONG INT:
// value*(1/clock)*t2div
// if value is INT:
// value*4*(1/clock)*t2div
// for example a value of 30 and t2div
// of 1 the high time is 12us
// WARNING: A value too high or low will
// prevent the output from
// changing.
}

}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Feb 25, 2008 11:11 am     Reply with quote

Send an email to CCS support and ask them for the latest EX_PWM.c
that has code for the PCD compiler.
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