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:
#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