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

18f4520 PWM

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



Joined: 17 Jan 2008
Posts: 4

View user's profile Send private message

18f4520 PWM
PostPosted: Thu Jan 17, 2008 8:12 am     Reply with quote

i am a beginner and i hope to find out how PWM works. How it produce sounds or duty cycle. hope someone can help me with the programm thanks.
BLAH_BLAH
Guest







PostPosted: Thu Jan 17, 2008 9:46 am     Reply with quote

1) search the forum
2) look at the ex_pwm.c file in your examples directory
3) read the manual
4) read the datasheet
5) try writing the code. If it doesn't work, post your (very simple) code and ask specific questions.

1-4 aren't necessarily in the correct order, but 5 should be the last step you try! Wink
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jan 17, 2008 12:10 pm     Reply with quote

See this post for a demo program:
http://www.ccsinfo.com/forum/viewtopic.php?t=17729&start=1
colourwheel



Joined: 17 Jan 2008
Posts: 4

View user's profile Send private message

PostPosted: Fri Jan 18, 2008 8:14 am     Reply with quote

mine is pic18f4520 issit the same as the link u post there?
i need to produce a fire engine sound, is that possible? any sample programm?
colourwheel



Joined: 17 Jan 2008
Posts: 4

View user's profile Send private message

PostPosted: Fri Jan 18, 2008 8:23 am     Reply with quote

#include<p18f4520.h>
void main()
{
TRISC=0b11111011;
T2CON=0b00000101;
PR2=249;
CCPR1L=0B1111101;
CCP1COB=0B00001111;
while(1)
}

i only have sounds coming out but it does no sound like a fire engine sound? how do i edit it to make it sound more like it?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jan 18, 2008 12:00 pm     Reply with quote

You should always tell us your overall purpose in your first post.
Put it in the title of your post.
Your purpose is to make music or play a simple tune with the PIC.

CCS has an example file for this. It's in this directory:
Quote:
c:\Program Files\picc\Examples\Ex_Tones.c

Here's a post where someone needed help with it.
http://www.ccsinfo.com/forum/viewtopic.php?p=69356

Mark has posted a ring tone player int the Code Library:
http://www.ccsinfo.com/forum/viewtopic.php?t=22010

There are many other posts about playing sounds on the PIC.
Use the forum's search page to find them.
http://www.ccsinfo.com/forum/search.php
colourwheel



Joined: 17 Jan 2008
Posts: 4

View user's profile Send private message

PostPosted: Sun Jan 20, 2008 12:37 am     Reply with quote

ok nex time i know what to put for the title and thanks for the help!!
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