2 FreeRTOS V7.3.0 - Copyright (C) 2012 Real Time Engineers Ltd.
\r
4 FEATURES AND PORTS ARE ADDED TO FREERTOS ALL THE TIME. PLEASE VISIT
\r
5 http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
\r
7 ***************************************************************************
\r
9 * FreeRTOS tutorial books are available in pdf and paperback. *
\r
10 * Complete, revised, and edited pdf reference manuals are also *
\r
13 * Purchasing FreeRTOS documentation will not only help you, by *
\r
14 * ensuring you get running as quickly as possible and with an *
\r
15 * in-depth knowledge of how to use FreeRTOS, it will also help *
\r
16 * the FreeRTOS project to continue with its mission of providing *
\r
17 * professional grade, cross platform, de facto standard solutions *
\r
18 * for microcontrollers - completely free of charge! *
\r
20 * >>> See http://www.FreeRTOS.org/Documentation for details. <<< *
\r
22 * Thank you for using FreeRTOS, and thank you for your support! *
\r
24 ***************************************************************************
\r
27 This file is part of the FreeRTOS distribution.
\r
29 FreeRTOS is free software; you can redistribute it and/or modify it under
\r
30 the terms of the GNU General Public License (version 2) as published by the
\r
31 Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
\r
32 >>>NOTE<<< The modification to the GPL is included to allow you to
\r
33 distribute a combined work that includes FreeRTOS without being obliged to
\r
34 provide the source code for proprietary components outside of the FreeRTOS
\r
35 kernel. FreeRTOS is distributed in the hope that it will be useful, but
\r
36 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
\r
37 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
\r
38 more details. You should have received a copy of the GNU General Public
\r
39 License and the FreeRTOS license exception along with FreeRTOS; if not it
\r
40 can be viewed here: http://www.freertos.org/a00114.html and also obtained
\r
41 by writing to Richard Barry, contact details for whom are available on the
\r
46 ***************************************************************************
\r
48 * Having a problem? Start by reading the FAQ "My application does *
\r
49 * not run, what could be wrong?" *
\r
51 * http://www.FreeRTOS.org/FAQHelp.html *
\r
53 ***************************************************************************
\r
56 http://www.FreeRTOS.org - Documentation, training, latest versions, license
\r
57 and contact details.
\r
59 http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
\r
60 including FreeRTOS+Trace - an indispensable productivity tool.
\r
62 Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell
\r
63 the code with commercial support, indemnification, and middleware, under
\r
64 the OpenRTOS brand: http://www.OpenRTOS.com. High Integrity Systems also
\r
65 provide a safety engineered and independently SIL3 certified version under
\r
66 the SafeRTOS brand: http://www.SafeRTOS.com.
\r
70 Changes between V1.2.4 and V1.2.5
\r
72 + Introduced portGLOBAL_INTERRUPT_FLAG definition to test the global
\r
73 interrupt flag setting. Using the two bits defined within
\r
74 portINITAL_INTERRUPT_STATE was causing the w register to get clobbered
\r
75 before the test was performed.
\r
79 + Set the interrupt vector address to 0x08. Previously it was at the
\r
80 incorrect address for compatibility mode of 0x18.
\r
84 + PCLATU and PCLATH are now saved as part of the context. This allows
\r
85 function pointers to be used within tasks. Thanks to Javier Espeche
\r
86 for the enhancement.
\r
90 + TABLAT is now saved as part of the task context.
\r
94 + TBLPTRU is now initialised to zero as the MPLAB compiler expects this
\r
95 value and does not write to the register.
\r
98 /* Scheduler include files. */
\r
99 #include "FreeRTOS.h"
\r
102 /* MPLAB library include file. */
\r
103 #include "timers.h"
\r
105 /*-----------------------------------------------------------
\r
106 * Implementation of functions defined in portable.h for the PIC port.
\r
107 *----------------------------------------------------------*/
\r
109 /* Hardware setup for tick. */
\r
110 #define portTIMER_FOSC_SCALE ( ( unsigned long ) 4 )
\r
112 /* Initial interrupt enable state for newly created tasks. This value is
\r
113 copied into INTCON when a task switches in for the first time. */
\r
114 #define portINITAL_INTERRUPT_STATE 0xc0
\r
116 /* Just the bit within INTCON for the global interrupt flag. */
\r
117 #define portGLOBAL_INTERRUPT_FLAG 0x80
\r
119 /* Constant used for context switch macro when we require the interrupt
\r
120 enable state to be unchanged when the interrupted task is switched back in. */
\r
121 #define portINTERRUPTS_UNCHANGED 0x00
\r
123 /* Some memory areas get saved as part of the task context. These memory
\r
124 area's get used by the compiler for temporary storage, especially when
\r
125 performing mathematical operations, or when using 32bit data types. This
\r
126 constant defines the size of memory area which must be saved. */
\r
127 #define portCOMPILER_MANAGED_MEMORY_SIZE ( ( unsigned char ) 0x13 )
\r
129 /* We require the address of the pxCurrentTCB variable, but don't want to know
\r
130 any details of its type. */
\r
131 typedef void tskTCB;
\r
132 extern volatile tskTCB * volatile pxCurrentTCB;
\r
134 /* IO port constants. */
\r
135 #define portBIT_SET ( ( unsigned char ) 1 )
\r
136 #define portBIT_CLEAR ( ( unsigned char ) 0 )
\r
139 * The serial port ISR's are defined in serial.c, but are called from portable
\r
140 * as they use the same vector as the tick ISR.
\r
142 void vSerialTxISR( void );
\r
143 void vSerialRxISR( void );
\r
146 * Perform hardware setup to enable ticks.
\r
148 static void prvSetupTimerInterrupt( void );
\r
151 * ISR to maintain the tick, and perform tick context switches if the
\r
152 * preemptive scheduler is being used.
\r
154 static void prvTickISR( void );
\r
157 * ISR placed on the low priority vector. This calls the appropriate ISR for
\r
158 * the actual interrupt.
\r
160 static void prvLowInterrupt( void );
\r
163 * Macro that pushes all the registers that make up the context of a task onto
\r
164 * the stack, then saves the new top of stack into the TCB.
\r
166 * If this is called from an ISR then the interrupt enable bits must have been
\r
167 * set for the ISR to ever get called. Therefore we want to save the INTCON
\r
168 * register with the enable bits forced to be set - and ucForcedInterruptFlags
\r
169 * must contain these bit settings. This means the interrupts will again be
\r
170 * enabled when the interrupted task is switched back in.
\r
172 * If this is called from a manual context switch (i.e. from a call to yield),
\r
173 * then we want to save the INTCON so it is restored with its current state,
\r
174 * and ucForcedInterruptFlags must be 0. This allows a yield from within
\r
175 * a critical section.
\r
177 * The compiler uses some locations at the bottom of the memory for temporary
\r
178 * storage during math and other computations. This is especially true if
\r
179 * 32bit data types are utilised (as they are by the scheduler). The .tmpdata
\r
180 * and MATH_DATA sections have to be stored in there entirety as part of a task
\r
181 * context. This macro stores from data address 0x00 to
\r
182 * portCOMPILER_MANAGED_MEMORY_SIZE. This is sufficient for the demo
\r
183 * applications but you should check the map file for your project to ensure
\r
184 * this is sufficient for your needs. It is not clear whether this size is
\r
185 * fixed for all compilations or has the potential to be program specific.
\r
187 #define portSAVE_CONTEXT( ucForcedInterruptFlags ) \
\r
190 /* Save the status and WREG registers first, as these will get modified \
\r
191 by the operations below. */ \
\r
192 MOVFF WREG, PREINC1 \
\r
193 MOVFF STATUS, PREINC1 \
\r
194 /* Save the INTCON register with the appropriate bits forced if \
\r
195 necessary - as described above. */ \
\r
196 MOVFF INTCON, WREG \
\r
197 IORLW ucForcedInterruptFlags \
\r
198 MOVFF WREG, PREINC1 \
\r
201 portDISABLE_INTERRUPTS(); \
\r
204 /* Store the necessary registers to the stack. */ \
\r
205 MOVFF BSR, PREINC1 \
\r
206 MOVFF FSR2L, PREINC1 \
\r
207 MOVFF FSR2H, PREINC1 \
\r
208 MOVFF FSR0L, PREINC1 \
\r
209 MOVFF FSR0H, PREINC1 \
\r
210 MOVFF TABLAT, PREINC1 \
\r
211 MOVFF TBLPTRU, PREINC1 \
\r
212 MOVFF TBLPTRH, PREINC1 \
\r
213 MOVFF TBLPTRL, PREINC1 \
\r
214 MOVFF PRODH, PREINC1 \
\r
215 MOVFF PRODL, PREINC1 \
\r
216 MOVFF PCLATU, PREINC1 \
\r
217 MOVFF PCLATH, PREINC1 \
\r
218 /* Store the .tempdata and MATH_DATA areas as described above. */ \
\r
221 MOVFF POSTINC0, PREINC1 \
\r
222 MOVFF POSTINC0, PREINC1 \
\r
223 MOVFF POSTINC0, PREINC1 \
\r
224 MOVFF POSTINC0, PREINC1 \
\r
225 MOVFF POSTINC0, PREINC1 \
\r
226 MOVFF POSTINC0, PREINC1 \
\r
227 MOVFF POSTINC0, PREINC1 \
\r
228 MOVFF POSTINC0, PREINC1 \
\r
229 MOVFF POSTINC0, PREINC1 \
\r
230 MOVFF POSTINC0, PREINC1 \
\r
231 MOVFF POSTINC0, PREINC1 \
\r
232 MOVFF POSTINC0, PREINC1 \
\r
233 MOVFF POSTINC0, PREINC1 \
\r
234 MOVFF POSTINC0, PREINC1 \
\r
235 MOVFF POSTINC0, PREINC1 \
\r
236 MOVFF POSTINC0, PREINC1 \
\r
237 MOVFF POSTINC0, PREINC1 \
\r
238 MOVFF POSTINC0, PREINC1 \
\r
239 MOVFF POSTINC0, PREINC1 \
\r
240 MOVFF INDF0, PREINC1 \
\r
241 MOVFF FSR0L, PREINC1 \
\r
242 MOVFF FSR0H, PREINC1 \
\r
243 /* Store the hardware stack pointer in a temp register before we \
\r
245 MOVFF STKPTR, FSR0L \
\r
248 /* Store each address from the hardware stack. */ \
\r
249 while( STKPTR > ( unsigned char ) 0 ) \
\r
252 MOVFF TOSL, PREINC1 \
\r
253 MOVFF TOSH, PREINC1 \
\r
254 MOVFF TOSU, PREINC1 \
\r
260 /* Store the number of addresses on the hardware stack (from the \
\r
261 temporary register). */ \
\r
262 MOVFF FSR0L, PREINC1 \
\r
263 MOVF PREINC1, 1, 0 \
\r
266 /* Save the new top of the software stack in the TCB. */ \
\r
268 MOVFF pxCurrentTCB, FSR0L \
\r
269 MOVFF pxCurrentTCB + 1, FSR0H \
\r
270 MOVFF FSR1L, POSTINC0 \
\r
271 MOVFF FSR1H, POSTINC0 \
\r
274 /*-----------------------------------------------------------*/
\r
277 * This is the reverse of portSAVE_CONTEXT. See portSAVE_CONTEXT for more
\r
280 #define portRESTORE_CONTEXT() \
\r
283 /* Set FSR0 to point to pxCurrentTCB->pxTopOfStack. */ \
\r
284 MOVFF pxCurrentTCB, FSR0L \
\r
285 MOVFF pxCurrentTCB + 1, FSR0H \
\r
287 /* De-reference FSR0 to set the address it holds into FSR1. \
\r
288 (i.e. *( pxCurrentTCB->pxTopOfStack ) ). */ \
\r
289 MOVFF POSTINC0, FSR1L \
\r
290 MOVFF POSTINC0, FSR1H \
\r
292 /* How many return addresses are there on the hardware stack? Discard \
\r
293 the first byte as we are pointing to the next free space. */ \
\r
294 MOVFF POSTDEC1, FSR0L \
\r
295 MOVFF POSTDEC1, FSR0L \
\r
298 /* Fill the hardware stack from our software stack. */ \
\r
301 while( STKPTR < FSR0L ) \
\r
305 MOVF POSTDEC1, 0, 0 \
\r
307 MOVF POSTDEC1, 0, 0 \
\r
309 MOVF POSTDEC1, 0, 0 \
\r
315 /* Restore the .tmpdata and MATH_DATA memory. */ \
\r
316 MOVFF POSTDEC1, FSR0H \
\r
317 MOVFF POSTDEC1, FSR0L \
\r
318 MOVFF POSTDEC1, POSTDEC0 \
\r
319 MOVFF POSTDEC1, POSTDEC0 \
\r
320 MOVFF POSTDEC1, POSTDEC0 \
\r
321 MOVFF POSTDEC1, POSTDEC0 \
\r
322 MOVFF POSTDEC1, POSTDEC0 \
\r
323 MOVFF POSTDEC1, POSTDEC0 \
\r
324 MOVFF POSTDEC1, POSTDEC0 \
\r
325 MOVFF POSTDEC1, POSTDEC0 \
\r
326 MOVFF POSTDEC1, POSTDEC0 \
\r
327 MOVFF POSTDEC1, POSTDEC0 \
\r
328 MOVFF POSTDEC1, POSTDEC0 \
\r
329 MOVFF POSTDEC1, POSTDEC0 \
\r
330 MOVFF POSTDEC1, POSTDEC0 \
\r
331 MOVFF POSTDEC1, POSTDEC0 \
\r
332 MOVFF POSTDEC1, POSTDEC0 \
\r
333 MOVFF POSTDEC1, POSTDEC0 \
\r
334 MOVFF POSTDEC1, POSTDEC0 \
\r
335 MOVFF POSTDEC1, POSTDEC0 \
\r
336 MOVFF POSTDEC1, POSTDEC0 \
\r
337 MOVFF POSTDEC1, INDF0 \
\r
338 /* Restore the other registers forming the tasks context. */ \
\r
339 MOVFF POSTDEC1, PCLATH \
\r
340 MOVFF POSTDEC1, PCLATU \
\r
341 MOVFF POSTDEC1, PRODL \
\r
342 MOVFF POSTDEC1, PRODH \
\r
343 MOVFF POSTDEC1, TBLPTRL \
\r
344 MOVFF POSTDEC1, TBLPTRH \
\r
345 MOVFF POSTDEC1, TBLPTRU \
\r
346 MOVFF POSTDEC1, TABLAT \
\r
347 MOVFF POSTDEC1, FSR0H \
\r
348 MOVFF POSTDEC1, FSR0L \
\r
349 MOVFF POSTDEC1, FSR2H \
\r
350 MOVFF POSTDEC1, FSR2L \
\r
351 MOVFF POSTDEC1, BSR \
\r
352 /* The next byte is the INTCON register. Read this into WREG as some \
\r
353 manipulation is required. */ \
\r
354 MOVFF POSTDEC1, WREG \
\r
357 /* From the INTCON register, only the interrupt enable bits form part \
\r
358 of the tasks context. It is perfectly legitimate for another task to \
\r
359 have modified any other bits. We therefore only restore the top two bits. \
\r
361 if( WREG & portGLOBAL_INTERRUPT_FLAG ) \
\r
364 MOVFF POSTDEC1, STATUS \
\r
365 MOVFF POSTDEC1, WREG \
\r
366 /* Return enabling interrupts. */ \
\r
373 MOVFF POSTDEC1, STATUS \
\r
374 MOVFF POSTDEC1, WREG \
\r
375 /* Return without effecting interrupts. The context may have \
\r
376 been saved from a critical region. */ \
\r
381 /*-----------------------------------------------------------*/
\r
384 * See header file for description.
\r
386 portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE pxCode, void *pvParameters )
\r
388 unsigned long ulAddress;
\r
389 unsigned char ucBlock;
\r
391 /* Place a few bytes of known values on the bottom of the stack.
\r
392 This is just useful for debugging. */
\r
394 *pxTopOfStack = 0x11;
\r
396 *pxTopOfStack = 0x22;
\r
398 *pxTopOfStack = 0x33;
\r
402 /* Simulate how the stack would look after a call to vPortYield() generated
\r
405 First store the function parameters. This is where the task will expect to
\r
406 find them when it starts running. */
\r
407 ulAddress = ( unsigned long ) pvParameters;
\r
408 *pxTopOfStack = ( portSTACK_TYPE ) ( ulAddress & ( unsigned long ) 0x00ff );
\r
412 *pxTopOfStack = ( portSTACK_TYPE ) ( ulAddress & ( unsigned long ) 0x00ff );
\r
415 /* Next we just leave a space. When a context is saved the stack pointer
\r
416 is incremented before it is used so as not to corrupt whatever the stack
\r
417 pointer is actually pointing to. This is especially necessary during
\r
418 function epilogue code generated by the compiler. */
\r
419 *pxTopOfStack = 0x44;
\r
422 /* Next are all the registers that form part of the task context. */
\r
424 *pxTopOfStack = ( portSTACK_TYPE ) 0x66; /* WREG. */
\r
427 *pxTopOfStack = ( portSTACK_TYPE ) 0xcc; /* Status. */
\r
430 /* INTCON is saved with interrupts enabled. */
\r
431 *pxTopOfStack = ( portSTACK_TYPE ) portINITAL_INTERRUPT_STATE; /* INTCON */
\r
434 *pxTopOfStack = ( portSTACK_TYPE ) 0x11; /* BSR. */
\r
437 *pxTopOfStack = ( portSTACK_TYPE ) 0x22; /* FSR2L. */
\r
440 *pxTopOfStack = ( portSTACK_TYPE ) 0x33; /* FSR2H. */
\r
443 *pxTopOfStack = ( portSTACK_TYPE ) 0x44; /* FSR0L. */
\r
446 *pxTopOfStack = ( portSTACK_TYPE ) 0x55; /* FSR0H. */
\r
449 *pxTopOfStack = ( portSTACK_TYPE ) 0x66; /* TABLAT. */
\r
452 *pxTopOfStack = ( portSTACK_TYPE ) 0x00; /* TBLPTRU. */
\r
455 *pxTopOfStack = ( portSTACK_TYPE ) 0x88; /* TBLPTRUH. */
\r
458 *pxTopOfStack = ( portSTACK_TYPE ) 0x99; /* TBLPTRUL. */
\r
461 *pxTopOfStack = ( portSTACK_TYPE ) 0xaa; /* PRODH. */
\r
464 *pxTopOfStack = ( portSTACK_TYPE ) 0xbb; /* PRODL. */
\r
467 *pxTopOfStack = ( portSTACK_TYPE ) 0x00; /* PCLATU. */
\r
470 *pxTopOfStack = ( portSTACK_TYPE ) 0x00; /* PCLATH. */
\r
473 /* Next the .tmpdata and MATH_DATA sections. */
\r
474 for( ucBlock = 0; ucBlock <= portCOMPILER_MANAGED_MEMORY_SIZE; ucBlock++ )
\r
476 *pxTopOfStack = ( portSTACK_TYPE ) ucBlock;
\r
480 /* Store the top of the global data section. */
\r
481 *pxTopOfStack = ( portSTACK_TYPE ) portCOMPILER_MANAGED_MEMORY_SIZE; /* Low. */
\r
484 *pxTopOfStack = ( portSTACK_TYPE ) 0x00; /* High. */
\r
487 /* The only function return address so far is the address of the
\r
489 ulAddress = ( unsigned long ) pxCode;
\r
492 *pxTopOfStack = ( portSTACK_TYPE ) ( ulAddress & ( unsigned long ) 0x00ff );
\r
497 *pxTopOfStack = ( portSTACK_TYPE ) ( ulAddress & ( unsigned long ) 0x00ff );
\r
501 /* TOS even higher. */
\r
502 *pxTopOfStack = ( portSTACK_TYPE ) ( ulAddress & ( unsigned long ) 0x00ff );
\r
505 /* Store the number of return addresses on the hardware stack - so far only
\r
506 the address of the task entry point. */
\r
507 *pxTopOfStack = ( portSTACK_TYPE ) 1;
\r
510 return pxTopOfStack;
\r
512 /*-----------------------------------------------------------*/
\r
514 portBASE_TYPE xPortStartScheduler( void )
\r
516 /* Setup a timer for the tick ISR is using the preemptive scheduler. */
\r
517 prvSetupTimerInterrupt();
\r
519 /* Restore the context of the first task to run. */
\r
520 portRESTORE_CONTEXT();
\r
522 /* Should not get here. Use the function name to stop compiler warnings. */
\r
523 ( void ) prvLowInterrupt;
\r
524 ( void ) prvTickISR;
\r
528 /*-----------------------------------------------------------*/
\r
530 void vPortEndScheduler( void )
\r
532 /* It is unlikely that the scheduler for the PIC port will get stopped
\r
533 once running. If required disable the tick interrupt here, then return
\r
534 to xPortStartScheduler(). */
\r
536 /*-----------------------------------------------------------*/
\r
539 * Manual context switch. This is similar to the tick context switch,
\r
540 * but does not increment the tick count. It must be identical to the
\r
541 * tick context switch in how it stores the stack of a task.
\r
543 void vPortYield( void )
\r
545 /* This can get called with interrupts either enabled or disabled. We
\r
546 will save the INTCON register with the interrupt enable bits unmodified. */
\r
547 portSAVE_CONTEXT( portINTERRUPTS_UNCHANGED );
\r
549 /* Switch to the highest priority task that is ready to run. */
\r
550 vTaskSwitchContext();
\r
552 /* Start executing the task we have just switched to. */
\r
553 portRESTORE_CONTEXT();
\r
555 /*-----------------------------------------------------------*/
\r
558 * Vector for ISR. Nothing here must alter any registers!
\r
560 #pragma code high_vector=0x08
\r
561 static void prvLowInterrupt( void )
\r
563 /* Was the interrupt the tick? */
\r
564 if( PIR1bits.CCP1IF )
\r
571 /* Was the interrupt a byte being received? */
\r
572 if( PIR1bits.RCIF )
\r
579 /* Was the interrupt the Tx register becoming empty? */
\r
580 if( PIR1bits.TXIF )
\r
582 if( PIE1bits.TXIE )
\r
592 /*-----------------------------------------------------------*/
\r
595 * ISR for the tick.
\r
596 * This increments the tick count and, if using the preemptive scheduler,
\r
597 * performs a context switch. This must be identical to the manual
\r
598 * context switch in how it stores the context of a task.
\r
600 static void prvTickISR( void )
\r
602 /* Interrupts must have been enabled for the ISR to fire, so we have to
\r
603 save the context with interrupts enabled. */
\r
604 portSAVE_CONTEXT( portGLOBAL_INTERRUPT_FLAG );
\r
605 PIR1bits.CCP1IF = 0;
\r
607 /* Maintain the tick count. */
\r
608 vTaskIncrementTick();
\r
610 #if configUSE_PREEMPTION == 1
\r
612 /* Switch to the highest priority task that is ready to run. */
\r
613 vTaskSwitchContext();
\r
617 portRESTORE_CONTEXT();
\r
619 /*-----------------------------------------------------------*/
\r
622 * Setup a timer for a regular tick.
\r
624 static void prvSetupTimerInterrupt( void )
\r
626 const unsigned long ulConstCompareValue = ( ( configCPU_CLOCK_HZ / portTIMER_FOSC_SCALE ) / configTICK_RATE_HZ );
\r
627 unsigned long ulCompareValue;
\r
628 unsigned char ucByte;
\r
630 /* Interrupts are disabled when this function is called.
\r
632 Setup CCP1 to provide the tick interrupt using a compare match on timer
\r
635 Clear the time count then setup timer. */
\r
636 TMR1H = ( unsigned char ) 0x00;
\r
637 TMR1L = ( unsigned char ) 0x00;
\r
639 /* Set the compare match value. */
\r
640 ulCompareValue = ulConstCompareValue;
\r
641 CCPR1L = ( unsigned char ) ( ulCompareValue & ( unsigned long ) 0xff );
\r
642 ulCompareValue >>= ( unsigned long ) 8;
\r
643 CCPR1H = ( unsigned char ) ( ulCompareValue & ( unsigned long ) 0xff );
\r
645 CCP1CONbits.CCP1M0 = portBIT_SET; /*< Compare match mode. */
\r
646 CCP1CONbits.CCP1M1 = portBIT_SET; /*< Compare match mode. */
\r
647 CCP1CONbits.CCP1M2 = portBIT_CLEAR; /*< Compare match mode. */
\r
648 CCP1CONbits.CCP1M3 = portBIT_SET; /*< Compare match mode. */
\r
649 PIE1bits.CCP1IE = portBIT_SET; /*< Interrupt enable. */
\r
651 /* We are only going to use the global interrupt bit, so set the peripheral
\r
653 INTCONbits.GIEL = portBIT_SET;
\r
655 /* Provided library function for setting up the timer that will produce the
\r
657 OpenTimer1( T1_16BIT_RW & T1_SOURCE_INT & T1_PS_1_1 & T1_CCP1_T3_CCP2 );
\r