-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTMR0.c
73 lines (62 loc) · 1.61 KB
/
TMR0.c
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
/*
* File: TMR0.c
* Author: Mario
*
*/
#include "TMR0.h"
/******************************************************************************
* @fn - TMR0_setup
* @brief - This function configure the TMR0 peripheral
*
* @param[in] - TMR0_CLK macros
* @param[in] - TMR0_EDGE macros
* @param[in] - SPBRG TMR0_PRESC macros
*
* @return - none
*
* @note - none
*****************************************************************************/
void TMR0_setup (uint8_t TMR0_CLK, uint8_t TMR0_EDGE, uint8_t TMR0_PRESC)
{
OPTION_REGbits.TMR0CS = TMR0_CLK;
OPTION_REGbits.TMR0SE = TMR0_EDGE;
if(TMR0_PRESC <= 7)
{
OPTION_REGbits.PSA = 0;
OPTION_REGbits.PS = TMR0_PRESC;
}
else
{
OPTION_REGbits.PSA = 1;
}
}
/******************************************************************************
* @fn - TMR0_INT_Handle
* @brief - This function handle the TMR0 interrupt
*
* @param[in] - TMR0REG_VALUE TMR0 register value
*
* @return - none
*
* @note - none
*****************************************************************************/
void TMR0_INT_Handle(uint8_t TMR0REG_VALUE)
{
INTCONbits.TMR0IF = 0;
TMR0 = TMR0REG_VALUE;
}
/******************************************************************************
* @fn - TMR0_EnableInterrupts
* @brief - This function enable the TMR0 interrupt
*
* @param[in] - none
*
* @return - none
*
* @note - none
*****************************************************************************/
void TMR0_EnableInterrupts(void)
{
INTCONbits.GIE = 1;
INTCONbits.TMR0IE = 1;
}