hi,
> P2DIR |= 0x00;
What's that supposed to do? It doesn't do anything
I don't see you selecting P2.0 and P2.2 in peripheral mode. I'm not
sure it's necessary, but I think you should do so.
What MSP chip does your development board have?
I didn't understand how you're connecting the potentiometer.
Michael K.
--- In m..., gbadvancero wrote:
>
>
> Hi everyone. I'm connecting a potentiometer to my MSP430 RF2500
development
> board. The potentiometer center and right output which creates the
potential
> differential that I need to measure to know the position of the
> potentiometer are connected to P2.0 and P2.2 and the OA is set as general
> purpose (which I guessed that it makes the difference of the potencial
> between P2.0 and P2.2).
>
> The range of the potentiometer goes from 100 mV to 2100 mV approx.
That's
> why I decided to set a gain of 1 (0+1) and set the upper reference voltage
> to 2.5V (and the lower reference voltage to 0).
>
> Well, after that, I set the ADC10. And the result? It doesn't work.
The
> ADC10MEM register always is 1023 (as if the result is over the range).
>
> This is the code (sorry for the comments in spanish as i'm spanish)
>
>
>
>
> #include "msp430x22x4.h"
>
>
> void TXString( char* string, int length );
>
> void main(void){
> WDTCTL = WDTPW + WDTHOLD; // Stop WDT
> long volt=0, posmin=0, posmax=0, dr=0, res=0, vmin=0, vmax=0;
> long nmax=0, nmin=0, degC;
> long posicion;
>
>
>
> BCSCTL1 = CALBC1_1MHZ; // Set DCO
> DCOCTL = CALDCO_1MHZ;
> P3SEL = 0x30; // P3.4,5 = USCI_A0 TXD/RXD
> P2DIR |= 0x00;
>
>
> UCA0CTL1 |= UCSSEL_2; // SMCLK
> UCA0BR0 = 104; // 1MHz 9600
> UCA0BR1 = 0; // 1MHz 9600
> UCA0MCTL = UCBRS0; // Modulation UCBRSx = 1
> UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state
> machine**
> IE2 |= UCA0RXIE; // Enable USCI_A0 RX interrupt
> while(1){
> //__bis_SR_register(LPM0_bits + GIE); /00/ Enter LPM0, interrupts
> enabled
> //Función 1: Recepción de datos del sensor
> //Se realiza la función 1 directamente con la función 2
>
> //Función 2: Amplificación de la señal recibida
>
> // __bis_SR_register(LPM3_bits+GIE); // LPM3 con interrupcions
> habilitadas
> OA0CTL0 = OAPM_1+ OAN_1 + OAP_0 + OAADC1 ; // Señal + del
sensor
> conectada a OA0IO (Pin 3)
> // Salida conectada en el A1
> OA0CTL1 = OAFBR_0 + OAFC_7; // Modo Amplificador Operacional General,
G=1
>
>
>
>
> //Función 3: Conversión A/D
>
> ADC10AE0 |= 0x02; //Entrada por el puerto A1
> ADC10CTL1 = INCH_1 + ADC10DIV_4; // Entrada A1
> ADC10CTL0 = SREF_1 + ADC10SHT_3 + ADC10ON + ADC10IE + ADC10SR + REFON +
> REF2_5V;
> // Tensión máxima 2.5 V, mínima 0 V
> for( degC = 240; degC > 0; degC-- );//Retraso para que se fije la
> configuración
> ADC10CTL0 |= ENC + ADC10SC; // Comienzo de la
conversión
> // __bis_SR_register(CPUOFF + GIE); // LPM0 con interrupciones
> habilitadas
> volt=ADC10MEM; //guardamos en la variable VOLT el dato de la
> conversión
>
> ADC10CTL0 &= ~ENC;
> ADC10CTL0 &= ~(REFON + ADC10ON); // se desactiva el A/D para ahorrar
> energia
> }
> --
>
>