|
G:\HPamp-2\program\protector.X\mcc_generated_files\tmr0.c |
1 /**
2 TMR0 Generated Driver File
3 4 @Company
5 Microchip Technology Inc.
6 7 @File Name
8 tmr0.c 9 10 @Summary
11 This is the generated driver implementation file for the TMR0 driver using MPLAB(c) Code Configurator
12 13 @Description
14 This source file provides APIs for TMR0.
15 Generation Information :
16 Product Revision : MPLAB(c) Code Configurator - 3.15.0
17 Device : PIC16F1823
18 Driver Version : 2.00
19 The generated drivers are tested against the following:
20 Compiler : XC8 1.35
21 MPLAB : MPLAB X 3.20
22 */
23 24 /*
25 (c) 2016 Microchip Technology Inc. and its subsidiaries. You may use this
26 software and any derivatives exclusively with Microchip products. 27 28 THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
29 EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED
30 WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A
31 PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION32 WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION.
33 34 IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
35 INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
36 WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS
37 BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE
38 FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN
39 ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
40 THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
41 42 MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE
43 TERMS.
44 */
45 46 /**
47 Section: Included Files
48 */
49 50 #include <xc.h>
51 #include "tmr0.h"
52 53 /**
54 Section: Global Variables Definitions
55 */
56 57 volatile uint8_t timer0ReloadVal;
58 59 /**
60 Section: TMR0 APIs
61 */
62 63 void TMR0_Initialize(void)
64 {65 // Set TMR0 to the options selected in the User Interface
66 67 // PSA assigned; PS 1:256; TMRSE Increment_hi_lo; mask the nWPUEN and INTEDG bits
68 OPTION_REG = (OPTION_REG & 0xC0) | 0xD7 & 0x3F; 69 70 // TMR0 134;
71 TMR0 = 0x86; 72 73 // Load the TMR value to reload variable
74 timer0ReloadVal= 134; 75 76 // Clear Interrupt flag before enabling the interrupt
77 INTCONbits.TMR0IF = 0;
78 79 // Enabling TMR0 interrupt
80 INTCONbits.TMR0IE = 1;
81 } 82 83 84 uint8_t TMR0_ReadTimer(void)
85 {86 uint8_t readVal;
87 88 readVal = TMR0; 89 90 return readVal;
91 } 92 93 void TMR0_WriteTimer(uint8_t timerVal)
94 {95 // Write to the Timer0 register
96 TMR0 = timerVal; 97 } 98 99 void TMR0_Reload(void)
100 {101 // Write to the Timer0 register
102 TMR0 = timer0ReloadVal;103 }104 105 void TMR0_ISR(void)
106 {107 108 // clear the TMR0 interrupt flag
109 INTCONbits.TMR0IF = 0;
110 111 TMR0 = timer0ReloadVal;112 113 // ticker function call;
114 // ticker is 1 -> Callback function gets called everytime this ISR executes
115 TMR0_CallBack();116 117 // add your TMR0 interrupt custom code
118 }119 120 void TMR0_CallBack(void)
121 {122 // Add your custom callback code here
123 // this code executes every 1 TMR0 periods
124 if( RC4 == 0x0 ){125 // Power LED blink126 if ( RC5 == 0x1 ) {127 RC5 = 0x0 ;128 }129 else {130 RC5 = 0x1 ;131 }132 133 }134 }135 /**
136 End of File
137 */
138