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

pwm and interrupt on change on 18f2431

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



Joined: 02 Jan 2007
Posts: 18

View user's profile Send private message

pwm and interrupt on change on 18f2431
PostPosted: Tue Feb 19, 2008 1:36 pm     Reply with quote

Hello,

I'm using an 18f2431 and I want to be able to have two pwm outputs and also independently use two port b pins as inputs using the interrupt on change feature.

I was intending to use the power pwm feature on the chip for the two pwm outputs, but it looks like I have to give up two pins per pwm channel, which seems wasteful. As I've understood it each channel is allocated to two adjacent port b outputs, so pwm0 is on b0 and b1, pwm 1 on b2 & b3, and pwm 3 on b4 and b5. So I was thinking I could use pwm channel 3 leaving pins b0-b3 free. But I'm having a great deal of difficulty getting this to work and can't work out a configuration that'll give me the results I want. Is what I've described possible?

Any help is really appreciated as I'm finding the datasheet somewhat cryptic!

Thanks in advance. If I need to provide more information please let me know.

Luke
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Feb 19, 2008 6:21 pm     Reply with quote

Quote:

So I was thinking I could use pwm channel 3 leaving pins b0-b3 free

PWM channel 3 is not implemented in 18F2431. Only channels 0, 1, 2
are available. So you must mean you want to use Channel 2.

The PWM pin assignment options are listed in the 18F2431 data sheet.
Quote:

Ch. 2
RB5 -- PWM4
RB4 -- PWM5

Ch. 1
RB3 -- PWM3
RB2 -- PWM2

Ch. 0
RB1 -- PWM1
RB0 -- PWM0


The available combinations are listed below. It doesn't show a setting
to select PWM channel 2 only.
Quote:

REGISTER 17-3: PWMCON0: PWM CONTROL REGISTER 0

bits 6-4 PWMEN2:PWMEN0: PWM Module Enable bits

111 =All odd PWM I/O pins enabled for PWM output.
110 =PWM1, PWM3 pins enabled for PWM output.
101 =All PWM I/O pins enabled for PWM output.
100 =PWM0,PWM1,PWM2,PWM3,PWM4 and PWM5 pins enabled for PWM output.
011 =PWM0, PWM1, PWM2 and PWM3 I/O pins enabled for PWM output.
010 =PWM0 and PWM1 pins enabled for PWM output.
001 =PWM1 pin is enabled for PWM output.
000 =PWM module disabled. All PWM I/O pins are general purpose I/O.
Quote:
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