-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtimers.h
1183 lines (901 loc) · 52.1 KB
/
timers.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#ifndef __TIMERS_H
#define __TIMERS_H
/******************************************************************************
// * TIMERS PERIPHERAL LIBRARY HEADER FILE
******************************************************************************
* FileName: timers.h
* Dependencies: See include below
* Processor: PIC18
* Compiler: MCC18
* Company: Microchip Technology, Inc.
*
* Software License Agreement
* The software supplied herewith by Microchip Technology Incorporated
* (the “Company”) for its PICmicro® Microcontroller is intended and
* supplied to you, the Company’s customer, for use solely and
* exclusively on Microchip PICmicro Microcontroller products. The
* software is owned by the Company and/or its supplier, and is
* protected under applicable copyright laws. All rights are reserved.
* Any use in violation of the foregoing restrictions may subject the
* user to criminal sanctions under applicable laws, as well as to
* civil liability for the breach of the terms and conditions of this
* license.
*
* THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES,
* WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
* TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
* IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
* CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
*****************************************************************************/
#include <pconfig.h>
/* PIC18 timers peripheral library. */
/* used to hold 16-bit timer value */
union Timers
{
unsigned int lt;
char bt[2];
};
/* Interrupt bit mask to be 'anded' with the other configuration masks and
* passed as the 'config' parameter to the 'open' routines. */
#ifndef USE_OR_MASKS
#define TIMER_INT_OFF 0b01111111 //Disable TIMER Interrupt
#define TIMER_INT_ON 0b11111111 //Enable TIMER Interrupt
/* ***** TIMER0 ***** */
/* TIMER0 configuration masks -- to be 'anded' together and passed to the
* 'open' routine. */
#define T0_16BIT 0b10111111 //Timer0 is configured as an 16-bit timer/counter
#define T0_8BIT 0b11111111 //Timer0 is configured as an 8-bit timer/counter
#define T0_SOURCE_INT 0b11011111 //Internal instruction cycle clock (CLKO) acts as source of clock
#if defined (TMR_V7_4)
#define T0_SOURCE_INTOSC 0b11001111 //INTOSC
#else
#define T0_SOURCE_EXT 0b11111111 //Transition on TxCKI pin acts as source of clock
#endif
#define T0_EDGE_RISE 0b11101111 //Increment on low-to-high transition on TxCKI pin
#define T0_EDGE_FALL 0b11111111 //Increment on high-to-low transition on TxCKI pin
#define T0_PS_1_1 0b11111111 //1:1 Prescale value (NO Prescaler)
#define T0_PS_1_2 0b11110000 //1:2 Prescale value
#define T0_PS_1_4 0b11110001 //1:4 Prescale value
#define T0_PS_1_8 0b11110010 //1:8 Prescale value
#define T0_PS_1_16 0b11110011 //1:16 Prescale value
#define T0_PS_1_32 0b11110100 //1:32 Prescale value
#define T0_PS_1_64 0b11110101 //1:64 Prescale value
#define T0_PS_1_128 0b11110110 //1:128 Prescale value
#define T0_PS_1_256 0b11110111 //1:256 Prescale value
#else //!USE_OR_MASKS
#define TIMER_INT_OFF 0b00000000 //Disable TIMER Interrupt
#define TIMER_INT_ON 0b10000000 //Enable TIMER Interrupt
#define TIMER_INT_MASK (~TIMER_INT_ON) //Mask Enable/Disable Timer Interrupt selection bit
/* ***** TIMER0 ***** */
/* TIMER0 configuration masks -- to be 'anded' together and passed to the
* 'open' routine. */
#define T0_16BIT 0b00000000 //Timer0 is configured as an 16-bit timer/counter
#define T0_8BIT 0b01000000 //Timer0 is configured as an 8-bit timer/counter
#define T0_BIT_MASK (~T0_8BIT) //Mask Timer0 8-Bit/16-Bit Control bit
#define T0_SOURCE_INT 0b00000000 //Internal instruction cycle clock (CLKO) acts as source of clock
#if defined (TMR_V7_4)
#define T0_SOURCE_INTOSC 0b00000000 //INTOSC
#else
#define T0_SOURCE_EXT 0b00100000 //Transition on TxCKI pin acts as source of clock
#endif
#define T0_SOURCE_MASK (~T0_SOURCE_EXT) //Mask Timer0 Clock Source Select bit
#define T0_EDGE_RISE 0b00000000 //Increment on low-to-high transition on TxCKI pin
#define T0_EDGE_FALL 0b00010000 //Increment on high-to-low transition on TxCKI pin
#define T0_EDGE_MASK (~T0_EDGE_FALL) //Mask Timer0 Source Edge Select bit
#define T0_PS_1_1 0b00001000 //1:1 Prescale value (NO Prescaler)
#define NO_T0_PS_MASK (~T0_PS_1_1) //Mask Timer0 Prescaler Assignment bit
#define T0_PS_1_2 0b00000000 //1:2 Prescale value
#define T0_PS_1_4 0b00000001 //1:4 Prescale value
#define T0_PS_1_8 0b00000010 //1:8 Prescale value
#define T0_PS_1_16 0b00000011 //1:16 Prescale value
#define T0_PS_1_32 0b00000100 //1:32 Prescale value
#define T0_PS_1_64 0b00000101 //1:64 Prescale value
#define T0_PS_1_128 0b00000110 //1:128 Prescale value
#define T0_PS_1_256 0b00000111 //1:256 Prescale value
#define T0_PS_MASK (~T0_PS_1_256) //Mask Timer0 Prescaler Select bits
#endif//USE_OR_MASKS
void OpenTimer0 ( unsigned char config);
void CloseTimer0 (void);
unsigned int ReadTimer0 (void);
void WriteTimer0 ( unsigned int timer0);
/* ***** TIMER1 ***** */
/* TIMER1 configuration masks -- to be 'anded' together and passed to the
* 'open' routine. */
#if defined (TMR_V6) || defined (TMR_V7) || defined (TMR_V7_1) || defined (TMR_V7_2)\
|| defined (TMR_V7_3) || defined (TMR_V7_4) || defined (TMR_V7_5)
#ifndef USE_OR_MASKS
#if defined (TMR_V7_4)
#define T1_SOURCE_INTOSC 0b11111111 // Clock source is INTOSC
#endif
#define T1_SOURCE_PINOSC 0b11011111 // Clock source T1OSCEN = 0 Ext clock, T1OSCEN=1 Crystal osc
#define T1_SOURCE_FOSC_4 0b10011111 //Clock source is instruction clock (FOSC/4)
#define T1_SOURCE_FOSC 0b10111111 //Closck source is system clock (FOSC)
#define T1_PS_1_1 0b11100111 // 1:1 prescale value
#define T1_PS_1_2 0b11101111 // 1:2 prescale value
#define T1_PS_1_4 0b11110111 // 1:4 prescale value
#define T1_PS_1_8 0b11111111 // 1:8 prescale value
#define T1_OSC1EN_OFF 0b11111011 // Timer 1 oscilator enable off
#define T1_OSC1EN_ON 0b11111111 // Timer 1 oscilator enable on
#define T1_SYNC_EXT_ON 0b11111101 // Synchronize external clock input
#define T1_SYNC_EXT_OFF 0b11111111 // Do not synchronize external clock input
#define T1_8BIT_RW 0b11111110 //Enables register read/write of Timer1 in two 8-bit operations
#define T1_16BIT_RW 0b11111111 //Enables register read/write of Timer1 in one 16-bit operation
#else
#if defined (TMR_V7_4)
#define T1_SOURCE_INTOSC 0b00000000 // Clock source is INTOSC
#endif
#define T1_SOURCE_PINOSC 0b01000000 // Clock source T1OSCEN = 0 Ext clock, T1OSCEN=1 Crystal osc
#define T1_SOURCE_FOSC_4 0b00000000 //Clock source is instruction clock (FOSC/4)
#define T1_SOURCE_FOSC 0b00100000 //Clock source is system clock (FOSC)
#define T1_SOURCE_MASK (~T1_SOURCE_FOSC) //Mask Timer1 Clock Source Select bits
#define T1_PS_1_1 0b00000000 // 1:1 prescale value
#define T1_PS_1_2 0b00001000 // 1:2 prescale value
#define T1_PS_1_4 0b00010000 // 1:4 prescale value
#define T1_PS_1_8 0b00011000 // 1:8 prescale value
#define T1_PS_MASK (~T1_PS_1_8) //Mask Timer1 Input Clock Prescale Select bits
#define T1_OSC1EN_OFF 0b00000000 // Timer 1 oscilator enable off
#define T1_OSC1EN_ON 0b00000100 // Timer 1 oscilator enable on
#define T1_OSC_MASK (~T1_OSC1EN_ON) //Mask Timer1 Oscillator Enable bit
#define T1_SYNC_EXT_ON 0b00000000 // Synchronize external clock input
#define T1_SYNC_EXT_OFF 0b00000010 // Do not synchronize external clock input
#define T1_SYNC_MASK (~T1_SYNC_EXT_OFF) // Mask Timer1 External Clock Input Synchronization Select bit
#define T1_8BIT_RW 0b00000000 //Enables register read/write of Timer1 in two 8-bit operations
#define T1_16BIT_RW 0b00000001 //Enables register read/write of Timer1 in one 16-bit operation
#define T1_BIT_RW_MASK (~T1_16BIT_RW) // Mask Timer1 16-Bit Read/Write Mode Enable bit
#endif
void OpenTimer1 ( unsigned char config, unsigned char config1);
void CloseTimer1 (void);
unsigned int ReadTimer1 (void);
void WriteTimer1 ( unsigned int timer1);
#else
#ifndef USE_OR_MASKS
#define T1_8BIT_RW 0b10111111 //Enables register read/write of Timer1 in two 8-bit operations
#define T1_16BIT_RW 0b11111111 //Enables register read/write of Timer1 in one 16-bit operation
#define T1_PS_1_1 0b11001111 // 1:1 prescale value
#define T1_PS_1_2 0b11011111 // 1:2 prescale value
#define T1_PS_1_4 0b11101111 // 1:4 prescale value
#define T1_PS_1_8 0b11111111 // 1:8 prescale value
#define T1_OSC1EN_OFF 0b11110111 // Timer 1 oscilator enable off
#define T1_OSC1EN_ON 0b11111111 // Timer 1 oscilator enable on
#define T1_SYNC_EXT_ON 0b11111011 // Synchronize external clock input
#define T1_SYNC_EXT_OFF 0b11111111 // Do not synchronize external clock input
#define T1_SOURCE_INT 0b11111101 //Internal instruction cycle clock (CLKO) acts as source of clock
#define T1_SOURCE_EXT 0b11111111 //Transition on TxCKI pin acts as source of clock
#else //!USE_OR_MASKS
#define T1_8BIT_RW 0b00000000 //Enables register read/write of Timer1 in two 8-bit operations
#define T1_16BIT_RW 0b01000000 //Enables register read/write of Timer1 in one 16-bit operation
#define T1_BIT_RW_MASK (~T1_16BIT_RW) // Mask Timer1 16-Bit Read/Write Mode Enable bit
#define T1_PS_1_1 0b00000000 // 1:1 prescale value
#define T1_PS_1_2 0b00010000 // 1:2 prescale value
#define T1_PS_1_4 0b00100000 // 1:4 prescale value
#define T1_PS_1_8 0b00110000 // 1:8 prescale value
#define T1_PS_MASK (~T1_PS_1_8) //Mask Timer1 Input Clock Prescale Select bits
#define T1_OSC1EN_OFF 0b00000000 // Timer 1 oscilator enable off
#define T1_OSC1EN_ON 0b00001000 // Timer 1 oscilator enable on
#define T1_OSC_MASK (~T1_OSC1EN_ON) //Mask Timer1 Oscillator Enable bit
#define T1_SYNC_EXT_ON 0b00000000 // Synchronize external clock input
#define T1_SYNC_EXT_OFF 0b00000100 // Do not synchronize external clock input
#define T1_SYNC_MASK (~T1_SYNC_EXT_OFF) // Mask Timer1 External Clock Input Synchronization Select bit
#define T1_SOURCE_INT 0b00000000 //Internal instruction cycle clock (CLKO) acts as source of clock
#define T1_SOURCE_EXT 0b00000010 //Transition on TxCKI pin acts as source of clock
#define T1_SOURCE_MASK (~T1_SOURCE_EXT) //Mask Timer1 Clock Source Select bits
#endif //USE_OR_MASKS
void OpenTimer1 ( unsigned char config);
void CloseTimer1 (void);
unsigned int ReadTimer1 (void);
void WriteTimer1 ( unsigned int timer1);
#endif
/* ***** TIMER2 ***** */
#if defined (TMR_V2) || defined (TMR_V3) || defined (TMR_V4) ||\
defined (TMR_V5) || defined (TMR_V6) || defined (TMR_V7) || defined (TMR_V7_1) ||\
defined (TMR_V7_2) || defined (TMR_V7_3) || defined (TMR_V7_4) || defined (TMR_V7_5)
/* TIMER2 configuration masks -- to be 'anded' together and passed to the
* 'open' routine. */
//-----------------AND OR MASK----------------------
#ifndef USE_OR_MASKS
#define T2_POST_1_1 0b10000111 //Timer2 Postscaler 1:1
#define T2_POST_1_2 0b10001111 //Timer2 Postscaler 1:2
#define T2_POST_1_3 0b10010111 //Timer2 Postscaler 1:3
#define T2_POST_1_4 0b10011111 //Timer2 Postscaler 1:4
#define T2_POST_1_5 0b10100111 //Timer2 Postscaler 1:5
#define T2_POST_1_6 0b10101111 //Timer2 Postscaler 1:6
#define T2_POST_1_7 0b10110111 //Timer2 Postscaler 1:7
#define T2_POST_1_8 0b10111111 //Timer2 Postscaler 1:8
#define T2_POST_1_9 0b11000111 //Timer2 Postscaler 1:9
#define T2_POST_1_10 0b11001111 //Timer2 Postscaler 1:10
#define T2_POST_1_11 0b11010111 //Timer2 Postscaler 1:11
#define T2_POST_1_12 0b11011111 //Timer2 Postscaler 1:12
#define T2_POST_1_13 0b11100111 //Timer2 Postscaler 1:13
#define T2_POST_1_14 0b11101111 //Timer2 Postscaler 1:14
#define T2_POST_1_15 0b11110111 //Timer2 Postscaler 1:15
#define T2_POST_1_16 0b11111111 //Timer2 Postscaler 1:16
#define T2_PS_1_1 0b11111100 //Timer2 Prescale 1:1
#define T2_PS_1_4 0b11111101 //Timer2 Prescale 1:4
#define T2_PS_1_16 0b11111110 //Timer2 Prescale 1:16
#else //!USE_OR_MASKS
#define T2_POST_1_1 0b00000000 //Timer2 Postscaler 1:1
#define T2_POST_1_2 0b00001000 //Timer2 Postscaler 1:2
#define T2_POST_1_3 0b00010000 //Timer2 Postscaler 1:3
#define T2_POST_1_4 0b00011000 //Timer2 Postscaler 1:4
#define T2_POST_1_5 0b00100000 //Timer2 Postscaler 1:5
#define T2_POST_1_6 0b00101000 //Timer2 Postscaler 1:6
#define T2_POST_1_7 0b00110000 //Timer2 Postscaler 1:7
#define T2_POST_1_8 0b00111000 //Timer2 Postscaler 1:8
#define T2_POST_1_9 0b01000000 //Timer2 Postscaler 1:9
#define T2_POST_1_10 0b01001000 //Timer2 Postscaler 1:10
#define T2_POST_1_11 0b01010000 //Timer2 Postscaler 1:11
#define T2_POST_1_12 0b01011000 //Timer2 Postscaler 1:12
#define T2_POST_1_13 0b01100000 //Timer2 Postscaler 1:13
#define T2_POST_1_14 0b01101000 //Timer2 Postscaler 1:14
#define T2_POST_1_15 0b01110000 //Timer2 Postscaler 1:15
#define T2_POST_1_16 0b01111000 //Timer2 Postscaler 1:16
#define T2_POST_MASK (~T2_POST_1_16) //Mask Timer2 Postscale Selection bits
#define T2_PS_1_1 0b00000000 //Timer2 Prescale 1:1
#define T2_PS_1_4 0b00000001 //Timer2 Prescale 1:4
#define T2_PS_1_16 0b00000011 //Timer2 Prescale 1:16
#define T2_PS_MASK (~T2_PS_1_16) //Mask Timer2 Input Clock Prescale Select bits
#endif //!USE_OR_MASKS
/***********************************************************************************
Macro : WriteTimer2(timer2)
Include : timers.h
Description : Macro writes the parameter passed to TIMER2 count register TMR2
Arguments : timer2 : value to be written to TIMER2 count register TMR2
Remarks : None
***********************************************************************************/
#define WriteTimer2(timer2) TMR2 = (timer2)
/***********************************************************************************
Macro : ReadTimer2()
Include : timers.h
Description : Macro returns the TMR2 register value of TIMER2
Arguments : None
Returns : TMR2 value
***********************************************************************************/
#define ReadTimer2() TMR2
void OpenTimer2 ( unsigned char config);
void CloseTimer2 (void);
//unsigned char ReadTimer2 (void);
#endif
/* ***** TIMER3 ***** */
#if defined(TMR_V1) || defined(TMR_V2) || defined(TMR_V4)
/* TIMER3 configuration masks -- to be 'anded' together and passed to the
* 'open' routine. */
#ifndef USE_OR_MASKS
#define T3_8BIT_RW 0b11111110 //Enables register read/write of Timer3 in two 8-bit operations
#define T3_16BIT_RW 0b11111111 //Enables register read/write of Timer3 in two 16-bit operations
#define T3_PS_1_1 0b11001111 //Timer3 1:1 prescale value
#define T3_PS_1_2 0b11011111 //Timer3 1:2 prescale value
#define T3_PS_1_4 0b11101111 //Timer3 1:4 prescale value
#define T3_PS_1_8 0b11111111 //Timer3 1:8 prescale value
#define T3_SYNC_EXT_ON 0b11111011 // Synchronize external clock input
#define T3_SYNC_EXT_OFF 0b11111111 // Do not synchronize external clock input
#define T3_SOURCE_INT 0b11111101 //Internal instruction cycle clock (CLKO) acts as source of clock
#define T3_SOURCE_EXT 0b11111111 //Transition on TxCKI pin acts as source of clock
#else //!USE_OR_MASKS
#define T3_8BIT_RW 0b00000000 //Enables register read/write of Timer3 in two 8-bit operations
#define T3_16BIT_RW 0b00000001 //Enables register read/write of Timer3 in two 16-bit operations
#define T3_BIT_MASK (~T3_16BIT_RW) // Mask Timer3 16-Bit Read/Write Mode Enable bit
#define T3_PS_1_1 0b00000000 //Timer3 1:1 prescale value
#define T3_PS_1_2 0b00010000 //Timer3 1:2 prescale value
#define T3_PS_1_4 0b00100000 //Timer3 1:4 prescale value
#define T3_PS_1_8 0b00110000 //Timer3 1:8 prescale value
#define T3_PS_MASK (~T3_PS_1_8) //Mask Timer3 Input Clock Prescale Select bits
#define T3_SYNC_EXT_ON 0b00000000 // Synchronize external clock input
#define T3_SYNC_EXT_OFF 0b00000100 // Do not synchronize external clock input
#define T3_SYNC_MASK (~T3_SYNC_EXT_OFF) // Mask Timer3 External Clock Input Synchronization Select bit
#define T3_SOURCE_INT 0b00000000 //Internal instruction cycle clock (CLKO) acts as source of clock
#define T3_SOURCE_EXT 0b00000010 //Transition on TxCKI pin acts as source of clock
#define T3_SOURCE_MASK (~T3_SOURCE_EXT) //Mask Timer3 Clock Source Select bits
#endif //USE_OR_MASKS
//-----------------------------------------------------------------------------------------------------------
/************************************************************************
Macro : T3_OSC1EN_ON
Overview : sets the T1OSCEN bit in the T1CON
Parameters : None
Remarks : None.
**************************************************************************/
#define T3_OSC1EN_ON() T1CONbits.T1OSCEN=1
/************************************************************************
Macro : T3_OSC1EN_OFF
Overview : Clears the T1OSCEN bit in the T1CON
Parameters : None
Remarks : None.
**************************************************************************/
#define T3_OSC1EN_OFF() T1CONbits.T1OSCEN=0
void OpenTimer3 ( unsigned char config);
void CloseTimer3 (void);
unsigned int ReadTimer3 (void);
void WriteTimer3 ( unsigned int timer3);
#elif defined (TMR_V6) || defined (TMR_V7) || defined (TMR_V7_1) ||\
defined (TMR_V7_2) || defined (TMR_V7_3) || defined (TMR_V7_4) || defined (TMR_V7_5)
#ifndef USE_OR_MASKS
#if defined (TMR_V7_4)
#define T3_SOURCE_INTOSC 0b11111111 // Clock source is INTOSC
#endif
#define T3_SOURCE_PINOSC 0b11011111 // Clock source T1OSCEN = 0 Ext clock, T1OSCEN=1 Crystal osc
#define T3_SOURCE_FOSC_4 0b10011111 //Clock source is instruction clock (FOSC/4)
#define T3_SOURCE_FOSC 0b10111111 //Closck source is system clock (FOSC)
#define T3_PS_1_1 0b11100111 //Timer3 1:1 prescale value
#define T3_PS_1_2 0b11101111 //Timer3 1:2 prescale value
#define T3_PS_1_4 0b11110111 //Timer3 1:4 prescale value
#define T3_PS_1_8 0b11111111 //Timer3 1:8 prescale value
#define T3_OSC1EN_OFF 0b11111011 // Timer1 oscilator disabled which is used by Timer3
#define T3_OSC1EN_ON 0b11111111 // Timer1 oscilator enabled which is used by Timer3
#define T3_SYNC_EXT_ON 0b11111101 // Synchronize external clock input
#define T3_SYNC_EXT_OFF 0b11111111 // Do not synchronize external clock input
#define T3_8BIT_RW 0b11111110 //Enables register read/write of Timer3 in two 8-bit operations
#define T3_16BIT_RW 0b11111111 //Enables register read/write of Timer3 in two 16-bit operations
#else
#if defined (TMR_V7_4)
#define T3_SOURCE_INTOSC 0b00000000 // Clock source is INTOSC
#endif
#define T3_SOURCE_PINOSC 0b01000000 // Clock source T1OSCEN = 0 Ext clock, T1OSCEN=1 Crystal osc
#define T3_SOURCE_FOSC_4 0b00000000 //Clock source is instruction clock (FOSC/4)
#define T3_SOURCE_FOSC 0b00100000 //Closck source is system clock (FOSC)
#define T3_SOURCE_MASK (~T3_SOURCE_FOSC) //Mask Timer3 Clock Source Select bits
#define T3_PS_1_1 0b00000000 //Timer3 1:1 prescale value
#define T3_PS_1_2 0b00001000 //Timer3 1:2 prescale value
#define T3_PS_1_4 0b00010000 //Timer3 1:4 prescale value
#define T3_PS_1_8 0b00011000 //Timer3 1:8 prescale value
#define T3_PS_MASK (~T3_PS_1_8) //Mask Timer3 Input Clock Prescale Select bits
#define T3_OSC1EN_OFF 0b00000000 // Timer1 oscilator disabled which is used by Timer3
#define T3_OSC1EN_ON 0b00000100 // Timer1 oscilator enabled which is used by Timer3
#define T3_OSC_MASK (~T3_OSC1EN_ON) //Mask Timer3 Oscillator Source Select bit
#define T3_SYNC_EXT_ON 0b00000000 // Synchronize external clock input
#define T3_SYNC_EXT_OFF 0b00000010 // Do not synchronize external clock input
#define T3_SYNC_MASK (~T3_SYNC_EXT_OFF) // Mask Timer3 External Clock Input Synchronization Select bit
#define T3_8BIT_RW 0b00000000 //Enables register read/write of Timer3 in two 8-bit operations
#define T3_16BIT_RW 0b00000001 //Enables register read/write of Timer3 in two 16-bit operations
#define T3_BIT_RW_MASK (~T3_16BIT_RW) // Mask Timer3 16-Bit Read/Write Mode Enable bit
#endif
void OpenTimer3 ( unsigned char config, unsigned char config1);
void CloseTimer3 (void);
unsigned int ReadTimer3 (void);
void WriteTimer3 ( unsigned int timer3);
#endif
/* ***** TIMER4 ***** */
#if defined(TMR_V4) || defined(TMR_V6) || defined (TMR_V7) || defined (TMR_V7_1)\
||defined (TMR_V7_2) || defined (TMR_V7_3) || defined (TMR_V7_4)
/* TIMER4 configuration masks -- to be 'anded' together and passed to the
* 'open' routine. */
#ifndef USE_OR_MASKS
#define T4_POST_1_1 0b10000111 //Timer4 Postscaler 1:1
#define T4_POST_1_2 0b10001111 //Timer4 Postscaler 1:2
#define T4_POST_1_3 0b10010111 //Timer4 Postscaler 1:3
#define T4_POST_1_4 0b10011111 //Timer4 Postscaler 1:4
#define T4_POST_1_5 0b10100111 //Timer4 Postscaler 1:5
#define T4_POST_1_6 0b10101111 //Timer4 Postscaler 1:6
#define T4_POST_1_7 0b10110111 //Timer4 Postscaler 1:7
#define T4_POST_1_8 0b10111111 //Timer4 Postscaler 1:8
#define T4_POST_1_9 0b11000111 //Timer4 Postscaler 1:9
#define T4_POST_1_10 0b11001111 //Timer4 Postscaler 1:10
#define T4_POST_1_11 0b11010111 //Timer4 Postscaler 1:11
#define T4_POST_1_12 0b11011111 //Timer4 Postscaler 1:12
#define T4_POST_1_13 0b11100111 //Timer4 Postscaler 1:13
#define T4_POST_1_14 0b11101111 //Timer4 Postscaler 1:14
#define T4_POST_1_15 0b11110111 //Timer4 Postscaler 1:15
#define T4_POST_1_16 0b11111111 //Timer4 Postscaler 1:16
#define T4_PS_1_1 0b11111100 //Timer4 Prescale 1:1
#define T4_PS_1_4 0b11111101 //Timer4 Prescale 1:4
#define T4_PS_1_16 0b11111111 //Timer4 Prescale 1:16
#else //!USE_OR_MASKS
#define T4_POST_1_1 0b00000000 // Timer4 Postscaler 1:1
#define T4_POST_1_2 0b00001000 // Timer4 Postscaler 1:2
#define T4_POST_1_3 0b00010000 // Timer4 Postscaler 1:3
#define T4_POST_1_4 0b00011000 // Timer4 Postscaler 1:4
#define T4_POST_1_5 0b00100000 // Timer4 Postscaler 1:5
#define T4_POST_1_6 0b00101000 // Timer4 Postscaler 1:6
#define T4_POST_1_7 0b00110000 // Timer4 Postscaler 1:7
#define T4_POST_1_8 0b00111000 // Timer4 Postscaler 1:8
#define T4_POST_1_9 0b01000000 // Timer4 Postscaler 1:9
#define T4_POST_1_10 0b01001000 // Timer4 Postscaler 1:10
#define T4_POST_1_11 0b01010000 // Timer4 Postscaler 1:11
#define T4_POST_1_12 0b01011000 // Timer4 Postscaler 1:12
#define T4_POST_1_13 0b01100000 // Timer4 Postscaler 1:13
#define T4_POST_1_14 0b01101000 // Timer4 Postscaler 1:14
#define T4_POST_1_15 0b01110000 // Timer4 Postscaler 1:15
#define T4_POST_1_16 0b01111000 // Timer4 Postscaler 1:16
#define T4_POST_MASK (~T4_POST_1_16) //Mask Timer4 Postscale Select bits
#define T4_PS_1_1 0b00000000 //Timer4 Prescale 1:1
#define T4_PS_1_4 0b00000001 //Timer4 Prescale 1:4
#define T4_PS_1_16 0b00000011 //Timer4 Prescale 1:16
#define T4_PS_MASK (~T4_PS_1_16) //Mask Timer4 Input Clock Prescale Select bits
#endif //USE_OR_MASKS
/***********************************************************************************
Macro : WriteTimer4(timer4)
Include : timers.h
Description : Macro writes the parameter passed to TIMER4 count register TMR4
Arguments : timer4 : value to be written to TIMER4 count register TMR4
Remarks : None
***********************************************************************************/
#define WriteTimer4(timer4) TMR4 = (timer4)
/***********************************************************************************
Macro : ReadTimer4()
Include : timers.h
Description : Macro returns the TMR4 register value of TIMER4
Arguments : None
Returns : TMR4 value
***********************************************************************************/
#define ReadTimer4() TMR4
void OpenTimer4 ( unsigned char config);
void CloseTimer4 (void);
//unsigned char ReadTimer4 (void);
#endif
//-------- TIMER 5 DECLARATION ---------------------
#if defined (TMR_V5)
#ifndef USE_OR_MASKS
#define T5_SLP_EN 0b11111111 //Timer5 Enable during sleep
#define T5_SLP_DIS 0b01111111 //Timer5 Disable during sleep
#define T5_SP_EVNT_REN 0b10111111 //Timer5 special event reset enable
#define T5_SP_EVNT_RDIS 0b11111111 //Timer5 special event reset disable
#define T5_MD_SNGL_SHOT 0b11111111 //Timer5 SINGLE SHOT MODE
#define T5_MD_CONT_COUNT 0b11011111 //Timer5 CONTINOUS COUNT MODE
#define T5_PS_1_1 0b11100111 //Timer5 Prescale 1:1
#define T5_PS_1_2 0b11101111 //Timer5 Prescale 1:2
#define T5_PS_1_4 0b11110111 //Timer5 Prescale 1:4
#define T5_PS_1_8 0b11111111 //Timer5 Prescale 1:8
#define T5_EX_CLK_SYNC 0b11111011 // Synchronize external clock input
#define T5_EX_CLK_NOSYNC 0b11111111 // Do not synchronize external clock input
#define T5_CLK_EXTRN 0b11111111 //Transition on TxCKI pin acts as source of clock
#define T5_CLK_INT 0b11111101 //Internal instruction cycle clock (CLKO) acts as source of clock
#else //!USE_OR_MASKS
#define T5_SLP_EN 0b10000000 //Timer5 Enable during sleep
#define T5_SLP_DIS 0b00000000 //Timer5 Disable during sleep
#define T5_SLP_MASK (~T5_SLP_EN) //Mask Timer5 Sleep Enable bit
#define T5_SP_EVNT_REN 0b00000000 //Timer5 special event reset enable
#define T5_SP_EVNT_RDIS 0b01000000 //Timer5 special event reset disable
#define T5_SP_ENNT_MASK (~T5_SP_EVNT_RDIS) //Mask TIMER5 Special Event Trigger Reset Enable bit
#define T5_MD_SNGL_SHOT 0b00100000 //Timer5 SINGLE SHOT MODE
#define T5_MD_CONT_COUNT 0b00000000 //Timer5 CONTINOUS COUNT MODE
#define T5_MD_MASK (~T5_MD_SNGL_SHOT) //Mask Timer5 Mode bit
#define T5_PS_1_1 0b00000000 //Timer5 Prescale 1:1
#define T5_PS_1_2 0b00001000 //Timer5 Prescale 1:2
#define T5_PS_1_4 0b00010000 //Timer5 Prescale 1:4
#define T5_PS_1_8 0b00011000 //Timer5 Prescale 1:8
#define T5_PS_MASK (~T5_PS_1_8) //Mask Timer5 Input Clock Prescale Select bits
#define T5_EX_CLK_SYNC 0b00000000 // Synchronize external clock input
#define T5_EX_CLK_NOSYNC 0b00000100 // Do not synchronize external clock input
#define T5_EX_CLK_SYNC_MASK (~T5_EX_CLK_NOSYNC) // Mask Timer5 External Clock Input Synchronization Select bit
#define T5_CLK_EXTRN 0b00000010 //Transition on TxCKI pin acts as source of clock
#define T5_CLK_INT 0b00000000 //Internal instruction cycle clock (CLKO) acts as source of clock
#define T5_CLK_SOURCE_MASK (~T5_CLK_EXTRN) //Mask Timer5 Clock Source Select bits
#endif //USE_OR_MASKS
void CloseTimer5(void);
void OpenTimer5( unsigned char, unsigned int);
unsigned int ReadTimer5(void);
void WriteTimer5( unsigned int);
#elif defined (TMR_V7) || defined (TMR_V7_1) || defined (TMR_V7_3) || defined (TMR_V7_4)
#ifndef USE_OR_MASKS
#if defined (TMR_V7_4)
#define T5_SOURCE_INTOSC 0b11111111 // Clock source is INTOSC
#endif
#define T5_SOURCE_PINOSC 0b11011111 // Clock source SOSCEN = 0 Ext clock, SOSCEN=1 Crystal osc
#define T5_SOURCE_FOSC_4 0b10011111 //Clock source is instruction clock (FOSC/4)
#define T5_SOURCE_FOSC 0b10111111 //Closck source is system clock (FOSC)
#define T5_PS_1_1 0b11100111 //Timer5 1:1 prescale value
#define T5_PS_1_2 0b11101111 //Timer5 1:2 prescale value
#define T5_PS_1_4 0b11110111 //Timer5 1:4 prescale value
#define T5_PS_1_8 0b11111111 //Timer5 1:8 prescale value
#define T5_OSC1EN_OFF 0b11111011 // Timer1 oscilator disabled which is used by Timer5
#define T5_OSC1EN_ON 0b11111111 // Timer1 oscilator enabled which is used by Timer5
#define T5_SYNC_EXT_ON 0b11111101 // Synchronize external clock input
#define T5_SYNC_EXT_OFF 0b11111111 // Do not synchronize external clock input
#define T5_8BIT_RW 0b11111110 //Enables register read/write of Timer5 in two 8-bit operations
#define T5_16BIT_RW 0b11111111 //Enables register read/write of Timer5 in two 16-bit operations
#else
#if defined (TMR_V7_4)
#define T5_SOURCE_INTOSC 0b00000000 // Clock source is INTOSC
#endif
#define T5_SOURCE_PINOSC 0b01000000 // Clock source SOSCEN = 0 Ext clock, SOSCEN=1 Crystal osc
#define T5_SOURCE_FOSC_4 0b00000000 //Clock source is instruction clock (FOSC/4)
#define T5_SOURCE_FOSC 0b00100000 //Closck source is system clock (FOSC)
#define T5_SOURCE_MASK (~T5_SOURCE_FOSC) //Mask Timer5 Clock Source Select bits
#define T5_PS_1_1 0b00000000 //Timer5 1:1 prescale value
#define T5_PS_1_2 0b00001000 //Timer5 1:2 prescale value
#define T5_PS_1_4 0b00010000 //Timer5 1:4 prescale value
#define T5_PS_1_8 0b00011000 //Timer5 1:8 prescale value
#define T5_PS_MASK (~T5_PS_1_8) //Mask Timer5 Input Clock Prescale Select bits
#define T5_OSC1EN_OFF 0b00000000 // Timer1 oscilator disabled which is used by Timer5
#define T5_OSC1EN_ON 0b00000100 // Timer1 oscilator enabled which is used by Timer5
#define T5_OSC_MASK (~T5_OSC1EN_ON) //Mask Timer5 Oscillator Source Select bit
#define T5_SYNC_EXT_ON 0b00000000 // Synchronize external clock input
#define T5_SYNC_EXT_OFF 0b00000010 // Do not synchronize external clock input
#define T5_SYNC_MASK (~T5_SYNC_EXT_OFF) // Mask Timer5 External Clock Input Synchronization Select bit
#define T5_8BIT_RW 0b00000000 //Enables register read/write of Timer5 in two 8-bit operations
#define T5_16BIT_RW 0b00000001 //Enables register read/write of Timer5 in two 16-bit operations
#define T5_BIT_RW_MASK (~T5_16BIT_RW) // Mask Timer5 16-Bit Read/Write Mode Enable bit
#endif
void OpenTimer5 ( unsigned char config, unsigned char config1);
void CloseTimer5 (void);
unsigned int ReadTimer5 (void);
void WriteTimer5 ( unsigned int Timer5);
#endif
#if defined (TMR_V7) || defined (TMR_V7_1) || defined (TMR_V7_3) || defined (TMR_V7_4)
/* TIMER6 configuration masks -- to be 'anded' together and passed to the
* 'open' routine. */
#ifndef USE_OR_MASKS
#define T6_POST_1_1 0b10000111 //Timer6 Postscaler 1:1
#define T6_POST_1_2 0b10001111 //Timer6 Postscaler 1:2
#define T6_POST_1_3 0b10010111 //Timer6 Postscaler 1:3
#define T6_POST_1_4 0b10011111 //Timer6 Postscaler 1:4
#define T6_POST_1_5 0b10100111 //Timer6 Postscaler 1:5
#define T6_POST_1_6 0b10101111 //Timer6 Postscaler 1:6
#define T6_POST_1_7 0b10110111 //Timer6 Postscaler 1:7
#define T6_POST_1_8 0b10111111 //Timer6 Postscaler 1:8
#define T6_POST_1_9 0b11000111 //Timer6 Postscaler 1:9
#define T6_POST_1_10 0b11001111 //Timer6 Postscaler 1:10
#define T6_POST_1_11 0b11010111 //Timer6 Postscaler 1:11
#define T6_POST_1_12 0b11011111 //Timer6 Postscaler 1:12
#define T6_POST_1_13 0b11100111 //Timer6 Postscaler 1:13
#define T6_POST_1_14 0b11101111 //Timer6 Postscaler 1:14
#define T6_POST_1_15 0b11110111 //Timer6 Postscaler 1:15
#define T6_POST_1_16 0b11111111 //Timer6 Postscaler 1:16
#define T6_PS_1_1 0b11111100 //Timer6 Prescale 1:1
#define T6_PS_1_4 0b11111101 //Timer6 Prescale 1:4
#define T6_PS_1_16 0b11111111 //Timer6 Prescale 1:16
#else //!USE_OR_MASKS
#define T6_POST_1_1 0b00000000 // Timer6 Postscaler 1:1
#define T6_POST_1_2 0b00001000 // Timer6 Postscaler 1:2
#define T6_POST_1_3 0b00010000 // Timer6 Postscaler 1:3
#define T6_POST_1_4 0b00011000 // Timer6 Postscaler 1:4
#define T6_POST_1_5 0b00100000 // Timer6 Postscaler 1:5
#define T6_POST_1_6 0b00101000 // Timer6 Postscaler 1:6
#define T6_POST_1_7 0b00110000 // Timer6 Postscaler 1:7
#define T6_POST_1_8 0b00111000 // Timer6 Postscaler 1:8
#define T6_POST_1_9 0b01000000 // Timer6 Postscaler 1:9
#define T6_POST_1_10 0b01001000 // Timer6 Postscaler 1:10
#define T6_POST_1_11 0b01010000 // Timer6 Postscaler 1:11
#define T6_POST_1_12 0b01011000 // Timer6 Postscaler 1:12
#define T6_POST_1_13 0b01100000 // Timer6 Postscaler 1:13
#define T6_POST_1_14 0b01101000 // Timer6 Postscaler 1:14
#define T6_POST_1_15 0b01110000 // Timer6 Postscaler 1:15
#define T6_POST_1_16 0b01111000 // Timer6 Postscaler 1:16
#define T6_POST_MASK (~T6_POST_1_16) //Mask Timer6 Postscale Select bits
#define T6_PS_1_1 0b00000000 //Timer6 Prescale 1:1
#define T6_PS_1_4 0b00000001 //Timer6 Prescale 1:4
#define T6_PS_1_16 0b00000011 //Timer6 Prescale 1:16
#define T6_PS_MASK (~T6_PS_1_16) //Mask Timer6 Input Clock Prescale Select bits
#endif //USE_OR_MASKS
/***********************************************************************************
Macro : WriteTimer6(Timer6)
Include : timers.h
Description : Macro writes the parameter passed to Timer6 count register TMR6
Arguments : Timer6 : value to be written to Timer6 count register TMR6
Remarks : None
***********************************************************************************/
#define WriteTimer6(Timer6) TMR6 = (Timer6)
/***********************************************************************************
Macro : ReadTimer6()
Include : timers.h
Description : Macro returns the TMR6 register value of Timer6
Arguments : None
Returns : TMR6 value
***********************************************************************************/
#define ReadTimer6() TMR6
void OpenTimer6 ( unsigned char config);
void CloseTimer6 (void);
#endif
#if defined (TMR_V7)
#ifndef USE_OR_MASKS
#define T7_SOURCE_PINOSC 0b11011111 // Clock source SOSCEN = 0 Ext clock, SOSCEN=1 Crystal osc
#define T7_SOURCE_FOSC_4 0b10011111 //Clock source is instruction clock (FOSC/4)
#define T7_SOURCE_FOSC 0b10111111 //Closck source is system clock (FOSC)
#define T7_PS_1_1 0b11100111 //Timer7 1:1 prescale value
#define T7_PS_1_2 0b11101111 //Timer7 1:2 prescale value
#define T7_PS_1_4 0b11110111 //Timer7 1:4 prescale value
#define T7_PS_1_8 0b11111111 //Timer7 1:8 prescale value
#define T7_OSC1EN_OFF 0b11111011 // Timer1 oscilator disabled which is used by Timer7
#define T7_OSC1EN_ON 0b11111111 // Timer1 oscilator enabled which is used by Timer7
#define T7_SYNC_EXT_ON 0b11111101 // Synchronize external clock input
#define T7_SYNC_EXT_OFF 0b11111111 // Do not synchronize external clock input
#define T7_8BIT_RW 0b11111110 //Enables register read/write of Timer7 in two 8-bit operations
#define T7_16BIT_RW 0b11111111 //Enables register read/write of Timer7 in two 16-bit operations
#else
#define T7_SOURCE_PINOSC 0b01000000 // Clock source SOSCEN = 0 Ext clock, SOSCEN=1 Crystal osc
#define T7_SOURCE_FOSC_4 0b00000000 //Clock source is instruction clock (FOSC/4)
#define T7_SOURCE_FOSC 0b00100000 //Closck source is system clock (FOSC)
#define T7_SOURCE_MASK (~T7_SOURCE_FOSC) //Mask Timer7 Clock Source Select bits
#define T7_PS_1_1 0b00000000 //Timer7 1:1 prescale value
#define T7_PS_1_2 0b00001000 //Timer7 1:2 prescale value
#define T7_PS_1_4 0b00010000 //Timer7 1:4 prescale value
#define T7_PS_1_8 0b00011000 //Timer7 1:8 prescale value
#define T7_PS_MASK (~T7_PS_1_8) //Mask Timer7 Input Clock Prescale Select bits
#define T7_OSC1EN_OFF 0b00000000 // Timer1 oscilator disabled which is used by Timer7
#define T7_OSC1EN_ON 0b00000100 // Timer1 oscilator enabled which is used by Timer7
#define T7_OSC_MASK (~T7_OSC1EN_ON) //Mask Timer7 Oscillator Source Select bit
#define T7_SYNC_EXT_ON 0b00000000 // Synchronize external clock input
#define T7_SYNC_EXT_OFF 0b00000010 // Do not synchronize external clock input
#define T7_SYNC_MASK (~T7_SYNC_EXT_OFF) // Mask Timer7 External Clock Input Synchronization Select bit
#define T7_8BIT_RW 0b00000000 //Enables register read/write of Timer7 in two 8-bit operations
#define T7_16BIT_RW 0b00000001 //Enables register read/write of Timer7 in two 16-bit operations
#define T7_BIT_RW_MASK (~T7_16BIT_RW) // Mask Timer7 16-Bit Read/Write Mode Enable bit
#endif
void OpenTimer7 ( unsigned char config, unsigned char config1);
void CloseTimer7 (void);
unsigned int ReadTimer7 (void);
void WriteTimer7 ( unsigned int Timer7);
#endif
#if defined (TMR_V7) || defined (TMR_V7_1) || defined (TMR_V7_4)
/* Timer8 configuration masks -- to be 'anded' together and passed to the
* 'open' routine. */
#ifndef USE_OR_MASKS
#define T8_POST_1_1 0b10000111 //Timer8 Postscaler 1:1
#define T8_POST_1_2 0b10001111 //Timer8 Postscaler 1:2
#define T8_POST_1_3 0b10010111 //Timer8 Postscaler 1:3
#define T8_POST_1_4 0b10011111 //Timer8 Postscaler 1:4
#define T8_POST_1_5 0b10100111 //Timer8 Postscaler 1:5
#define T8_POST_1_6 0b10101111 //Timer8 Postscaler 1:6
#define T8_POST_1_7 0b10110111 //Timer8 Postscaler 1:7
#define T8_POST_1_8 0b10111111 //Timer8 Postscaler 1:8
#define T8_POST_1_9 0b11000111 //Timer8 Postscaler 1:9
#define T8_POST_1_10 0b11001111 //Timer8 Postscaler 1:10
#define T8_POST_1_11 0b11010111 //Timer8 Postscaler 1:11
#define T8_POST_1_12 0b11011111 //Timer8 Postscaler 1:12
#define T8_POST_1_13 0b11100111 //Timer8 Postscaler 1:13
#define T8_POST_1_14 0b11101111 //Timer8 Postscaler 1:14
#define T8_POST_1_15 0b11110111 //Timer8 Postscaler 1:15
#define T8_POST_1_16 0b11111111 //Timer8 Postscaler 1:16
#define T8_PS_1_1 0b11111100 //Timer8 Prescale 1:1
#define T8_PS_1_4 0b11111101 //Timer8 Prescale 1:4
#define T8_PS_1_16 0b11111111 //Timer8 Prescale 1:16
#else //!USE_OR_MASKS
#define T8_POST_1_1 0b00000000 // Timer8 Postscaler 1:1
#define T8_POST_1_2 0b00001000 // Timer8 Postscaler 1:2
#define T8_POST_1_3 0b00010000 // Timer8 Postscaler 1:3
#define T8_POST_1_4 0b00011000 // Timer8 Postscaler 1:4
#define T8_POST_1_5 0b00100000 // Timer8 Postscaler 1:5
#define T8_POST_1_6 0b00101000 // Timer8 Postscaler 1:6
#define T8_POST_1_7 0b00110000 // Timer8 Postscaler 1:7
#define T8_POST_1_8 0b00111000 // Timer8 Postscaler 1:8
#define T8_POST_1_9 0b01000000 // Timer8 Postscaler 1:9
#define T8_POST_1_10 0b01001000 // Timer8 Postscaler 1:10
#define T8_POST_1_11 0b01010000 // Timer8 Postscaler 1:11
#define T8_POST_1_12 0b01011000 // Timer8 Postscaler 1:12
#define T8_POST_1_13 0b01100000 // Timer8 Postscaler 1:13
#define T8_POST_1_14 0b01101000 // Timer8 Postscaler 1:14
#define T8_POST_1_15 0b01110000 // Timer8 Postscaler 1:15
#define T8_POST_1_16 0b01111000 // Timer8 Postscaler 1:16
#define T8_POST_MASK (~T8_POST_1_16) //Mask Timer8 Postscale Select bits
#define T8_PS_1_1 0b00000000 //Timer8 Prescale 1:1
#define T8_PS_1_4 0b00000001 //Timer8 Prescale 1:4
#define T8_PS_1_16 0b00000011 //Timer8 Prescale 1:16
#define T8_PS_MASK (~T8_PS_1_16) //Mask Timer8 Input Clock Prescale Select bits
#endif //USE_OR_MASKS
/***********************************************************************************
Macro : WriteTimer8(Timer8)
Include : timers.h
Description : Macro writes the parameter passed to Timer8 count register TMR8
Arguments : Timer8 : value to be written to Timer8 count register TMR8
Remarks : None
***********************************************************************************/
#define WriteTimer8(Timer8) TMR8 = (Timer8)
/***********************************************************************************
Macro : ReadTimer8()
Include : timers.h
Description : Macro returns the TMR8 register value of Timer8
Arguments : None
Returns : TMR8 value
***********************************************************************************/
#define ReadTimer8() TMR8
void OpenTimer8 ( unsigned char config);
void CloseTimer8 (void);
#endif
#if defined (TMR_V7)
/* Timer10 configuration masks -- to be 'anded' together and passed to the
* 'open' routine. */
#ifndef USE_OR_MASKS
#define T10_POST_1_1 0b10000111 //Timer10 Postscaler 1:1
#define T10_POST_1_2 0b10001111 //Timer10 Postscaler 1:2
#define T10_POST_1_3 0b10010111 //Timer10 Postscaler 1:3
#define T10_POST_1_4 0b10011111 //Timer10 Postscaler 1:4
#define T10_POST_1_5 0b10100111 //Timer10 Postscaler 1:5
#define T10_POST_1_6 0b10101111 //Timer10 Postscaler 1:6
#define T10_POST_1_7 0b10110111 //Timer10 Postscaler 1:7
#define T10_POST_1_8 0b10111111 //Timer10 Postscaler 1:8
#define T10_POST_1_9 0b11000111 //Timer10 Postscaler 1:9
#define T10_POST_1_10 0b11001111 //Timer10 Postscaler 1:10
#define T10_POST_1_11 0b11010111 //Timer10 Postscaler 1:11
#define T10_POST_1_12 0b11011111 //Timer10 Postscaler 1:12
#define T10_POST_1_13 0b11100111 //Timer10 Postscaler 1:13
#define T10_POST_1_14 0b11101111 //Timer10 Postscaler 1:14
#define T10_POST_1_15 0b11110111 //Timer10 Postscaler 1:15
#define T10_POST_1_16 0b11111111 //Timer10 Postscaler 1:16
#define T10_PS_1_1 0b11111100 //Timer10 Prescale 1:1
#define T10_PS_1_4 0b11111101 //Timer10 Prescale 1:4
#define T10_PS_1_16 0b11111111 //Timer10 Prescale 1:16
#else //!USE_OR_MASKS
#define T10_POST_1_1 0b00000000 // Timer10 Postscaler 1:1
#define T10_POST_1_2 0b00001000 // Timer10 Postscaler 1:2
#define T10_POST_1_3 0b00010000 // Timer10 Postscaler 1:3
#define T10_POST_1_4 0b00011000 // Timer10 Postscaler 1:4
#define T10_POST_1_5 0b00100000 // Timer10 Postscaler 1:5
#define T10_POST_1_6 0b00101000 // Timer10 Postscaler 1:6
#define T10_POST_1_7 0b00110000 // Timer10 Postscaler 1:7
#define T10_POST_1_8 0b00111000 // Timer10 Postscaler 1:8
#define T10_POST_1_9 0b01000000 // Timer10 Postscaler 1:9
#define T10_POST_1_10 0b01001000 // Timer10 Postscaler 1:10
#define T10_POST_1_11 0b01010000 // Timer10 Postscaler 1:11
#define T10_POST_1_12 0b01011000 // Timer10 Postscaler 1:12
#define T10_POST_1_13 0b01100000 // Timer10 Postscaler 1:13
#define T10_POST_1_14 0b01101000 // Timer10 Postscaler 1:14
#define T10_POST_1_15 0b01110000 // Timer10 Postscaler 1:15
#define T10_POST_1_16 0b01111000 // Timer10 Postscaler 1:16
#define T10_POST_MASK (~T10_POST_1_16) //Mask Timer10 Postscale Select bits
#define T10_PS_1_1 0b00000000 //Timer10 Prescale 1:1
#define T10_PS_1_4 0b00000001 //Timer10 Prescale 1:4
#define T10_PS_1_16 0b00000011 //Timer10 Prescale 1:16
#define T10_PS_MASK (~T10_PS_1_16) //Mask Timer10 Input Clock Prescale Select bits
#endif //USE_OR_MASKS
/***********************************************************************************
Macro : WriteTimer10(Timer10)
Include : timers.h
Description : Macro writes the parameter passed to Timer10 count register TMR10
Arguments : Timer10 : value to be written to Timer10 count register TMR10
Remarks : None
***********************************************************************************/
#define WriteTimer10(Timer10) TMR10 = (Timer10)
/***********************************************************************************
Macro : ReadTimer10()
Include : timers.h
Description : Macro returns the TMR10 register value of Timer10
Arguments : None
Returns : TMR10 value
***********************************************************************************/
#define ReadTimer10() TMR10
void OpenTimer10 ( unsigned char config);
void CloseTimer10 (void);
#endif
#if defined (TMR_V7)
/* Timer12 configuration masks -- to be 'anded' together and passed to the
* 'open' routine. */
#ifndef USE_OR_MASKS
#define T12_POST_1_1 0b10000111 //Timer12 Postscaler 1:1
#define T12_POST_1_2 0b10001111 //Timer12 Postscaler 1:2
#define T12_POST_1_3 0b10010111 //Timer12 Postscaler 1:3
#define T12_POST_1_4 0b10011111 //Timer12 Postscaler 1:4
#define T12_POST_1_5 0b10100111 //Timer12 Postscaler 1:5
#define T12_POST_1_6 0b10101111 //Timer12 Postscaler 1:6
#define T12_POST_1_7 0b10110111 //Timer12 Postscaler 1:7