2 FreeRTOS V7.4.0 - Copyright (C) 2013 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
33 >>>>>>NOTE<<<<<< The modification to the GPL is included to allow you to
\r
34 distribute a combined work that includes FreeRTOS without being obliged to
\r
35 provide the source code for proprietary components outside of the FreeRTOS
\r
38 FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
\r
39 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
\r
40 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
\r
41 details. You should have received a copy of the GNU General Public License
\r
42 and the FreeRTOS license exception along with FreeRTOS; if not itcan be
\r
43 viewed here: http://www.freertos.org/a00114.html and also obtained by
\r
44 writing to Real Time Engineers Ltd., contact details for whom are available
\r
45 on the FreeRTOS WEB site.
\r
49 ***************************************************************************
\r
51 * Having a problem? Start by reading the FAQ "My application does *
\r
52 * not run, what could be wrong?" *
\r
54 * http://www.FreeRTOS.org/FAQHelp.html *
\r
56 ***************************************************************************
\r
59 http://www.FreeRTOS.org - Documentation, books, training, latest versions,
\r
60 license and Real Time Engineers Ltd. contact details.
\r
62 http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
\r
63 including FreeRTOS+Trace - an indispensable productivity tool, and our new
\r
64 fully thread aware and reentrant UDP/IP stack.
\r
66 http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High
\r
67 Integrity Systems, who sell the code with commercial support,
\r
68 indemnification and middleware, under the OpenRTOS brand.
\r
70 http://www.SafeRTOS.com - High Integrity Systems also provide a safety
\r
71 engineered and independently SIL3 certified version for use in safety and
\r
72 mission critical applications that require provable dependability.
\r
76 Changes between V1.2.4 and V1.2.5
\r
78 + Introduced portGLOBAL_INTERRUPT_FLAG definition to test the global
\r
79 interrupt flag setting. Using the two bits defined within
\r
80 portINITAL_INTERRUPT_STATE was causing the w register to get clobbered
\r
81 before the test was performed.
\r
85 + Set the interrupt vector address to 0x08. Previously it was at the
\r
86 incorrect address for compatibility mode of 0x18.
\r
90 + PCLATU and PCLATH are now saved as part of the context. This allows
\r
91 function pointers to be used within tasks. Thanks to Javier Espeche
\r
92 for the enhancement.
\r
96 + TABLAT is now saved as part of the task context.
\r
100 + TBLPTRU is now initialised to zero as the MPLAB compiler expects this
\r
101 value and does not write to the register.
\r
104 /* Scheduler include files. */
\r
105 #include "FreeRTOS.h"
\r
108 /* MPLAB library include file. */
\r
109 #include "timers.h"
\r
111 /*-----------------------------------------------------------
\r
112 * Implementation of functions defined in portable.h for the PIC port.
\r
113 *----------------------------------------------------------*/
\r
115 /* Hardware setup for tick. */
\r
116 #define portTIMER_FOSC_SCALE ( ( unsigned long ) 4 )
\r
118 /* Initial interrupt enable state for newly created tasks. This value is
\r
119 copied into INTCON when a task switches in for the first time. */
\r
120 #define portINITAL_INTERRUPT_STATE 0xc0
\r
122 /* Just the bit within INTCON for the global interrupt flag. */
\r
123 #define portGLOBAL_INTERRUPT_FLAG 0x80
\r
125 /* Constant used for context switch macro when we require the interrupt
\r
126 enable state to be unchanged when the interrupted task is switched back in. */
\r
127 #define portINTERRUPTS_UNCHANGED 0x00
\r
129 /* Some memory areas get saved as part of the task context. These memory
\r
130 area's get used by the compiler for temporary storage, especially when
\r
131 performing mathematical operations, or when using 32bit data types. This
\r
132 constant defines the size of memory area which must be saved. */
\r
133 #define portCOMPILER_MANAGED_MEMORY_SIZE ( ( unsigned char ) 0x13 )
\r
135 /* We require the address of the pxCurrentTCB variable, but don't want to know
\r
136 any details of its type. */
\r
137 typedef void tskTCB;
\r
138 extern volatile tskTCB * volatile pxCurrentTCB;
\r
140 /* IO port constants. */
\r
141 #define portBIT_SET ( ( unsigned char ) 1 )
\r
142 #define portBIT_CLEAR ( ( unsigned char ) 0 )
\r
145 * The serial port ISR's are defined in serial.c, but are called from portable
\r
146 * as they use the same vector as the tick ISR.
\r
148 void vSerialTxISR( void );
\r
149 void vSerialRxISR( void );
\r
152 * Perform hardware setup to enable ticks.
\r
154 static void prvSetupTimerInterrupt( void );
\r
157 * ISR to maintain the tick, and perform tick context switches if the
\r
158 * preemptive scheduler is being used.
\r
160 static void prvTickISR( void );
\r
163 * ISR placed on the low priority vector. This calls the appropriate ISR for
\r
164 * the actual interrupt.
\r
166 static void prvLowInterrupt( void );
\r
169 * Macro that pushes all the registers that make up the context of a task onto
\r
170 * the stack, then saves the new top of stack into the TCB.
\r
172 * If this is called from an ISR then the interrupt enable bits must have been
\r
173 * set for the ISR to ever get called. Therefore we want to save the INTCON
\r
174 * register with the enable bits forced to be set - and ucForcedInterruptFlags
\r
175 * must contain these bit settings. This means the interrupts will again be
\r
176 * enabled when the interrupted task is switched back in.
\r
178 * If this is called from a manual context switch (i.e. from a call to yield),
\r
179 * then we want to save the INTCON so it is restored with its current state,
\r
180 * and ucForcedInterruptFlags must be 0. This allows a yield from within
\r
181 * a critical section.
\r
183 * The compiler uses some locations at the bottom of the memory for temporary
\r
184 * storage during math and other computations. This is especially true if
\r
185 * 32bit data types are utilised (as they are by the scheduler). The .tmpdata
\r
186 * and MATH_DATA sections have to be stored in there entirety as part of a task
\r
187 * context. This macro stores from data address 0x00 to
\r
188 * portCOMPILER_MANAGED_MEMORY_SIZE. This is sufficient for the demo
\r
189 * applications but you should check the map file for your project to ensure
\r
190 * this is sufficient for your needs. It is not clear whether this size is
\r
191 * fixed for all compilations or has the potential to be program specific.
\r
193 #define portSAVE_CONTEXT( ucForcedInterruptFlags ) \
\r
196 /* Save the status and WREG registers first, as these will get modified \
\r
197 by the operations below. */ \
\r
198 MOVFF WREG, PREINC1 \
\r
199 MOVFF STATUS, PREINC1 \
\r
200 /* Save the INTCON register with the appropriate bits forced if \
\r
201 necessary - as described above. */ \
\r
202 MOVFF INTCON, WREG \
\r
203 IORLW ucForcedInterruptFlags \
\r
204 MOVFF WREG, PREINC1 \
\r
207 portDISABLE_INTERRUPTS(); \
\r
210 /* Store the necessary registers to the stack. */ \
\r
211 MOVFF BSR, PREINC1 \
\r
212 MOVFF FSR2L, PREINC1 \
\r
213 MOVFF FSR2H, PREINC1 \
\r
214 MOVFF FSR0L, PREINC1 \
\r
215 MOVFF FSR0H, PREINC1 \
\r
216 MOVFF TABLAT, PREINC1 \
\r
217 MOVFF TBLPTRU, PREINC1 \
\r
218 MOVFF TBLPTRH, PREINC1 \
\r
219 MOVFF TBLPTRL, PREINC1 \
\r
220 MOVFF PRODH, PREINC1 \
\r
221 MOVFF PRODL, PREINC1 \
\r
222 MOVFF PCLATU, PREINC1 \
\r
223 MOVFF PCLATH, PREINC1 \
\r
224 /* Store the .tempdata and MATH_DATA areas as described above. */ \
\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 POSTINC0, PREINC1 \
\r
241 MOVFF POSTINC0, PREINC1 \
\r
242 MOVFF POSTINC0, PREINC1 \
\r
243 MOVFF POSTINC0, PREINC1 \
\r
244 MOVFF POSTINC0, PREINC1 \
\r
245 MOVFF POSTINC0, PREINC1 \
\r
246 MOVFF INDF0, PREINC1 \
\r
247 MOVFF FSR0L, PREINC1 \
\r
248 MOVFF FSR0H, PREINC1 \
\r
249 /* Store the hardware stack pointer in a temp register before we \
\r
251 MOVFF STKPTR, FSR0L \
\r
254 /* Store each address from the hardware stack. */ \
\r
255 while( STKPTR > ( unsigned char ) 0 ) \
\r
258 MOVFF TOSL, PREINC1 \
\r
259 MOVFF TOSH, PREINC1 \
\r
260 MOVFF TOSU, PREINC1 \
\r
266 /* Store the number of addresses on the hardware stack (from the \
\r
267 temporary register). */ \
\r
268 MOVFF FSR0L, PREINC1 \
\r
269 MOVF PREINC1, 1, 0 \
\r
272 /* Save the new top of the software stack in the TCB. */ \
\r
274 MOVFF pxCurrentTCB, FSR0L \
\r
275 MOVFF pxCurrentTCB + 1, FSR0H \
\r
276 MOVFF FSR1L, POSTINC0 \
\r
277 MOVFF FSR1H, POSTINC0 \
\r
280 /*-----------------------------------------------------------*/
\r
283 * This is the reverse of portSAVE_CONTEXT. See portSAVE_CONTEXT for more
\r
286 #define portRESTORE_CONTEXT() \
\r
289 /* Set FSR0 to point to pxCurrentTCB->pxTopOfStack. */ \
\r
290 MOVFF pxCurrentTCB, FSR0L \
\r
291 MOVFF pxCurrentTCB + 1, FSR0H \
\r
293 /* De-reference FSR0 to set the address it holds into FSR1. \
\r
294 (i.e. *( pxCurrentTCB->pxTopOfStack ) ). */ \
\r
295 MOVFF POSTINC0, FSR1L \
\r
296 MOVFF POSTINC0, FSR1H \
\r
298 /* How many return addresses are there on the hardware stack? Discard \
\r
299 the first byte as we are pointing to the next free space. */ \
\r
300 MOVFF POSTDEC1, FSR0L \
\r
301 MOVFF POSTDEC1, FSR0L \
\r
304 /* Fill the hardware stack from our software stack. */ \
\r
307 while( STKPTR < FSR0L ) \
\r
311 MOVF POSTDEC1, 0, 0 \
\r
313 MOVF POSTDEC1, 0, 0 \
\r
315 MOVF POSTDEC1, 0, 0 \
\r
321 /* Restore the .tmpdata and MATH_DATA memory. */ \
\r
322 MOVFF POSTDEC1, FSR0H \
\r
323 MOVFF POSTDEC1, FSR0L \
\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, POSTDEC0 \
\r
338 MOVFF POSTDEC1, POSTDEC0 \
\r
339 MOVFF POSTDEC1, POSTDEC0 \
\r
340 MOVFF POSTDEC1, POSTDEC0 \
\r
341 MOVFF POSTDEC1, POSTDEC0 \
\r
342 MOVFF POSTDEC1, POSTDEC0 \
\r
343 MOVFF POSTDEC1, INDF0 \
\r
344 /* Restore the other registers forming the tasks context. */ \
\r
345 MOVFF POSTDEC1, PCLATH \
\r
346 MOVFF POSTDEC1, PCLATU \
\r
347 MOVFF POSTDEC1, PRODL \
\r
348 MOVFF POSTDEC1, PRODH \
\r
349 MOVFF POSTDEC1, TBLPTRL \
\r
350 MOVFF POSTDEC1, TBLPTRH \
\r
351 MOVFF POSTDEC1, TBLPTRU \
\r
352 MOVFF POSTDEC1, TABLAT \
\r
353 MOVFF POSTDEC1, FSR0H \
\r
354 MOVFF POSTDEC1, FSR0L \
\r
355 MOVFF POSTDEC1, FSR2H \
\r
356 MOVFF POSTDEC1, FSR2L \
\r
357 MOVFF POSTDEC1, BSR \
\r
358 /* The next byte is the INTCON register. Read this into WREG as some \
\r
359 manipulation is required. */ \
\r
360 MOVFF POSTDEC1, WREG \
\r
363 /* From the INTCON register, only the interrupt enable bits form part \
\r
364 of the tasks context. It is perfectly legitimate for another task to \
\r
365 have modified any other bits. We therefore only restore the top two bits. \
\r
367 if( WREG & portGLOBAL_INTERRUPT_FLAG ) \
\r
370 MOVFF POSTDEC1, STATUS \
\r
371 MOVFF POSTDEC1, WREG \
\r
372 /* Return enabling interrupts. */ \
\r
379 MOVFF POSTDEC1, STATUS \
\r
380 MOVFF POSTDEC1, WREG \
\r
381 /* Return without effecting interrupts. The context may have \
\r
382 been saved from a critical region. */ \
\r
387 /*-----------------------------------------------------------*/
\r
390 * See header file for description.
\r
392 portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE pxCode, void *pvParameters )
\r
394 unsigned long ulAddress;
\r
395 unsigned char ucBlock;
\r
397 /* Place a few bytes of known values on the bottom of the stack.
\r
398 This is just useful for debugging. */
\r
400 *pxTopOfStack = 0x11;
\r
402 *pxTopOfStack = 0x22;
\r
404 *pxTopOfStack = 0x33;
\r
408 /* Simulate how the stack would look after a call to vPortYield() generated
\r
411 First store the function parameters. This is where the task will expect to
\r
412 find them when it starts running. */
\r
413 ulAddress = ( unsigned long ) pvParameters;
\r
414 *pxTopOfStack = ( portSTACK_TYPE ) ( ulAddress & ( unsigned long ) 0x00ff );
\r
418 *pxTopOfStack = ( portSTACK_TYPE ) ( ulAddress & ( unsigned long ) 0x00ff );
\r
421 /* Next we just leave a space. When a context is saved the stack pointer
\r
422 is incremented before it is used so as not to corrupt whatever the stack
\r
423 pointer is actually pointing to. This is especially necessary during
\r
424 function epilogue code generated by the compiler. */
\r
425 *pxTopOfStack = 0x44;
\r
428 /* Next are all the registers that form part of the task context. */
\r
430 *pxTopOfStack = ( portSTACK_TYPE ) 0x66; /* WREG. */
\r
433 *pxTopOfStack = ( portSTACK_TYPE ) 0xcc; /* Status. */
\r
436 /* INTCON is saved with interrupts enabled. */
\r
437 *pxTopOfStack = ( portSTACK_TYPE ) portINITAL_INTERRUPT_STATE; /* INTCON */
\r
440 *pxTopOfStack = ( portSTACK_TYPE ) 0x11; /* BSR. */
\r
443 *pxTopOfStack = ( portSTACK_TYPE ) 0x22; /* FSR2L. */
\r
446 *pxTopOfStack = ( portSTACK_TYPE ) 0x33; /* FSR2H. */
\r
449 *pxTopOfStack = ( portSTACK_TYPE ) 0x44; /* FSR0L. */
\r
452 *pxTopOfStack = ( portSTACK_TYPE ) 0x55; /* FSR0H. */
\r
455 *pxTopOfStack = ( portSTACK_TYPE ) 0x66; /* TABLAT. */
\r
458 *pxTopOfStack = ( portSTACK_TYPE ) 0x00; /* TBLPTRU. */
\r
461 *pxTopOfStack = ( portSTACK_TYPE ) 0x88; /* TBLPTRUH. */
\r
464 *pxTopOfStack = ( portSTACK_TYPE ) 0x99; /* TBLPTRUL. */
\r
467 *pxTopOfStack = ( portSTACK_TYPE ) 0xaa; /* PRODH. */
\r
470 *pxTopOfStack = ( portSTACK_TYPE ) 0xbb; /* PRODL. */
\r
473 *pxTopOfStack = ( portSTACK_TYPE ) 0x00; /* PCLATU. */
\r
476 *pxTopOfStack = ( portSTACK_TYPE ) 0x00; /* PCLATH. */
\r
479 /* Next the .tmpdata and MATH_DATA sections. */
\r
480 for( ucBlock = 0; ucBlock <= portCOMPILER_MANAGED_MEMORY_SIZE; ucBlock++ )
\r
482 *pxTopOfStack = ( portSTACK_TYPE ) ucBlock;
\r
486 /* Store the top of the global data section. */
\r
487 *pxTopOfStack = ( portSTACK_TYPE ) portCOMPILER_MANAGED_MEMORY_SIZE; /* Low. */
\r
490 *pxTopOfStack = ( portSTACK_TYPE ) 0x00; /* High. */
\r
493 /* The only function return address so far is the address of the
\r
495 ulAddress = ( unsigned long ) pxCode;
\r
498 *pxTopOfStack = ( portSTACK_TYPE ) ( ulAddress & ( unsigned long ) 0x00ff );
\r
503 *pxTopOfStack = ( portSTACK_TYPE ) ( ulAddress & ( unsigned long ) 0x00ff );
\r
507 /* TOS even higher. */
\r
508 *pxTopOfStack = ( portSTACK_TYPE ) ( ulAddress & ( unsigned long ) 0x00ff );
\r
511 /* Store the number of return addresses on the hardware stack - so far only
\r
512 the address of the task entry point. */
\r
513 *pxTopOfStack = ( portSTACK_TYPE ) 1;
\r
516 return pxTopOfStack;
\r
518 /*-----------------------------------------------------------*/
\r
520 portBASE_TYPE xPortStartScheduler( void )
\r
522 /* Setup a timer for the tick ISR is using the preemptive scheduler. */
\r
523 prvSetupTimerInterrupt();
\r
525 /* Restore the context of the first task to run. */
\r
526 portRESTORE_CONTEXT();
\r
528 /* Should not get here. Use the function name to stop compiler warnings. */
\r
529 ( void ) prvLowInterrupt;
\r
530 ( void ) prvTickISR;
\r
534 /*-----------------------------------------------------------*/
\r
536 void vPortEndScheduler( void )
\r
538 /* It is unlikely that the scheduler for the PIC port will get stopped
\r
539 once running. If required disable the tick interrupt here, then return
\r
540 to xPortStartScheduler(). */
\r
542 /*-----------------------------------------------------------*/
\r
545 * Manual context switch. This is similar to the tick context switch,
\r
546 * but does not increment the tick count. It must be identical to the
\r
547 * tick context switch in how it stores the stack of a task.
\r
549 void vPortYield( void )
\r
551 /* This can get called with interrupts either enabled or disabled. We
\r
552 will save the INTCON register with the interrupt enable bits unmodified. */
\r
553 portSAVE_CONTEXT( portINTERRUPTS_UNCHANGED );
\r
555 /* Switch to the highest priority task that is ready to run. */
\r
556 vTaskSwitchContext();
\r
558 /* Start executing the task we have just switched to. */
\r
559 portRESTORE_CONTEXT();
\r
561 /*-----------------------------------------------------------*/
\r
564 * Vector for ISR. Nothing here must alter any registers!
\r
566 #pragma code high_vector=0x08
\r
567 static void prvLowInterrupt( void )
\r
569 /* Was the interrupt the tick? */
\r
570 if( PIR1bits.CCP1IF )
\r
577 /* Was the interrupt a byte being received? */
\r
578 if( PIR1bits.RCIF )
\r
585 /* Was the interrupt the Tx register becoming empty? */
\r
586 if( PIR1bits.TXIF )
\r
588 if( PIE1bits.TXIE )
\r
598 /*-----------------------------------------------------------*/
\r
601 * ISR for the tick.
\r
602 * This increments the tick count and, if using the preemptive scheduler,
\r
603 * performs a context switch. This must be identical to the manual
\r
604 * context switch in how it stores the context of a task.
\r
606 static void prvTickISR( void )
\r
608 /* Interrupts must have been enabled for the ISR to fire, so we have to
\r
609 save the context with interrupts enabled. */
\r
610 portSAVE_CONTEXT( portGLOBAL_INTERRUPT_FLAG );
\r
611 PIR1bits.CCP1IF = 0;
\r
613 /* Maintain the tick count. */
\r
614 vTaskIncrementTick();
\r
616 #if configUSE_PREEMPTION == 1
\r
618 /* Switch to the highest priority task that is ready to run. */
\r
619 vTaskSwitchContext();
\r
623 portRESTORE_CONTEXT();
\r
625 /*-----------------------------------------------------------*/
\r
628 * Setup a timer for a regular tick.
\r
630 static void prvSetupTimerInterrupt( void )
\r
632 const unsigned long ulConstCompareValue = ( ( configCPU_CLOCK_HZ / portTIMER_FOSC_SCALE ) / configTICK_RATE_HZ );
\r
633 unsigned long ulCompareValue;
\r
634 unsigned char ucByte;
\r
636 /* Interrupts are disabled when this function is called.
\r
638 Setup CCP1 to provide the tick interrupt using a compare match on timer
\r
641 Clear the time count then setup timer. */
\r
642 TMR1H = ( unsigned char ) 0x00;
\r
643 TMR1L = ( unsigned char ) 0x00;
\r
645 /* Set the compare match value. */
\r
646 ulCompareValue = ulConstCompareValue;
\r
647 CCPR1L = ( unsigned char ) ( ulCompareValue & ( unsigned long ) 0xff );
\r
648 ulCompareValue >>= ( unsigned long ) 8;
\r
649 CCPR1H = ( unsigned char ) ( ulCompareValue & ( unsigned long ) 0xff );
\r
651 CCP1CONbits.CCP1M0 = portBIT_SET; /*< Compare match mode. */
\r
652 CCP1CONbits.CCP1M1 = portBIT_SET; /*< Compare match mode. */
\r
653 CCP1CONbits.CCP1M2 = portBIT_CLEAR; /*< Compare match mode. */
\r
654 CCP1CONbits.CCP1M3 = portBIT_SET; /*< Compare match mode. */
\r
655 PIE1bits.CCP1IE = portBIT_SET; /*< Interrupt enable. */
\r
657 /* We are only going to use the global interrupt bit, so set the peripheral
\r
659 INTCONbits.GIEL = portBIT_SET;
\r
661 /* Provided library function for setting up the timer that will produce the
\r
663 OpenTimer1( T1_16BIT_RW & T1_SOURCE_INT & T1_PS_1_1 & T1_CCP1_T3_CCP2 );
\r