MSP430F233 ADC12 convertion probleme

Discussions on how to get your MSP JTAG programmer up and running.

Moderator: phalanx

Post Reply
marcm89
Posts: 1
Joined: Tue May 20, 2014 6:07 am

MSP430F233 ADC12 convertion probleme

Post by marcm89 » Tue May 20, 2014 6:44 am

Hello,

First, sorry for my bad English.

I'm using the MSP430F233. On XT1 I have connected a quartz (32768Hz) whitch I use for comunication with UART and timers. I receive a comande by UART then I change the state of 3 bistable relays.
So far no problem.

I also want to do analog to digital conversions with the ADC12 in Repeat-Sequence-of-Channels Mode but I can not really happening, my problem is the sampling frequency.

I want to measure a signial 50Hz and the less I need 100 different values​​.

Here is my code:

Code: Select all

#include  <msp430x23x.h>
   
void init()
{
    // Stop WDT
    WDTCTL = WDTPW + WDTHOLD;          

    // Set CPU Speed (MCLK)
    if (CALBC1_1MHZ ==0xFF || CALDCO_1MHZ == 0xFF)                                     
    {  
      while(1);                               // If calibration constants erased do not load, trap CPU!!
    }   
    BCSCTL1 = CALBC1_1MHZ;                    // Set DCO
    DCOCTL = CALDCO_1MHZ;

    //SET ACLK
    P2DIR |= 0x05;                                    // P2.0,2 output direction
    P2SEL |= 0x01;                                    // P2.0 = ACLK
    __delay_cycles(100000); 
    BCSCTL1 |= DIVA_0;

    // Init UART
    P3SEL = 0x30;                                      // P3.4,5 = USCI_A0 TXD/RXD
    UCA0CTL1 |= UCSSEL_1;                      // ACLK
    UCA0BR0 = 7;                                       // 32768Hz --> 7 (ACLK)
    UCA0BR1 = 0;                              
    UCA0MCTL = UCBRS0;                           // Modulation UCBRSx = 1
    UCA0CTL1 &= ~UCSWRST;                     // Initialize USCI state machine
    IE2 |= UCA0RXIE;                                  // Enable USCI_A0 RX interrupt

   // Init ADC12
    P6SEL = 0x00;                             
    ADC12CTL0 &= ~ENC;
    ADC12CTL0 |= ADC12ON+MSC+SHT0_1+REFON+REF2_5V;                            
    ADC12CTL1 = SHP+ADC12SSEL0+ADC12DIV_0+CONSEQ_3;                 /
    ADC12MCTL0 = SREF_1 + INCH_0;                      
    ADC12MCTL1 = SREF_1 + INCH_1;                 
    ADC12MCTL2 = SREF_1 + INCH_2;                 
    ADC12MCTL3 = SREF_1 + INCH_3;        
    ADC12MCTL1 = SREF_1 + INCH_4;                 
    ADC12MCTL2 = SREF_1 + INCH_5;                 
    ADC12MCTL3 = SREF_1 + INCH_6+EOS;            
    ADC12IE = 0x40;                                    
    ADC12CTL0 |= ENC;                                 
    ADC12CTL0 |= ADC12SC;                              
    __bis_SR_register(GIE);                            
}

#pragma vector=ADC12_VECTOR
__interrupt void ADC12ISR (void)
{
  result1 = ADC12MEM0;             // Move A0 results, IFG is cleared
  result2 = ADC12MEM1;             // Move A1 results, IFG is cleared
  result3 = ADC12MEM2;             // Move A2 results, IFG is cleared
  result4 = ADC12MEM3;             // Move A3 results, IFG is cleared
  result5 = ADC12MEM4;             // Move A0 results, IFG is cleared
  result6 = ADC12MEM5;             // Move A1 results, IFG is cleared
  result7 = ADC12MEM6;             // Move A2 results, IFG is cleared
}
Thank you already for your help

UhClem
Posts: 413
Joined: Sun Aug 03, 2008 6:11 pm

Re: MSP430F233 ADC12 convertion probleme

Post by UhClem » Wed May 21, 2014 10:04 am

It is very difficult to tell what your problem is but I think it is the sampling rate. This shouldn't be a problem as there are plenty of ways to change it:

1) Use a different source for the ADC clock. Besides the ~5MHz ADC12OSC that you are using there is ACLK, MCLK, and SMCLK.
2) Divide the clock. You have the clock divider set to 1 and you could choose anything up to 8.
3) Use a timer to trigger the conversion sequence.

All of this is well covered in the SLAU144 document from TI.


One other thing, P6SEL should be set to 1's for the pins you want to use for the ADC in order to disable the pin buffers.

Post Reply