Hi,
I am working on EVM430I2040S which has msp430i2040 on it. I am using three channels of ADC. One for voltage sampling, one for current sampling and third for temperature. The voltage and current samples are sent to PC through UART terminal. The sampling rate required is 2 KHz. Baud rate used is 115200. I applied sinusoidal input at the input channels but I am not getting sinusoidal output. I think there is case of under sampling but I am unable to spot the problem in code. What should I do to achieve a sampling rate of 2KHz and transmission using UART. Please find the attached code.
#include <msp430.h> unsigned int i; unsigned int value1,value2; unsigned char val_low,val_high; unsigned int value; /* * main.c */ void main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer P2DIR |= BIT3; // Set P1.0 to output direction SD24CTL=SD24REFS; // Internal Reference SD24CCTL0|=SD24GRP; //Group with channel 1 SD24CCTL1|=SD24GRP|SD24IE; // Group with channel 2 and enbling interrupt SD24INCTL1=0x20; // Gain=16 for channel 1 SD24CCTL2=0x00; SD24INCTL2=0x06; // Internal temp sensor to channel 2 P1SEL0|= BIT2|BIT3; //P1.2,3 eUSCI_A function P1SEL1&= ~(BIT2|BIT3); UCA0CTLW0|=UCSWRST; // Hold eUSCI in reset UCA0CTLW0|= UCSSEL_2; //SMCLK UCA0BR0=0x8E; // 115200 baud UCA0BR1=0x00; UCA0MCTLW=0x0022; UCA0CTLW0&=~(UCSWRST); //Release from reset for (i=0; i<20; i++) { __delay_cycles(16000); //1ms delay } SD24CCTL2|=SD24SC; // Set bit to start conversion __bis_SR_register(LPM0_bits|GIE); } #pragma vector= SD24_VECTOR __interrupt void SD24_ISR(void) { value1=SD24MEM0; // Voltage value2=SD24MEM1; // Current value= SD24MEM2; // temperature SD24PRE0= 0xFF; // delay in next conversion of channel 0 SD24PRE1= 0xFF; // delay in next conversion of channel 1 val_high=(value1>>8)&(0xFF); while (!(UCA0IFG&UCTXIFG)); // USCI_A0 TX buffer ready? UCA0TXBUF = val_high; // TX -> RXed character val_low=value1&(0xFF); while (!(UCA0IFG&UCTXIFG)); // USCI_A0 TX buffer ready? UCA0TXBUF = val_low; // TX -> RXed character val_high=(value2>>8)&(0xFF); while (!(UCA0IFG&UCTXIFG)); // USCI_A0 TX buffer ready? UCA0TXBUF = val_high; // TX -> RXed character val_low=value2&(0xFF); while (!(UCA0IFG&UCTXIFG)); // USCI_A0 TX buffer ready? UCA0TXBUF = val_low; // TX -> RXed character P2OUT ^= BIT3; // Toggle P1.0 using exclusive-OR }