TimerTick on PIC18 port

hermarcel wrote on Friday, November 26, 2004:

Studying the PIC18-port I came across the following line in port.c:

OpenTimer1( T1_16BIT_RW & T1_SOURCE_INT & T1_PS_1_1 & T1_CCP1_T3_CCP2 );

Reading “MPLAB_C18_Libraries_51297c.pdf” on www.microchip.com to figure out what this function does, confuses me. The argument “T1_CCP1_T3_CCP2” is not defined for OpenTimer1, it’s only defined for OpenTimer3. Can someone enlighten me on this?

Marcel

nobody wrote on Friday, November 26, 2004:

The C18 header file does not define T1_CCP1_T3_CCP2 for all devices.  Maybe the library documentatin does not take this into account.

#if defined(__18F6520) || defined(__18F6620) || defined(__18F6720) ||
    defined(__18F8520) || defined(__18F8620) || defined(__18F8720) ||
    defined(__18F6620) || defined(__18F6621) ||
    defined(__18F8620) || defined(__18F8621)

#define T34_SOURCE_CCP             0b11111111
#define T12_CCP12_T34_CCP345    0b11110111
#define T12_CCP1_T34_CCP2345    0b10111111
#define T12_SOURCE_CCP             0b10110111

#else

#define T3_SOURCE_CCP         0b11111111
#define T1_CCP1_T3_CCP2       0b10111111
#define T1_SOURCE_CCP         0b10110111

#endif

nobody wrote on Friday, November 26, 2004:

My library ref manual (dated 2003) has the CCP section missing for timer 1.

The code example is given as:

OpenTimer1( TIMER_INT_ON &
T1_8BIT_RW &
T1_SOURCE_EXT &
T1_PS_1_1 &
T1_OSC1EN_OFF &
T1_SYNC_EXT_OFF &
T1_SOURCE_CCP );

But it does not define the T1_SOURCE_CCP options for timer 1.

Compare this to timer 3 where the code snippet is almost the same (T1->T3) but just above it there is a section "Use With CCP:" that defines values for T3_SOURCE_CCP.

Looks to me just like an omission from the
manual.

hermarcel wrote on Saturday, November 27, 2004:

The weird thing then is that the datasheet (eg. 18F452) also defines it only for timer3…

rtel wrote on Saturday, November 27, 2004:

Hi Marcel,

This does look odd looking back.  I got the constant value from the header file - and presuming that the timer is working correctly and that the header file is not incorrect - it seems ok.

I need to investigate futher and see exactly what the timer function library call does and compare this to the datasheet.

Regards.

hermarcel wrote on Saturday, November 27, 2004:

Well, I assume it works. So, your call should be correct. I was just wondering, nothing more. It’s of course ok If you like to investigate this, but my quriosity (?) is already satisfied :slight_smile: