Hello can anyone help...?? I m working on MSP430FG4618 experiments board... trying to record an audio data on an external flash memory
I m using the USART module.. in 3 pin master mode...Memstart and Memend are just memory defined variables...I was wondering if
i have configured the USART properly.... I have connected UCLK, SIMO ,SOMI pins to the external flash memory. The external flash
I m using is A25L010 (AMIC flash memory).....This code seems not to be recording any data...Any obvious errors in this code???
Please help?
void TimespeakRecord(void)
{
// Power-up external hardware
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; // General purp., rail-to-rail inp.
// Setup ADC12 module
ADC12CTL0 = ADC12ON; // Turn on ADC12, S&H in sample
// ADC12 Clock=ADC12OSC
ADC12CTL1 = SHS_3 + CONSEQ_2; // S&H src select: Timer_B.OUT1,
// rep. single channel
ADC12IFG = 0x00; // Clear ADC12 interrupt flag reg
ADC12MCTL0 = 0x0001; // Input channel A1
ADC12CTL0 |= ENC; // Enable conversion
// Steps executed for automated ADC12-to-Flash transfer
// everything without CPU intervention
//
// (1) Timer_B.OUT1 triggers ADC12 conversion
// (2) ADC12IFGx triggers DMA transfer
// (3) Goto (1) until DMA0SZ = 0
// Setup Timer_B for recording
TBCTL = TBSSEL_2; // Use SMCLK as Timer_B source
TBR = 0;
TBCCR0 = SamplePrd; // Initialize TBCCR0
TBCCR1 = SamplePrd - 20; // Trigger for ADC12 SC
TBCCTL1 = OUTMOD_7; // Reset OUT1 on EQU1, set on EQU0
//USART Configuration
ME2 |= USPIE1; // Enable USART1 SPI
U1TCTL |= CKPH+SSEL1+SSEL0+STC+CKPL; // SMCLK, 3-pin mode; OUT=falling edge ,IN= rising edge;
U1CTL |= CHAR+SYNC+MM; // 8-bit SPI master
U1BR0 = 0x02; // SMCLK/2 for baud rate //1048KHz/2
U1BR1 = 0; // SMCLK/2 for baud rate
U1MCTL = 0; // Clear modulation
U1CTL &= ~SWRST; // Initialise USART state machine
// Setup the DMA controller
// DMA0 fills up block of External flash memory
// Configure DMA triggers first
DMACTL0 =DMA0TSEL_6 +DMA0TSEL_4 ; // ADC12IFGx triggers DMA0; URXIFG0 DMA0
P4OUT &= ~0x40; // Enable external flash (chip select of external flash connected here)
U1TXBUF = 0x00; // Dummy write to start SPI
// Setup DMA0 for recording to first memory block
//DMA0SA = (unsigned int)&ADC12MEM0;
DMA0SA = (void(*)()) & ADC12MEM0;// Src address = ADC12 module
DMA0DA = (void(*)())&U1TXBUF; // Dst address = Flash memory
DMA0SZ = (Memend - Memstart) >> 1; // Size in words
DMA0CTL = DMADSTINCR1 + DMADSTINCR0 + DMAEN;
// Single transfer,
// increment dest. address,(CR1 bit 1 and CR0 bit 0)
// leave source address unchanged,
// src and dst are words size,
// edge sensitive DMA trigger,
// enable DMA
// Setup and erase Flash memory
// Update LCD
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
TBCTL |= MC0; // Start Timer_B in UP mode
// (counts up to TBCL0)
// Activate LPM during DMA recording, wake-up when finished
__bis_SR_register(LPM0_bits + GIE); // Enable interrupts, enter LPM0
// Power-down MSP430 modules
ADC12CTL1 &= ~CONSEQ_2; // Stop conversion immediately
ADC12CTL0 &= ~ENC; // disable ADC12 conversion
ADC12CTL0 = 0; // Switch off ADC12 & ref voltage
TBCTL = 0; // Disable Timer_B
OA0CTL0 = 0; // Disable OA0
P2OUT &= ~0x08; // Mic supply off
P5OUT &= ~0x02; // LED#4 off
// Update LCD
LCDM8 = 0x00; // " "
LCDM7 = 0x00; // " "
LCDM6 = 0x00; // " "
}