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

generate a PWM from pic

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








generate a PWM from pic
PostPosted: Tue May 29, 2007 10:05 am     Reply with quote

I need help to use the PWM feature to generate 32 bits pulses, the pulse are generate by reading the a potentiometer from RA0,
all these 32 pulses are like this:

16 high pulse (40usec)-these pulses are use as a markers between data bits (always 40usec pluse)
16 low pulse (either 40usec or 80usec)-these pulse are represent valid data example =40usec is a 0, 80usec is a 1, the data will change according to the the RA0 port.


40us 40usec 80usec 40usec 80usec 40usec
----------- -------- ------- ------
|_____| |___________| |__________| etc.

Any body have a code that I can use?

I use the PIC18F877A
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jun 01, 2007 4:38 pm     Reply with quote

If you tell us what device you're trying to control, then we can probably
help you more easily. Tell us the manufacturer and the part number.
Provide a link to the website.

When you do ASCII art, put it in a Code block. Then click the Preview
button to see what it will look like when it's posted. Make any required
changes and Preview it again until it looks correct.
Steve H
Guest







PostPosted: Sun Jun 03, 2007 7:37 am     Reply with quote

I think you might be able to control the PWM enough to change the PWM value on the fly between every pulse - but I think a simpler approach might be to bit bang the data out.

Have a loop that goes through the bits one at a time (shift left or shift right).
Put out the marker - 16 uS
Put out the 40 or 80 uS pulse base on a one or zero of the shifted data
Loop again

There is an app note on the Microchip website about generating high resolution PWM pulses which you might want to take a look at for the PWM solution.

HTH - Steve H.
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