Hi,
I am trying to read two voltage values on two channels (A0, A1) using the ADC10 of my MSP430F2274(eZ430-RF2500T), and display the voltages on my sparkfun serLCD v2.5. Example: 3V, 5V etc....
This is my code to read in two voltage inputs. Is this the correct way to read in two voltage inputs using the ADC10?
ADC10CTL1 = INCH_0 // A0
ADC10CTL0 = SREF_1 + ADC10SHT_2 + REFON + ADC10ON + ADC10IE + REF2_5V;
__bis_SR_register(GIE); // Enable interrupts. Vss Ref.
for(temp = 10; temp > 0; temp-- ); // delay to allow reference to settle
ADC10AE0 |= 0x01; // PA.0 ADC option select
ADC10CTL0 |= ENC + ADC10SC; // Start to perform sampling and conversion
for(temp = 10; temp > 0; temp-- ); // delay to allow reference to settle
unsigned int voltage1 = ADC10MEM;
ADC10CTL1 = INCH_1 ; // A1
ADC10CTL0 = SREF_1 + ADC10SHT_2 + REFON + ADC10ON + ADC10IE + REF2_5V;
__bis_SR_register(GIE); // Enable interrupts. Vss Ref.
for(temp1 = 10; temp1 > 0; temp1-- ); // delay to allow reference to settle
ADC10AE0 |= 0x02; // PA.1 ADC option select
ADC10CTL0 |= ENC + ADC10SC; // Start to perform sampling and conversion
for(temp1 = 10; temp1 > 0; temp1-- ); // delay to allow reference to settle
unsigned int voltage2 = ADC10MEM;
This is the code used for my LCD display:
// Set up the timer to simulate a UART
ConfigureTimerUart();
__delay_cycles(1000000); // wait for LCD display to initialize
__enable_interrupt();
TXByte = 0xFE; Transmit();
TXByte = 0x9F; Transmit();
__delay_cycles(500000);
TXString(voltage1);