Other Parts Discussed in Thread: MSP430FR5994
Dear all,
I'm trying to do some DSP with the 4270 since it has an A/D and D/A. I have two questions:
1. Is there a good way to synchronize the input and output sample rates?
2. What is the best way to achieve the fastest sampling? i.e., how can I increase the clock going to the A/D and D/A and should I use interrupts?
Here's my code so far:
//***************************************************************************** // Audio Feedthru // // MSP430F4270 // ----------------- // | | // | DAC0/P1.4|--> Analog Out // | | // Vin+ -->|A0+ | // Vin- -->|A0- | // | | // | VREF |---+ // | | | // | | -+- 100nF // | | -+- // | | | // | AVss |---+ // //***************************************************************************** #include <msp430.h> unsigned int result; int main(void) { WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer FLL_CTL0 = DCOPLUS + XCAP14PF; // DCO+ set so freq = xtal x D x N+1 SD16CTL = SD16REFON+SD16SSEL0; // 1.2V ref, SMCLK SD16CCTL0 |= SD16SNGL+SD16IE+SD16BUF_3 ; // Single conv, enable interrupt, high impedance SD16INCTL0 |= SD16INTDLY_0; // Interrupt on 4th sample unsigned int i; for (i = 0; i < 10000; i++); // Delay for 32 kHz crystal __enable_interrupt(); // Enable general interrupts SD16CTL = SD16REFON; // 1.2V ref DAC12_0CTL = DAC12OPS + DAC12SREF_2 + DAC12IR + DAC12AMP_5 + DAC12ENC; // DAC o/p external, Ref Voltage = internal (SD16), // O/p Voltage range = 1x ref, Enable conversion while(1){ DAC12_0DAT = result >> 1; // Send A/D result to D/A SD16CCTL0 |= SD16SC; // Set bit to start A/D conversion __bis_SR_register(LPM0_bits); // Enter LPM0 } } #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__) #pragma vector=SD16_VECTOR __interrupt void SD16ISR(void) #elif defined(__GNUC__) void __attribute__ ((interrupt(SD16_VECTOR))) SD16ISR (void) #else #error Compiler not supported! #endif { switch (SD16IV) { case 2: // SD16MEM Overflow break; case 4: // SD16MEM0 IFG result = SD16MEM0; // Save CH0 results (clears IFG) break; } __bic_SR_register_on_exit(LPM0_bits); // Exit LPM0 }
thank you,
Scott