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

2 pwm...is it possible?

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



Joined: 13 Jul 2010
Posts: 45

View user's profile Send private message

2 pwm...is it possible?
PostPosted: Thu Jul 15, 2010 6:15 am     Reply with quote

Hello I am doing multiple tests 18f14k50 and I'm trying to generate two PWM ... CCS shows me as the availability of 3 CCP use those to generate two frequencies of 1 MHz and 1,5mHz? I use a 48MHz quartz ...
Code:

   setup_timer_1(T1_DIV_BY_1);           
   setup_timer_2(T2_DIV_BY_16,255,1);
   setup_ccp1(CCP_PWM);             
   setup_ccp2(CCP_PWM);
     set_pwm1_duty(16);
   set_pwm2_duty(18);


I tried this two frequencies to generate any frequencies but only works RC5 ... why?


Last edited by denis_11 on Thu Jul 15, 2010 1:19 pm; edited 1 time in total
denis_11



Joined: 13 Jul 2010
Posts: 45

View user's profile Send private message

PostPosted: Thu Jul 15, 2010 10:29 am     Reply with quote

nobody has ever used the pwm? I just wanted to know if it was possible to obtain with this pic two pwm
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jul 15, 2010 11:50 am     Reply with quote

Read the data sheet. Type this into Google:
Quote:
PIC18F14K50 site:microchip.com

That quickly gets you the link to the page for the 18F14K50.
From there you can download the data sheet:
http://ww1.microchip.com/downloads/en/DeviceDoc/41350D.pdf
Look at pages 3 and 4 for a summary of the peripherals on the PIC:
Quote:

• Enhanced Capture/Compare/PWM (ECCP) module:
- One, two, three, or four PWM outputs
- Selectable polarity
- Programmable dead time
- Auto-shutdown and Auto-restart

Code:

              ECCP
             (pwm)
PIC18F14K50    1

The answer is: There is only one PWM module on the PIC (CCP1).
However, the same PWM signal can be output on 1 to 4 pins. This is
called "pulse steering" mode.

If this is what you want to do, then post your compiler version.
denis_11



Joined: 13 Jul 2010
Posts: 45

View user's profile Send private message

PostPosted: Thu Jul 15, 2010 1:17 pm     Reply with quote

My compiler version is 4.106 and I want to generate two different frequencies ... one of 1 MHz and a second of 1.5 MHz ... then I would also use the comparator simultaneously ... you say that this is possible? I do not know what to do ... you have an example to show me? thanks
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jul 15, 2010 1:44 pm     Reply with quote

Quote:

I want to generate two different frequencies ... one of 1 MHz and a
second of 1.5 MHz.

You need 2 hardware CCP modules to do that. The 18F45K50 only has
one CCP module.

You need to use a PIC that has two separate CCP modules (CCP1 and CCP2).
denis_11



Joined: 13 Jul 2010
Posts: 45

View user's profile Send private message

PostPosted: Thu Jul 15, 2010 2:07 pm     Reply with quote

ah ok ... and with a 18F2550 can generate two different frequencies? it has 2 CCP...
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jul 15, 2010 2:56 pm     Reply with quote

Actually that's not going to work. You need two PWM modules, but each
one must have it's own separate timebase. Some PICs have this.
The 18F2520 does not. Both PWM channels run off Timer2 in that PIC.

The 18F4431 series does have two separate Timebases for PWM:
http://www.ccsinfo.com/forum/viewtopic.php?t=37206
There are some other PICs that also have this.

But with two PWM frequencies of 1 MHz and 1.5 MHz, the duty cycle
range will be very small. You won't get 256 PWM levels. You'll just
get a few. Also, you'll need to use a 12 MHz or 24 MHz crystal.

Are you sure you want to do this ? What's the purpose of your project ?
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