View previous topic :: View next topic |
Author |
Message |
andys
Joined: 23 Oct 2006 Posts: 175
|
Problem with timer1 |
Posted: Sun Dec 30, 2012 7:32 am |
|
|
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
|
|
Posted: Sun Dec 30, 2012 9:35 am |
|
|
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
|
Problem with timer1 |
Posted: Sun Dec 30, 2012 10:13 am |
|
|
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
|
|
Posted: Sun Dec 30, 2012 12:36 pm |
|
|
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: 19539
|
|
Posted: Sun Dec 30, 2012 2:35 pm |
|
|
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 |
|
|
|