This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

about mic



hi sir,

i have a problem with the program.i just want to generate an interrupt using microphone.but that isnt working..please help.

here is my code:

#include "msp430xG46x.h"
#include<C:\LCD_defs.h>
//------------------------------------------------------------------------------

#define SamplePrd 118 // Record&playback sample period
// SampleR = 1MHz / SamplePrd
//------------------------------------------------------------------------------

// LCD segment definitions
//------------------------------------------------------------------------------

#define SEG_A 0x01

#define SEG_B 0x02

#define SEG_C 0x04

#define SEG_D 0x08

#define SEG_E 0x40

#define SEG_F 0x10

#define SEG_G 0x20

#define SEG_H 0x80
unsigned int i;
void main(void)

{

volatile unsigned int i;


WDTCTL = WDTPW + WDTHOLD; // Stop WDT

FLL_CTL0 |= XCAP14PF; // Configure load caps
do
{
IFG1 &= ~OFIFG; // Clear OSCFault flag

// for (i = 0x47FF; i > 0; i--); // Time for flag to set

}

while (IFG1 & OFIFG); // OSCFault flag still set?

// Ports

P1OUT = 0; // All P1.x reset

P1IE |= 0x03; // P1.0, P1.1 Interrupt enabled

P1IES &= ~0x03; // P1.0, P1.1 hi/low edge

P1DIR = 0xFC; // P1.0/1 = input (switches)

P2OUT = 0; // All P2.x reset

P2DIR = 0xDF; // UCA0RXD = inp

P3OUT = 0x20; // All P3.x reset (3.5 = buzzer)

P3DIR = 0xF9; // I2C pins = inp

P4OUT = 0; // All P4.x reset

P4DIR = 0xFF; // All P4.x outputs

P5OUT = 0; // All P5.x reset

P5SEL = 0x1C; // P5.2/3/4 = LCD COM lines

P5DIR = 0xFF; // All P5.x outputs

P6OUT = 0; // All P6.x reset

P6SEL = 0xBF; // All but P6.6 analog funct.

P6DIR = 0xFF; // All P6.x outputs

P7OUT = 0; // All P7.x reset

P7DIR = 0xFF; // All P7.x outputs

P8OUT = 0; // All P8.x reset

P8DIR = 0xFF; // All P8.x outputs

/*P9OUT = 0; // All P9.x reset

P9DIR = 0xFF; // All P9.x outputs

P10OUT = 0; // All P10.x reset

P10DIR = 0xFF;*/ // All P10.x outputs

// LCD_A

/*for (i = 19; i > 0; i--)
{
LCDMEM[i] = 0;
} // Clear LCD*/

/* LCDACTL = LCDON + LCD4MUX + LCDFREQ_128; // 4mux LCD, ACLK/128

LCDAPCTL0 = 0x7E; */
LCDAPCTL0 = LCDS24 | LCDS20 | LCDS16 | LCDS12 | LCDS8 | LCDS4;

// LCDA configuration
LCDACTL = LCDFREQ_192 | LCD4MUX | LCDSON | LCDON; // (ACLK = 32768)/192, 4-mux LCD, LCD_A on, Segments on
LCDAVCTL0 = LCDCPEN; // Charge pump enable
LCDAVCTL1 = VLCD_3_44;

_BIS_SR( GIE);
while(1);
}
#pragma vector=PORT1_VECTOR
__interrupt void Port_1(void)

{
if ((P1IFG & 0x01)== 0x01) // Record button SW2 pressed?

{
P5OUT |= 0x02; // LED#4 on

P2OUT |= 0x08; // Mic supply on // Setup OA0 = Microphone pre-amplifier
// OA0+ = P6.2/OA0I1
// OA0- = P6.0/OA0I0
// OA0OUT = P6.1/OA0O, A1 (internal)


OA0CTL0 = OAP_1 + OAPM_3; // Select inputs, power mode

OA0CTL1 = OARRIP;
ADC12CTL0 = ADC12ON; // Turn on ADC12, S&H in sample
P1IFG &= ~0x01; // ADC12 Clock=ADC12OSC

ADC12CTL1 = SHS_3 + CONSEQ_2; // S&H src select: Timer_B.OUT1,
// rep. single channel

ADC12IFG = 0x00;
ADC12IE |= 0x03; // Clear ADC12 interrupt flag reg

ADC12MCTL0 = 0x0001; // Input channel A1

ADC12CTL0 |= ENC;
TBCTL = TBSSEL_2; // Use SMCLK as Timer_B source

TAR = 0;

CCR0 = SamplePrd;
// Initialize TBCCR0
CCTL0 = CCIE;
CCR1 = SamplePrd - 20;
// Trigger for ADC12 SC

TBCCTL1 = OUTMOD_7;
LCDM8 = SEG_A + SEG_B + SEG_C + SEG_E + SEG_F + SEG_G; // "R"

LCDM7 = SEG_A + SEG_D + SEG_E + SEG_F + SEG_G; // "E"

LCDM6 = SEG_A + SEG_D + SEG_E + SEG_F; // "C"

LCDM5 = 0x00; // " "

LCDM4 = 0x00; // " "

// Start recording

P1IFG &= ~0xff;
P1OUT |= 0x01; // LED#4 on
TACTL = TASSEL_2 + MC_1; // Start Timer_B in UP mode
}
else
{
while(1);
}

}
#pragma vector=TIMERA0_VECTOR
__interrupt void Timer_A(void)
{
ADC12CTL0 |= ADC12SC;
}
#pragma vector = ADC12_VECTOR
__interrupt void ADC12_ISR(void)


{
P1OUT |=0x02;
for(i=1000;i>0;i++);
P1OUT &= ~0x02;
ADC12IFG &= ~0x03;
}

**Attention** This is a public forum