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

Problem with timer1

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



Joined: 23 Oct 2006
Posts: 175

View user's profile Send private message

Problem with timer1
PostPosted: Sun Dec 30, 2012 7:32 am     Reply with quote

I tried to use
setup_timer1(T1_INTERNAL|T1_DIV_BY_8);

but the header of the pic which i use (dspic33fj128mc802) is not support the
T1_INTERNAL|T1_DIV_BY_8.

Can i replace it with setup_timer1(TMR_INTERNAL|TMR_DIV_BY_8 );

furthermore what is the different between T1_INTERNAL and TMR_INTERNAL ???
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Sun Dec 30, 2012 9:35 am     Reply with quote

Quote:
Can i replace it with setup_timer1(TMR_INTERNAL|TMR_DIV_BY_8 ); ...
........ ???
It's quicker to try it and see, rather than create a new thread.

The allowed parameters SHOULD be in the relevant .h file

Mike
andys



Joined: 23 Oct 2006
Posts: 175

View user's profile Send private message

Problem with timer1
PostPosted: Sun Dec 30, 2012 10:13 am     Reply with quote

You didn't understand what i mean.

I replace the parameters and is acceptable by the compiler.

My question are :

(1)Why T1_INTERNAL|T1_DIV_BY_8 is not supported by the header file ???
(I think the mcu has this hardware) and how to fix this problem????

(2)What is the meaning in the behavior of the mcu with this parameters?
rikotech8



Joined: 10 Dec 2011
Posts: 376
Location: Sofiq,Bulgariq

View user's profile Send private message

PostPosted: Sun Dec 30, 2012 12:36 pm     Reply with quote

If you look at the header file you will se that you haven't another choice. At the header file the options for setting timer1 are:
Code:

#define TMR_DISABLED 0x0000
#define TMR_INTERNAL 0xA000
#define TMR_EXTERNAL 0xA002
#define TMR_GATE     0x0040
#define T1_EXTERNAL_SYNC 0xA006 //This only applies to Timer1
#define T1_EXTERNAL_RTC  0xC002 //This only applies to Timer1

#define TMR_DIV_BY_1   0x0000
#define TMR_DIV_BY_8   0x0010
#define TMR_DIV_BY_64  0x0020
#define TMR_DIV_BY_256 0x0030
#define TMR_32_BIT     0x0008 // Only for even numbered timers

So I can't see T1_INTERNAL|T1_DIV_BY_8 to be used. In your case you have several timers to use. It depends on SETUP_TIMERx the x which timer you are about to use, not inside the brackets.
So declaring this way would be right:
Code:
SETUP_TIMER1(TMR_INTERNAL|TMR_DIV_BY_8);

_________________
A person who never made a mistake never tried anything new.
Ttelmah



Joined: 11 Mar 2010
Posts: 19467

View user's profile Send private message

PostPosted: Sun Dec 30, 2012 2:35 pm     Reply with quote

The reason is simply that on the PIC33, the timers are all basically the same. Hence the separate defines for timer1, timer2 etc., disappear. The function call name defines the timer, then the #defines say what features are wanted on this timer. So TMR_INTERNAL, can be used with all the timers, instead of T1_INTERNAL, which only worked with timer1.

Best Wishes
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