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

18FXX31 PWM TIME BASE INTERRUPS

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



Joined: 06 Apr 2004
Posts: 2

View user's profile Send private message

18FXX31 PWM TIME BASE INTERRUPS
PostPosted: Fri Aug 27, 2004 12:48 pm     Reply with quote

I am writing PWM code to drive LED's. I would like to us an interrup to help me to know when to update the duty cycle register. How do I read PTMOD AND PTOPS? Confused Question
dyeatman



Joined: 06 Sep 2003
Posts: 1912
Location: Norman, OK

View user's profile Send private message

Reading/Writing Internal Registers
PostPosted: Fri Aug 27, 2004 1:38 pm     Reply with quote

See the CCS manual FAQ section on Reading/Writing internal registers on page 213

All the interrupts and PWM settings are defined in the chip header file 18F4331.h etc.

According to the data sheet the PTMOD and PTOPS bits are in register PTCOM0 at 0xF7F in the 18F4331 chip
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Aug 27, 2004 1:42 pm     Reply with quote

Quote:
How do I read PTMOD AND PTOPS ?

Create a structure with bitfields. Then define the memory address
of that register with the #locate statement. (Or, the #byte statement
would work as well, in this case). Then you can read or write to the
register bits, just as if they were memory variables.

Remember that when you read a bitfield, the compiler will right-justify
the result.

Code:
#include <18F4431.H>
#fuses XT, NOPROTECT, PUT, NOBROWNOUT, NOWDT, NOLVP
#use delay(clock=4000000)

struct
{
unsigned char ptmod:2;
unsigned char ptckps:2;
unsigned char ptops:4;
}PTCON0;

#locate PTCON0 = 0xF7F

//=================================
main()
{
char value;

value = PTCON0.ptops;

value = PTCON0.ptmod;

while(1);
}
 
 
dslapo



Joined: 06 Apr 2004
Posts: 2

View user's profile Send private message

18FXX31 PWM TIME BASE INTERRUPS
PostPosted: Fri Aug 27, 2004 2:20 pm     Reply with quote

Thank you for your time.

Dave Laughing
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