forked from jack-ross/EKG-Embedded
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ADC.c
executable file
·58 lines (47 loc) · 1.44 KB
/
ADC.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
#include "ADC.h"
#
void ConfigureADC(void)
{
/* ADC10 Control register 1
* INCH_0 = choose analog input A0
* INCH_10 = choose the temperature sensor as the analog input
*
* ADC10DIV_3 = divide ADC clock by 4 (for temperature sensor)
*/
ADC10CTL1 = (INCH_0 | ADC10DIV_3);
ADC10AE0 |= ADC10_A0_BIT; // Enable ADC10 A7
/* ADC10 Control register 0
* SREF_0: Choose Vcc reference for analog inputs
* SREF_1: Choose 1.5V reference for temperature sensor
*
* ADC10SHT_3 = 64 × ADC10CLKs (for temperature sensor)
*/
ADC10CTL0 = (SREF_0 | ADC10SHT_3 | ADC10ON);
_delay_cycles(1000); // Wait for the ADC to adjust and stabilize
ADC10CTL0 |= (ENC | ADC10SC); // Enable and begin sampling and conversion
}
/*
void ConfigureADC(void)
{
/* ADC10 Control register 1
* INCH_7 = choose analog input A4
*
* ADC10DIV_3 = divide ADC clock by 4 (for temperature sensor)
*/
//ADC10CTL1 = (INCH_4 | ADC10DIV_3);
// ADC10AE0 |= ADC10_A7_BIT; // Enable ADC10 A4
//
//
// /* ADC10 Control register 0
// * SREF_0: Choose Vcc reference for analog inputs
// * SREF_1: Choose 1.5V reference for temperature sensor
// *
// * ADC10SHT_3 = 64 × ADC10CLKs (for temperature sensor)
// */
// ADC10CTL0 = (SREF_0 | ADC10SHT_3 | ADC10ON);
//
//
// _delay_cycles(1000); // Wait for the ADC to adjust and stabilize
// ADC10CTL0 |= (ENC | ADC10SC); // Enable and begin sampling and conversion
//}
//