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 CCS Technical Support

Variable Frequency PWM

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



Joined: 28 Apr 2004
Posts: 2

View user's profile Send private message

Variable Frequency PWM
PostPosted: Sat May 08, 2004 6:14 am     Reply with quote

Hi ,

I am using 16F819 in my design to generate a variable Frequency PWM
using CCP1 in my application

I have written a small Test Module
The module for single freq PWM seems to be working fine
I get the exact freq what I want by setting different values using
timer_setup() function

But when I continuously update the timer2 with different CCP1 Output is always Low

const long value = 520;
const byte loop = 1;
int selection;
int i;
void main()
{
OSCCON=0x74;
selection ==1;
while (loop == 1)
{

output_low(LED6);
delay_ms(1);

for (i=1;i<10;i++)
{
output_high(LED6);
set_pwm1_duty(value);
set_tris_b(0x00);

switch(selection)
{
case '1' : setup_timer_2(T2_DIV_BY_1, 255, 1);
break;
case '2' : setup_timer_2(T2_DIV_BY_4, 255, 1);
break;
case '3' : setup_timer_2(T2_DIV_BY_16, 255, 1);
break;
}
setup_ccp1(CCP_PWM); // Configure CCP1 as a PWM
}
if (selection > 3)
selection == 1;

else

selection ++;

} //while
} // main()

//EOF

In this I want to change the frequency continuously 350Hz,1.74khz& 7.6KHz using 'Selection' variable

When I checked individually , it was working fine
Am I missing something here for updating TIMER2 values?

Any suggestion would be of great help

Thanks & Best Regards,
Raghu
Neutone



Joined: 08 Sep 2003
Posts: 839
Location: Houston

View user's profile Send private message

PostPosted: Sat May 08, 2004 7:37 am     Reply with quote

case '1'

case 1

Almost looks the same.
Guest








PostPosted: Sat May 08, 2004 7:52 am     Reply with quote

Thanks neutone
Sorry for this stupid question
I am a newbie..

Thanks & Best regards,
Raghu
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