-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathADC.c
28 lines (24 loc) · 823 Bytes
/
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
#include "ADC.h"
//will need to modify to use with the 60 Hz signal from the fxn generator
//preconfigured for ADC
void ConfigureADC(void)
{
P1DIR &= ~BIT0;
P1DIR &= ~BIT1;
P1DIR &= ~BIT2;
/* ADC10 Control register 1
* INCH_10 = choose the temperature sensor as the analog input
* ADC10DIV_3 = divide ADC clock by 4 (for temperature sensor)
*/
ADC10CTL1 = (INCH_2 | CONSEQ_1);
ADC10AE0 = BIT2 | BIT0 | BIT1;
/* ADC10 Control register 0
* SREF_1: Choose 1.5V reference for temperature sensor
* ADC10SHT_3 = 64 ADC10CLKs (for temperature sensor)
*/
ADC10CTL0 = (SREF_0 | ADC10SHT_3 | REFON | ADC10ON | MSC);
// ADC10DTC0 |= (ADC10CT);
ADC10DTC1 = 0x03;
_delay_cycles(1000); // Wait for the ADC to adjust and stabilize
ADC10CTL0 |= (ENC | ADC10SC); // Enable and begin sampling and conversion
}