iam using the msp430f2234 ADC to sample a voltage 0-3.6V 50Hz reduced from the 230V, 50Hz, and trigger a triac when the voltage is 1.8,
am finding problems sampling the wave, code would be of great help. i have attached a copy of my voltage reducing circuit
below is my sample code
#include <msp430x22x4.h>
volatile unsigned int i; // volatile to prevent optimization
double adc_value[1] = {0};
void main(void){
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
BCSCTL1 = CALBC1_1MHZ; // Set range
DCOCTL = CALDCO_1MHZ;
P1DIR |= 0x01; // Set P1.0 to output direction
P2DIR |=0xF8; // Set ports P2.0/1/2 to Input Direction
P2SEL |=0x07; // Select Ports P2.0/1/2 as analogue input function
ADC10CTL0 =ADC10ON + REF2_5V + ADC10SHT_3 + ENC + ADC10SC + MSC; //ADC ON, Reference Voltage to 2.5 V and select Up-mode
ADC10CTL1 = INCH_1 +CONSEQ_1; // Select A1 as input channel, repeat single channel as conversion sequence
ADC10DTC0 = ADC10CT; // continuous data transfer
__delay_cycles(1000);
ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start
adc_value[0] = ADC10MEM;
if ( adc_value[0] = 1011100000) {
__delay_cycles(16000);
P1OUT = BIT0; // high P1.0
__delay_cycles(100);
P1OUT &= ~0x01;
}
else{
P1OUT &= ~0x01;
}
}