Hi,
I'm using A/D (6-channel single ended) for MSP430FG6626 with External reference (1.25 v) and I'm having some troubles with it, I don't get the right value .
when I apply 0.6v on the input I get (15728 in decimal) from the A/D and this is half what I should get (31457) .
I'm using the code provided from ti (msp430fg662x_ctsd16_07.c) with some change. and here the code . I'm using "MSP-TS430PZ100AUSB" for the micro
MSP430FG6626
// ------------------
// 32.768 kHz Watch crystal
// CH1 -->|P6.0/A0 |
// CH2 -->|P6.1/A1 |
// CH3 -->|P6.2/A2
// CH4 -->|P6.3/A3 |
// CH5 -->|P5.1/A4 |
// CH6-->|P5.6/A5 |
// P5.0-->VREF+ 1.25 v
#include <msp430.h>
#define Num_of_Channels 6
/* Arrays to store CTSD16 conversion results */
unsigned int Chresults[Num_of_Channels];
unsigned int index = 0;
void main(void) {
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog
P6SEL |= BIT0 | BIT1 | BIT2 | BIT3; // Select A0 to A3...
P5SEL |= BIT1 | BIT6; // Select A4,A5
P5SEL |= BIT0;
CTSD16INCTL0 |= CTSD16INCH_0;
CTSD16IFG &= ~CTSD16IFG0; // Clear CH0 result interrupt flag
CTSD16IE |= CTSD16IE0; // Enable CH0 result interrupts
__delay_cycles(2000); // Delay ~120us for 1.2V ref to settle
while(1) {
CTSD16CCTL0 |= CTSD16SC; // Set bit to start conversion
__bis_SR_register(LPM0_bits | GIE); // Enter LPM0 w/ interrupts
__no_operation(); // For debugger
if (index >= Num_of_Channels) {
index = 0; // SET BREAKPOINT HERE
CTSD16INCTL0 = CTSD16INCH_0; // Reset input to CH0
} else {
CTSD16INCTL0 += 1; // Increment CH count by 1
}
}
}
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=CTSD16_VECTOR
__interrupt void CTSD16_ISR(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(CTSD16_VECTOR))) CTSD16_ISR (void)
#else
#error Compiler not supported!
#endif
{
switch (__even_in_range(CTSD16IV,CTSD16IV_CTSD16MEM0)) {
case CTSD16IV_NONE: break;
case CTSD16IV_CTSD16OVIFG: break;
case CTSD16IV_CTSD16MEM0:
Chresults[index++] = CTSD16MEM0; // Save CH0 result (clears IFG)
__bic_SR_register_on_exit(LPM0_bits); // Wake up
break;
default: break;
}
}