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.

MSP430-EXP430F5438

Other Parts Discussed in Thread: MSP430G2553

A

  • >but I have some problem
    What problem do you have?

    >I am open to suggestions ! =D
    I suggest you to buy scope instead :)

    [edit] You forgot to specify bandwidth of your scope.

  • Problem is I cannot find the part of the code where the frequency is showed so i can change it to time domain
  • ADC reads time domain information so you don't need to find code where the frequency is showed but you want to find where it (time domain samples) comes out of ADC. You shall search google first and find similar "self made oscilloscope" projects, look how they are built and how they actually work.

  • Hi,

    Have you got even part of the solution for your project?

    I got something similar to solve, in the msp430 user folder there is a an audio function which can record your voice or sound and transform it from time domain to frequency domain using FFT (fast fourier transform) function. I think to make it display only time domain I will just need to disable the FFT function?

    Also for your additional functions, do you have the code or even a flow chart o how you solved it?

    • Digital filtering functionality.
    • Automatic scaling.
    • Varying sampling rates.
    • Signal FFT functionality
    • Store/recall scope functionality.

    Thanks for any answer!

  • Also forgot to ask, after going from frequency domain to display time domain in LCD, I need to:

    Stage 2 – ADC capture

    Rewrite the above code to sample on an input pin instead of from the Microphone.
    This will require that you take into account the reference voltage for the system, and ensure that the input signal is in the correct range using a DC offset.

    Have you done this or even have partial codes and flow chart?
  • Hi Manlee,
    I have no idea what the answers to your questions are.
  • Hi,

    Basically, the 1st question is to use the MSP430 as an Oscilloscope, showing time domain sine wave depending on the voice. So I need to write at the bottom of the following program plot voice[i] as y axis, i as x axis. Part of the code is pasted below, can you write a function at the bottom of the code that will plot voice[1] on the y axis and i on the x axis?

    /**********************************************************************//**
     * @file FFT.c
     *
     * Copyright 2010 Texas Instruments, Inc.
    ***************************************************************************/
    #include "msp430.h"
    #include "MSP-EXP430F5438_HAL\hal_MSP-EXP430F5438.h"
    #include "UserExperience_F5438A.h"
    #include "FFT.h"
    #include "FFT_430.h"

    int FBuff[512],outer;
    unsigned short index1;

    unsigned int voice_data[1024];
    unsigned int index;
    const int bit_rev_index[]={0x00,0x80,0x40,0xC0,0x20,0xA0,0x60,0xE0,0x10,0x90,0x50,
                               0xD0,0x30,0xB0,0x70,0xF0,0x08,0x88,0x48,0xC8,0x28,0xA8,
                               0x68,0xE8,0x18,0x98,0x58,0xD8,0x38,0xB8,0x78,0xF8,0x04,
                               0x84,0x44,0xC4,0x24,0xA4,0x64,0xE4,0x14,0x94,0x54,0xD4,
                               0x34,0xB4,0x74,0xF4,0x0C,0x8C,0x4C,0xCC,0x2C,0xAC,0x6C,
                               0xEC,0x1C,0x9C,0x5C,0xDC,0x3C,0xBC,0x7C,0xFC,0x02,0x82,
                               0x42,0xC2,0x22,0xA2,0x62,0xE2,0x12,0x92,0x52,0xD2,0x32,
                               0xB2,0x72,0xF2,0x0A,0x8A,0x4A,0xCA,0x2A,0xAA,0x6A,0xEA,
                               0x1A,0x9A,0x5A,0xDA,0x3A,0xBA,0x7A,0xFA,0x06,0x86,0x46,
                               0xC6,0x26,0xA6,0x66,0xE6,0x16,0x96,0x56,0xD6,0x36,0xB6,
                               0x76,0xF6,0x0E,0x8E,0x4E,0xCE,0x2E,0xAE,0x6E,0xEE,0x1E,
                               0x9E,0x5E,0xDE,0x3E,0xBE,0x7E,0xFE,0x01,0x81,0x41,0xC1,
                               0x21,0xA1,0x61,0xE1,0x11,0x91,0x51,0xD1,0x31,0xB1,0x71,
                               0xF1,0x09,0x89,0x49,0xC9,0x29,0xA9,0x69,0xE9,0x19,0x99,
                               0x59,0xD9,0x39,0xB9,0x79,0xF9,0x05,0x85,0x45,0xC5,0x25,
                               0xA5,0x65,0xE5,0x15,0x95,0x55,0xD5,0x35,0xB5,0x75,0xF5,
                               0x0D,0x8D,0x4D,0xCD,0x2D,0xAD,0x6D,0xED,0x1D,0x9D,0x5D,
                               0xDD,0x3D,0xBD,0x7D,0xFD,0x03,0x83,0x43,0xC3,0x23,0xA3,
                               0x63,0xE3,0x13,0x93,0x53,0xD3,0x33,0xB3,0x73,0xF3,0x0B,
                               0x8B,0x4B,0xCB,0x2B,0xAB,0x6B,0xEB,0x1B,0x9B,0x5B,0xDB,
                               0x3B,0xBB,0x7B,0xFB,0x07,0x87,0x47,0xC7,0x27,0xA7,0x67,
                               0xE7,0x17,0x97,0x57,0xD7,0x37,0xB7,0x77,0xF7,0x0F,0x8F,
                               0x4F,0xCF,0x2F,0xAF,0x6F,0xEF,0x1F,0x9F,0x5F,0xDF,0x3F,
                               0xBF,0x7F,0xFF};


    int imag, real,real_abs,imag_abs,mag,max,min;
    int FFT_data[512];

    unsigned int FFT_Image[1344];

    /**********************************************************************//**
     * @brief  Sets up board for recording from microphone
     *
     * @param  none
     *
     * @return none
     *************************************************************************/
    void shutdownRecorder(void)
    {
      halLcdSetBackLight(lcdBackLightLevelSettingLOCAL);
     
      // Power-down MSP430 modules
      TBCTL = 0;                                // Disable Timer_B
      ADC12CTL1 &= ~ADC12CONSEQ_2;              // Stop conversion immediately
      ADC12CTL0 &= ~ADC12ENC;                   // Disable ADC12 conversion
      ADC12CTL0 = 0x00;                         // Switch off ADC12
      ADC12IE = 0x00;

      AUDIO_PORT_OUT &= ~MIC_POWER_PIN;         // Turn of MIC   
      AUDIO_PORT_SEL &= ~MIC_INPUT_PIN;   
    }

    void setupRecorder()
    {
      AUDIO_PORT_OUT |= MIC_POWER_PIN;
      AUDIO_PORT_OUT &= ~MIC_INPUT_PIN;
      AUDIO_PORT_SEL |= MIC_INPUT_PIN;
     
      UCSCTL8 |= MODOSCREQEN;
      ADC12CTL0 &= ~ADC12ENC;                   // Disable conversions to configure ADC12
      ADC12CTL0 = ADC12ON + ADC12SHT02;         // Configure ADC12 to sample a sequence of channels, once
      ADC12CTL1 = ADC12SHP + ADC12CONSEQ_2 + ADC12SSEL_2 + ADC12SHS_3;     
      ADC12CTL2 = ADC12RES_0;                   // Select 8-bit resolution
      ADC12MCTL0 = MIC_INPUT_CHAN | ADC12EOS;
      ADC12CTL0 |= ADC12ENC;                    // Enable
      ADC12IE = BIT0;

      // Initialize Timer_B to be used as ADC12 trigger
      TBCTL = TBSSEL_2 + TBCLR;          // Use SMCLK as Timer_B source
      TBCCR0 = 2047;                     // Initialize TBCCR0 (period register)
      TBCCR1= 2047 - 100;                 // Initialize TBCCR1 (ADC12 trigger)
      TBCCTL0 = 0x0000;
      TBCCTL1 = OUTMOD_7;   
      TBCCTL2 = 0x0000;
      TBCCTL3 = 0x0000;
      TBCCTL4 = 0x0000;
      TBCCTL5 = 0x0000;
      TBCCTL6 = 0x0000;
    }

    /**********************************************************************//**
     * @brief  Runs the FFT app. Performs the FFT and displays it to the screen.
     *
     * @param  none
     *
     * @return none
     *************************************************************************/
    void FFTrecorder(void)
    {    
      unsigned int i, j;
      unsigned int mask = 0x0000;
     
      fftISR = 1;
     
      // Initialize FFT variables   
      buf_index = 0;
      for(i=0; i<1344; i++) {
          FFT_Image[i] = 0x0000;
      }

      halLcdClearScreen();
      halLcdPrintLine("    FFT DEMO   ", 0, 0 );
      halLcdPrintLine("0", 8, 0 );
      halLcdPrintLineCol("Fs 2", 8, 13, 0 );            
      halLcdLine(120, 107, 126, 97, PIXEL_ON);
      halLcdHLine(0, 138, 96, PIXEL_ON);

      halButtonsInit( BUTTON_ALL );
      halButtonsInterruptEnable( BUTTON_ALL );
      buttonsPressed = 0;
     
      setupRecorder();
     
      while(!buttonsPressed)
      {
        TBCCTL1 &= ~CCIFG;    
          TBCTL |= MC0;     //start timer B
        __bis_SR_register(LPM0_bits + GIE);  
        __no_operation();
        TBCTL &= ~MC0;
     
        if (buf_index == 512)    
          for (i=0;i<512;i++)
            voice_data[i] = buffer[i];                
        else
          for (i=0;i<512;i++)
            voice_data[i] = buffer[i + 512];
        
    // FILL IN CODE HERE THAT PLOTS voice[i] on y axis, and [i] on x axis.

    // USE   halLcdLine(120, 107, 126, 97, PIXEL_ON); FROM ABOVE TO DRAW THE GRAPH.


      shutdownRecorder();  
    }

  • I meant voice_data[i] on y axis and i on x axis.
  • turns out that deleting the FFT_prog makes the code broken but I want to show the time domain, not frequency domain so I deleted the FFT_prog codes, here is the original code with FFT_prog:

    /**********************************************************************//**
    * @file FFT.c
    *
    * Copyright 2010 Texas Instruments, Inc.
    ***************************************************************************/
    #include "msp430.h"
    #include "MSP-EXP430F5438_HAL\hal_MSP-EXP430F5438.h"
    #include "UserExperience_F5438A.h"
    #include "FFT.h"
    #include "FFT_430.h"

    int FBuff[512],outer;
    unsigned short index1;

    unsigned int voice_data[1024];
    unsigned int index;
    const int bit_rev_index[]={0x00,0x80,0x40,0xC0,0x20,0xA0,0x60,0xE0,0x10,0x90,0x50,
    0xD0,0x30,0xB0,0x70,0xF0,0x08,0x88,0x48,0xC8,0x28,0xA8,
    0x68,0xE8,0x18,0x98,0x58,0xD8,0x38,0xB8,0x78,0xF8,0x04,
    0x84,0x44,0xC4,0x24,0xA4,0x64,0xE4,0x14,0x94,0x54,0xD4,
    0x34,0xB4,0x74,0xF4,0x0C,0x8C,0x4C,0xCC,0x2C,0xAC,0x6C,
    0xEC,0x1C,0x9C,0x5C,0xDC,0x3C,0xBC,0x7C,0xFC,0x02,0x82,
    0x42,0xC2,0x22,0xA2,0x62,0xE2,0x12,0x92,0x52,0xD2,0x32,
    0xB2,0x72,0xF2,0x0A,0x8A,0x4A,0xCA,0x2A,0xAA,0x6A,0xEA,
    0x1A,0x9A,0x5A,0xDA,0x3A,0xBA,0x7A,0xFA,0x06,0x86,0x46,
    0xC6,0x26,0xA6,0x66,0xE6,0x16,0x96,0x56,0xD6,0x36,0xB6,
    0x76,0xF6,0x0E,0x8E,0x4E,0xCE,0x2E,0xAE,0x6E,0xEE,0x1E,
    0x9E,0x5E,0xDE,0x3E,0xBE,0x7E,0xFE,0x01,0x81,0x41,0xC1,
    0x21,0xA1,0x61,0xE1,0x11,0x91,0x51,0xD1,0x31,0xB1,0x71,
    0xF1,0x09,0x89,0x49,0xC9,0x29,0xA9,0x69,0xE9,0x19,0x99,
    0x59,0xD9,0x39,0xB9,0x79,0xF9,0x05,0x85,0x45,0xC5,0x25,
    0xA5,0x65,0xE5,0x15,0x95,0x55,0xD5,0x35,0xB5,0x75,0xF5,
    0x0D,0x8D,0x4D,0xCD,0x2D,0xAD,0x6D,0xED,0x1D,0x9D,0x5D,
    0xDD,0x3D,0xBD,0x7D,0xFD,0x03,0x83,0x43,0xC3,0x23,0xA3,
    0x63,0xE3,0x13,0x93,0x53,0xD3,0x33,0xB3,0x73,0xF3,0x0B,
    0x8B,0x4B,0xCB,0x2B,0xAB,0x6B,0xEB,0x1B,0x9B,0x5B,0xDB,
    0x3B,0xBB,0x7B,0xFB,0x07,0x87,0x47,0xC7,0x27,0xA7,0x67,
    0xE7,0x17,0x97,0x57,0xD7,0x37,0xB7,0x77,0xF7,0x0F,0x8F,
    0x4F,0xCF,0x2F,0xAF,0x6F,0xEF,0x1F,0x9F,0x5F,0xDF,0x3F,
    0xBF,0x7F,0xFF};


    int imag, real,real_abs,imag_abs,mag,max,min;
    int FFT_data[512];

    unsigned int FFT_Image[1344];

    /**********************************************************************//**
    * @brief Sets up board for recording from microphone
    *
    * @param none
    *
    * @return none
    *************************************************************************/
    void shutdownRecorder(void)
    {
    halLcdSetBackLight(lcdBackLightLevelSettingLOCAL);

    // Power-down MSP430 modules
    TBCTL = 0; // Disable Timer_B
    ADC12CTL1 &= ~ADC12CONSEQ_2; // Stop conversion immediately
    ADC12CTL0 &= ~ADC12ENC; // Disable ADC12 conversion
    ADC12CTL0 = 0x00; // Switch off ADC12
    ADC12IE = 0x00;

    AUDIO_PORT_OUT &= ~MIC_POWER_PIN; // Turn of MIC
    AUDIO_PORT_SEL &= ~MIC_INPUT_PIN;
    }

    void setupRecorder()
    {
    AUDIO_PORT_OUT |= MIC_POWER_PIN;
    AUDIO_PORT_OUT &= ~MIC_INPUT_PIN;
    AUDIO_PORT_SEL |= MIC_INPUT_PIN;

    UCSCTL8 |= MODOSCREQEN;
    ADC12CTL0 &= ~ADC12ENC; // Disable conversions to configure ADC12
    ADC12CTL0 = ADC12ON + ADC12SHT02; // Configure ADC12 to sample a sequence of channels, once
    ADC12CTL1 = ADC12SHP + ADC12CONSEQ_2 + ADC12SSEL_2 + ADC12SHS_3;
    ADC12CTL2 = ADC12RES_0; // Select 8-bit resolution
    ADC12MCTL0 = MIC_INPUT_CHAN | ADC12EOS;
    ADC12CTL0 |= ADC12ENC; // Enable
    ADC12IE = BIT0;

    // Initialize Timer_B to be used as ADC12 trigger
    TBCTL = TBSSEL_2 + TBCLR; // Use SMCLK as Timer_B source
    TBCCR0 = 2047; // Initialize TBCCR0 (period register)
    TBCCR1= 2047 - 100; // Initialize TBCCR1 (ADC12 trigger)
    TBCCTL0 = 0x0000;
    TBCCTL1 = OUTMOD_7;
    TBCCTL2 = 0x0000;
    TBCCTL3 = 0x0000;
    TBCCTL4 = 0x0000;
    TBCCTL5 = 0x0000;
    TBCCTL6 = 0x0000;
    }

    /**********************************************************************//**
    * @brief Runs the FFT app. Performs the FFT and displays it to the screen.
    *
    * @param none
    *
    * @return none
    *************************************************************************/
    void FFTrecorder(void)
    {
    unsigned int i, j;
    unsigned int mask = 0x0000;

    fftISR = 1;

    // Initialize FFT variables
    buf_index = 0;
    for(i=0; i<1344; i++) {
    FFT_Image[i] = 0x0000;
    }

    halLcdClearScreen();
    halLcdPrintLine(" FFT DEMO ", 0, 0 );
    halLcdPrintLine("0", 8, 0 );
    halLcdPrintLineCol("Fs 2", 8, 13, 0 );
    halLcdLine(120, 107, 126, 97, PIXEL_ON);
    halLcdHLine(0, 138, 96, PIXEL_ON);

    halButtonsInit( BUTTON_ALL );
    halButtonsInterruptEnable( BUTTON_ALL );
    buttonsPressed = 0;

    setupRecorder();

    while(!buttonsPressed)
    {
    TBCCTL1 &= ~CCIFG;
    TBCTL |= MC0; //start timer B
    __bis_SR_register(LPM0_bits + GIE);
    __no_operation();
    TBCTL &= ~MC0;

    if (buf_index == 512)
    for (i=0;i<512;i++)
    voice_data[i] = buffer[i];
    else
    for (i=0;i<512;i++)
    voice_data[i] = buffer[i + 512];

    FFT_prog(); // Perform FFT and store

    for (i=0;i<256;i++)
    {
    index=bit_rev_index[i];
    real=FBuff[2*index];
    imag=FBuff[2*index+1];
    if(real < 0)
    real_abs=~real+1;
    else
    real_abs=real;
    if(imag < 0)
    imag_abs=~imag+1;
    else
    imag_abs=imag;
    if(real_abs >= imag_abs)
    {
    max=real_abs;
    min=imag_abs;
    }
    else
    {
    max=imag_abs;
    min=real_abs;
    }
    mag=max+3*(min>>3);
    FFT_data[i]=mag;
    }

    //prepare the image of the FFT for display
    for (i=1;i<128;i++)
    {
    switch(i%8)
    {
    case 1: mask = 0x0003; break;
    case 2: mask = 0x000C; break;
    case 3: mask = 0x0030; break;
    case 4: mask = 0x00C0; break;
    case 5: mask = 0x0300; break;
    case 6: mask = 0x0C00; break;
    case 7: mask = 0x3000; break;
    case 0: mask = 0xC000; break;
    default: mask = 0x0000; break;
    }
    for (j=0; j<84; j++)
    {
    if (j<(84-FFT_data[i]*2))
    FFT_Image[((i-1)/8)+j*16] &= ~mask;
    else
    FFT_Image[((i-1)/8)+j*16] |= mask;
    }
    }
    halLcdImage(FFT_Image, 16, 84, 1, 12); //display the image
    }
    fftISR = 0;
    shutdownRecorder();
    }
  • okay, fill in the code below to draw a sine wave, voice_data[1] on y axis and i on x axis:

    /**********************************************************************//**
    * @file FFT.c
    *
    * Copyright 2010 Texas Instruments, Inc.
    ***************************************************************************/
    #include "msp430.h"
    #include "MSP-EXP430F5438_HAL\hal_MSP-EXP430F5438.h"
    #include "UserExperience_F5438A.h"
    #include "FFT.h"
    #include "FFT_430.h"

    int FBuff[512],outer;
    unsigned short index1;

    unsigned int voice_data[1024];
    unsigned int index;
    const int bit_rev_index[]={0x00,0x80,0x40,0xC0,0x20,0xA0,0x60,0xE0,0x10,0x90,0x50,
    0xD0,0x30,0xB0,0x70,0xF0,0x08,0x88,0x48,0xC8,0x28,0xA8,
    0x68,0xE8,0x18,0x98,0x58,0xD8,0x38,0xB8,0x78,0xF8,0x04,
    0x84,0x44,0xC4,0x24,0xA4,0x64,0xE4,0x14,0x94,0x54,0xD4,
    0x34,0xB4,0x74,0xF4,0x0C,0x8C,0x4C,0xCC,0x2C,0xAC,0x6C,
    0xEC,0x1C,0x9C,0x5C,0xDC,0x3C,0xBC,0x7C,0xFC,0x02,0x82,
    0x42,0xC2,0x22,0xA2,0x62,0xE2,0x12,0x92,0x52,0xD2,0x32,
    0xB2,0x72,0xF2,0x0A,0x8A,0x4A,0xCA,0x2A,0xAA,0x6A,0xEA,
    0x1A,0x9A,0x5A,0xDA,0x3A,0xBA,0x7A,0xFA,0x06,0x86,0x46,
    0xC6,0x26,0xA6,0x66,0xE6,0x16,0x96,0x56,0xD6,0x36,0xB6,
    0x76,0xF6,0x0E,0x8E,0x4E,0xCE,0x2E,0xAE,0x6E,0xEE,0x1E,
    0x9E,0x5E,0xDE,0x3E,0xBE,0x7E,0xFE,0x01,0x81,0x41,0xC1,
    0x21,0xA1,0x61,0xE1,0x11,0x91,0x51,0xD1,0x31,0xB1,0x71,
    0xF1,0x09,0x89,0x49,0xC9,0x29,0xA9,0x69,0xE9,0x19,0x99,
    0x59,0xD9,0x39,0xB9,0x79,0xF9,0x05,0x85,0x45,0xC5,0x25,
    0xA5,0x65,0xE5,0x15,0x95,0x55,0xD5,0x35,0xB5,0x75,0xF5,
    0x0D,0x8D,0x4D,0xCD,0x2D,0xAD,0x6D,0xED,0x1D,0x9D,0x5D,
    0xDD,0x3D,0xBD,0x7D,0xFD,0x03,0x83,0x43,0xC3,0x23,0xA3,
    0x63,0xE3,0x13,0x93,0x53,0xD3,0x33,0xB3,0x73,0xF3,0x0B,
    0x8B,0x4B,0xCB,0x2B,0xAB,0x6B,0xEB,0x1B,0x9B,0x5B,0xDB,
    0x3B,0xBB,0x7B,0xFB,0x07,0x87,0x47,0xC7,0x27,0xA7,0x67,
    0xE7,0x17,0x97,0x57,0xD7,0x37,0xB7,0x77,0xF7,0x0F,0x8F,
    0x4F,0xCF,0x2F,0xAF,0x6F,0xEF,0x1F,0x9F,0x5F,0xDF,0x3F,
    0xBF,0x7F,0xFF};


    int imag, real,real_abs,imag_abs,mag,max,min;
    int FFT_data[512];

    unsigned int FFT_Image[1344];

    /**********************************************************************//**
    * @brief Sets up board for recording from microphone
    *
    * @param none
    *
    * @return none
    *************************************************************************/
    void shutdownRecorder(void)
    {
    halLcdSetBackLight(lcdBackLightLevelSettingLOCAL);

    // Power-down MSP430 modules
    TBCTL = 0; // Disable Timer_B
    ADC12CTL1 &= ~ADC12CONSEQ_2; // Stop conversion immediately
    ADC12CTL0 &= ~ADC12ENC; // Disable ADC12 conversion
    ADC12CTL0 = 0x00; // Switch off ADC12
    ADC12IE = 0x00;

    AUDIO_PORT_OUT &= ~MIC_POWER_PIN; // Turn of MIC
    AUDIO_PORT_SEL &= ~MIC_INPUT_PIN;
    }

    void setupRecorder()
    {
    AUDIO_PORT_OUT |= MIC_POWER_PIN;
    AUDIO_PORT_OUT &= ~MIC_INPUT_PIN;
    AUDIO_PORT_SEL |= MIC_INPUT_PIN;

    UCSCTL8 |= MODOSCREQEN;
    ADC12CTL0 &= ~ADC12ENC; // Disable conversions to configure ADC12
    ADC12CTL0 = ADC12ON + ADC12SHT02; // Configure ADC12 to sample a sequence of channels, once
    ADC12CTL1 = ADC12SHP + ADC12CONSEQ_2 + ADC12SSEL_2 + ADC12SHS_3;
    ADC12CTL2 = ADC12RES_0; // Select 8-bit resolution
    ADC12MCTL0 = MIC_INPUT_CHAN | ADC12EOS;
    ADC12CTL0 |= ADC12ENC; // Enable
    ADC12IE = BIT0;

    // Initialize Timer_B to be used as ADC12 trigger
    TBCTL = TBSSEL_2 + TBCLR; // Use SMCLK as Timer_B source
    TBCCR0 = 2047; // Initialize TBCCR0 (period register)
    TBCCR1= 2047 - 100; // Initialize TBCCR1 (ADC12 trigger)
    TBCCTL0 = 0x0000;
    TBCCTL1 = OUTMOD_7;
    TBCCTL2 = 0x0000;
    TBCCTL3 = 0x0000;
    TBCCTL4 = 0x0000;
    TBCCTL5 = 0x0000;
    TBCCTL6 = 0x0000;
    }

    /**********************************************************************//**
    * @brief Runs the FFT app. Performs the FFT and displays it to the screen.
    *
    * @param none
    *
    * @return none
    *************************************************************************/
    void FFTrecorder(void)
    {
    unsigned int i;


    fftISR = 1;

    // Initialize FFT variables
    buf_index = 0;
    for(i=0; i<1344; i++) {
    FFT_Image[i] = 0x0000;
    }

    halLcdClearScreen();
    halLcdPrintLine(" FFT DEMO ", 0, 0 );
    halLcdPrintLine("0", 8, 0 );
    halLcdPrintLineCol("Fs 2", 8, 13, 0 );
    halLcdLine(120, 107, 126, 97, PIXEL_ON);
    halLcdHLine(0, 138, 96, PIXEL_ON);

    halButtonsInit( BUTTON_ALL );
    halButtonsInterruptEnable( BUTTON_ALL );
    buttonsPressed = 0;

    setupRecorder();

    while(!buttonsPressed)
    {
    TBCCTL1 &= ~CCIFG;
    TBCTL |= MC0; //start timer B
    __bis_SR_register(LPM0_bits + GIE);
    __no_operation();
    TBCTL &= ~MC0;

    if (buf_index == 512)
    for (i=0;i<512;i++)
    voice_data[i] = buffer[i];
    else
    for (i=0;i<512;i++)
    voice_data[i] = buffer[i + 512];

    // FILL IN CODE HERE THAT PLOTS voice_data[i] on y axis, and [i] on x axis.

    // USE halLcdLine(120, 107, 126, 97, PIXEL_ON); FROM ABOVE TO DRAW THE GRAPH.

    halLcdImage(FFT_Image, 16, 84, 1, 12); //display the image
    }
    fftISR = 0;
    shutdownRecorder();
    }
  • THIS IS THE LCD CODE TO DRAW ON LCD, I don't know what I should modify to draw a time domain sine wave with y axis voice_data[i] and x axis i:

    /**
    * @file hal_lcd.c
    *
    * Copyright 2010 Texas Instruments, Inc.
    ***************************************************************************/

    #include "msp430.h"
    #include "MSP-EXP430F5438_HAL\hal_MSP-EXP430F5438.h"
    #include "hal_lcd_fonts.h"

    unsigned char LcdInitMacro[]={
    0x74,0x00,0x00,0x76,0x00,0x01, // R00 start oscillation
    0x74,0x00,0x01,0x76,0x00,0x0D, // R01 driver output control
    0x74,0x00,0x02,0x76,0x00,0x4C, // R02 LCD - driving waveform control
    0x74,0x00,0x03,0x76,0x12,0x14, // R03 Power control
    0x74,0x00,0x04,0x76,0x04,0x66, // R04 Contrast control
    0x74,0x00,0x05,0x76,0x00,0x10, // R05 Entry mode
    0x74,0x00,0x06,0x76,0x00,0x00, // R06 RAM data write mask
    0x74,0x00,0x07,0x76,0x00,0x15, // R07 Display control
    0x74,0x00,0x08,0x76,0x00,0x03, // R08 Cursor Control
    0x74,0x00,0x09,0x76,0x00,0x00, // R09 RAM data write mask
    0x74,0x00,0x0A,0x76,0x00,0x15, // R0A
    0x74,0x00,0x0B,0x76,0x00,0x03, // R0B Horizontal Cursor Position
    0x74,0x00,0x0C,0x76,0x00,0x03, // R0C Vertical Cursor Position
    0x74,0x00,0x0D,0x76,0x00,0x00, // R0D
    0x74,0x00,0x0E,0x76,0x00,0x15, // R0E
    0x74,0x00,0x0F,0x76,0x00,0x03, // R0F
    0x74,0x00,0x10,0x76,0x00,0x15, // R0E
    0x74,0x00,0x11,0x76,0x00,0x03, // R0F
    };

    unsigned char Read_Block_Address_Macro[]= {0x74,0x00,0x12,0x77,0x00,0x00};
    unsigned char Draw_Block_Value_Macro[]={0x74,0x00,0x12,0x76,0xFF,0xFF};
    unsigned char Draw_Block_Address_Macro[]={0x74,0x00,0x11,0x76,0x00,0x00};

    unsigned int LcdAddress = 0, LcdTableAddress = 0;
    unsigned char contrast = 0x66;
    unsigned char backlight = 8;
    int LCD_MEM[110*17]; //This array stores a copy of all data on the LCD
    //screen. If memory is an issue though, this array
    //can be eliminated and the halLcdReadBlock()
    //command can be used instead whenever you are
    //manipulating the currently displayed data.

    /**********************************************************************//**
    * @brief Sends 3+3 bytes of data to the LCD using the format specified
    * by the LCD Guide.
    *
    * @param Data[] Data array for transmission
    *
    * @return none
    *************************************************************************/
    void halLcdSendCommand(unsigned char Data[])
    {
    unsigned char i;

    LCD_CS_RST_OUT &= ~LCD_CS_PIN; //CS = 0 --> Start Transfer
    for ( i = 0; i < 6; i++ )
    {
    while (!(UCB2IFG & UCTXIFG)); // Wait for TXIFG
    UCB2TXBUF = Data[i]; // Load data

    if (i == 2) //Pull CS up after 3 bytes
    {
    while (UCB2STAT & UCBUSY);
    LCD_CS_RST_OUT |= LCD_CS_PIN; //CS = 1 --> Stop Transfer
    LCD_CS_RST_OUT &= ~LCD_CS_PIN; //CS = 0 --> Start Transfer
    }
    }
    while (UCB2STAT & UCBUSY);
    LCD_CS_RST_OUT |= LCD_CS_PIN; //CS = 1 --> Stop Transfer
    }

    /**********************************************************************//**
    * @brief Initializes the USCI module, LCD device for communication.
    *
    * - Sets up the SPI2C Communication Module
    * - Performs Hitachi LCD Initialization Procedure
    *
    * @param none
    *
    * @return none
    *************************************************************************/
    void halLcdInit(void)
    {
    volatile unsigned int i=0;

    LCD_CS_RST_OUT |= LCD_CS_PIN | LCD_RESET_PIN ;
    LCD_CS_RST_DIR |= LCD_CS_PIN | LCD_RESET_PIN ;

    LCD_BACKLT_SEL |= LCD_BACKLIGHT_PIN;

    LCD_CS_RST_OUT &= ~LCD_RESET_PIN; // Reset LCD
    __delay_cycles(0x47FF); //Reset Pulse
    LCD_CS_RST_OUT |= LCD_RESET_PIN;

    // UCLK,MOSI setup, SOMI cleared
    LCD_SPI_SEL |= LCD_MOSI_PIN + LCD_CLK_PIN;
    LCD_SPI_SEL &= ~LCD_MISO_PIN;
    LCD_SPI_DIR &= ~(LCD_MISO_PIN + LCD_MOSI_PIN); // Pin direction controlled by module,
    // Set both pins to input as default

    // Initialize the USCI_B2 module for SPI operation
    UCB2CTL1 = UCSWRST; // Hold USCI in SW reset mode while configuring it
    UCB2CTL0 = UCMST+UCSYNC+UCCKPL+UCMSB; // 3-pin, 8-bit SPI master
    UCB2CTL1 |= UCSSEL_2; // SMCLK
    UCB2BR0 = 4; // Note: Do not exceed D/S spec for UCLK!
    UCB2BR1 = 0;
    UCB2CTL1 &= ~UCSWRST; // Release USCI state machine
    UCB2IFG &= ~UCRXIFG;

    // Wake-up the LCD as per datasheet specifications
    halLcdActive();

    // LCD Initialization Routine Using Predefined Macros
    halLcdSendCommand(&LcdInitMacro[ 1 * 6 ]);
    halLcdSendCommand(&LcdInitMacro[ 2 * 6 ]);
    halLcdSendCommand(&LcdInitMacro[ 4 * 6 ]);
    halLcdSendCommand(&LcdInitMacro[ 5 * 6 ]);
    halLcdSendCommand(&LcdInitMacro[ 6 * 6 ]);
    halLcdSendCommand(&LcdInitMacro[ 7 * 6 ]);

    }

    /**********************************************************************//**
    * @brief Shuts down the LCD display and hdisables the USCI communication.
    *
    * @param none
    *
    * @return none
    *************************************************************************/
    void halLcdShutDown(void)
    {
    halLcdStandby();

    LCD_CS_RST_DIR |= LCD_CS_PIN | LCD_RESET_PIN ;
    LCD_CS_RST_OUT &= ~(LCD_CS_PIN | LCD_RESET_PIN );
    LCD_CS_RST_OUT &= ~LCD_RESET_PIN;

    LCD_SPI_SEL &= ~(LCD_MOSI_PIN + LCD_CLK_PIN + LCD_MISO_PIN);
    LCD_CS_RST_DIR |= LCD_MOSI_PIN + LCD_CLK_PIN + LCD_MISO_PIN;
    LCD_CS_RST_OUT &= ~(LCD_MOSI_PIN + LCD_CLK_PIN + LCD_MISO_PIN);

    UCB2CTL0 = UCSWRST;
    }

    /**********************************************************************//**
    * @brief Initializes the LCD backlight PWM signal.
    *
    * @param none
    *
    * @return none
    *
    *************************************************************************/
    void halLcdBackLightInit(void)
    {
    LCD_BACKLT_DIR |= LCD_BACKLIGHT_PIN;
    LCD_BACKLT_OUT |= LCD_BACKLIGHT_PIN;
    LCD_BACKLT_SEL |= LCD_BACKLIGHT_PIN;

    TA0CCTL3 = OUTMOD_7;
    TA0CCR3 = TA0CCR0 >> 1 ;
    backlight = 8;

    TA0CCR0 = 400;
    TA0CTL = TASSEL_2+MC_1;
    }

    /**********************************************************************//**
    * @brief Get function for the backlight PWM's duty cycle.
    *
    * @param none
    *
    * @return backlight One of the the 17 possible settings - valued 0 to 16.
    *
    *************************************************************************/
    unsigned int halLcdGetBackLight(void)
    {
    return backlight;
    }

    /**********************************************************************//**
    * @brief Set function for the backlight PWM's duty cycle
    *
    * @param BackLightLevel The target backlight duty cycle - valued 0 to 16.
    *
    * @return none
    *************************************************************************/
    void halLcdSetBackLight(unsigned char BackLightLevel)
    {
    unsigned int dutyCycle = 0, i, dummy;

    if (BackLightLevel > 0)
    {
    TA0CCTL3 = OUTMOD_7;
    dummy = (TA0CCR0 >> 4);

    for (i = 0; i < BackLightLevel; i++)
    dutyCycle += dummy;

    TA0CCR3 = dutyCycle;

    // If the backlight was previously turned off, turn it on.
    if (!backlight)
    TA0CTL |= MC0;
    }
    else
    {
    TA0CCTL3 = 0;
    TA0CTL &= ~MC0;
    }
    backlight = BackLightLevel;
    }

    /**********************************************************************//**
    * @brief Turns off the backlight.
    *
    * Clears the respective GPIO and timer settings.
    *
    * @param none
    *
    * @return none
    *************************************************************************/
    void halLcdShutDownBackLight(void)
    {
    LCD_BACKLT_DIR |= LCD_BACKLIGHT_PIN;
    LCD_BACKLT_OUT &= ~(LCD_BACKLIGHT_PIN);
    LCD_BACKLT_SEL &= ~LCD_BACKLIGHT_PIN;

    TA0CCTL3 = 0;
    TA0CTL = 0;

    backlight = 0;
    }

    /**********************************************************************//**
    * @brief Set function for the contrast level of the LCD.
    *
    * @param ContrastLevel The target contrast level
    *
    * @return none
    *************************************************************************/
    void halLcdSetContrast(unsigned char ContrastLevel)
    {
    if (ContrastLevel > 127) ContrastLevel = 127;
    if (ContrastLevel < 70) ContrastLevel = 70;
    LcdInitMacro[ 0x04 * 6 + 5 ] = ContrastLevel;
    halLcdSendCommand(&LcdInitMacro[ 0x04 * 6 ]);
    }

    /**********************************************************************//**
    * @brief Get function for the contrast level of the LCD.
    *
    * @param none
    *
    * @return ContrastLevel The LCD constrast level
    *************************************************************************/
    unsigned char halLcdGetContrast(void)
    {
    return LcdInitMacro[ 0x04 * 6 + 5 ] ;
    }

    /**********************************************************************//**
    * @brief Turns the LCD cursor on at the current text position.
    *
    * @param none
    *
    * @return none
    *************************************************************************/
    void halLcdCursor(void)
    {
    LcdInitMacro[ 8 * 6 + 5 ] ^= BIT2;
    halLcdSendCommand(&LcdInitMacro[ 8 * 6 ]);

    LcdInitMacro[ 0x0B * 6 + 5 ] = ((LcdAddress & 0x1F) << 3) ;
    LcdInitMacro[ 0x0B * 6 + 4 ] = ( (LcdAddress & 0x1F) << 3 ) + 3;
    LcdInitMacro[ 0x0C * 6 + 5 ] = (LcdAddress >> 5);
    LcdInitMacro[ 0x0C * 6 + 4 ] = (LcdAddress >> 5) + 7;
    halLcdSendCommand(&LcdInitMacro[ 0x0B * 6 ]);
    halLcdSendCommand(&LcdInitMacro[ 0x0C * 6 ]);

    halLcdSetAddress(LcdAddress);
    }

    /**********************************************************************//**
    * @brief Turns off the LCD cursor.
    *
    * @param none
    *
    * @return none
    *************************************************************************/
    void halLcdCursorOff(void)
    {
    LcdInitMacro[ 8 * 6 + 5 ] &= ~BIT2;
    halLcdSendCommand(&LcdInitMacro[ 8 * 6 ]);
    }

    /**********************************************************************//**
    * @brief Inverts the grayscale values of the LCD display (Black <> white).
    *
    * @param none
    *
    * @return none
    *************************************************************************/
    void halLcdReverse(void)
    {
    LcdInitMacro[ 7 * 6 + 5 ] ^= BIT1;
    halLcdSendCommand(&LcdInitMacro[ 7 * 6 ]);
    }

    /**********************************************************************//**
    * @brief Sets the LCD in standby mode to reduce power consumption.
    *
    * @param none
    *
    * @return none
    *************************************************************************/
    void halLcdStandby(void)
    {
    LcdInitMacro[ 3 * 6 + 5 ] &= (~BIT3) & (~BIT2);
    LcdInitMacro[ 3 * 6 + 5 ] |= BIT0;
    halLcdSendCommand(&LcdInitMacro[ 3 * 6 ]);
    }

    /**********************************************************************//**
    * @brief Puts the LCD into active mode.
    *
    * @param none
    *
    * @return none
    *************************************************************************/
    void halLcdActive(void)
    {
    halLcdSendCommand(LcdInitMacro); // R00 start oscillation

    // Wait a minimum of 25ms after issuing "start oscillation"
    // command (to accomodate for MCLK up to 25MHz)
    __delay_cycles(250000);

    LcdInitMacro[ 3 * 6 + 5 ] |= BIT3;
    LcdInitMacro[ 3 * 6 + 5 ] &= ~BIT0;
    halLcdSendCommand(&LcdInitMacro[ 3 * 6 ]); // R03 Power control
    }

    /**********************************************************************//**
    * @brief Sets the pointer location in the LCD.
    *
    * - LcdAddress = Address
    * - LcdTableAddress = Correct Address Row + Column
    * = (Address / 0x20)* 17 + Column
    *
    * @param Address The target pointer location in the LCD.
    *
    * @return none
    *************************************************************************/
    void halLcdSetAddress(int Address)
    {
    int temp;

    Draw_Block_Address_Macro[4] = Address >> 8;
    Draw_Block_Address_Macro[5] = Address & 0xFF;
    halLcdSendCommand(Draw_Block_Address_Macro);
    LcdAddress = Address;
    temp = Address >> 5; // Divided by 0x20
    temp = temp + (temp << 4);
    //Multiplied by (1+16) and added by the offset
    LcdTableAddress = temp + (Address & 0x1F);
    }

    /**********************************************************************//**
    * @brief Draws a block at the specified LCD address.
    *
    * A block is the smallest addressable memory on the LCD and is
    * equivalent to 8 pixels, each of which is represented by 2 bits
    * that represent a grayscale value between 00b and 11b.
    *
    * @param Address The address at which to draw the block.
    *
    * @param Value The value of the block
    *
    * @return none
    *************************************************************************/
    void halLcdDrawBlock(unsigned int Address, unsigned int Value)
    {
    halLcdSetAddress(Address);
    halLcdDrawCurrentBlock(Value);
    }

    /**********************************************************************//**
    * @brief Writes Value to LCD CGram and MSP430 internal LCD table.
    *
    * Also updates the LcdAddress and LcdTableAddress to the correct values.
    *
    * @param Value The value of the block to be written to the LCD.
    *
    * @return none
    *************************************************************************/
    void halLcdDrawCurrentBlock(unsigned int Value)
    {
    int temp;

    Draw_Block_Value_Macro[4] = Value >> 8;
    Draw_Block_Value_Macro[5] = Value & 0xFF;
    LCD_MEM[ LcdTableAddress ] = Value;

    halLcdSendCommand(Draw_Block_Value_Macro);

    LcdAddress++;
    temp = LcdAddress >> 5; // Divided by 0x20
    temp = temp + (temp << 4);
    // Multiplied by (1+16) and added by the offset
    LcdTableAddress = temp + (LcdAddress & 0x1F);

    // If LcdAddress gets off the right edge, move to next line
    if ((LcdAddress & 0x1F) > 0x11)
    halLcdSetAddress( (LcdAddress & 0xFFE0) + 0x20 );
    if (LcdAddress == LCD_Size)
    halLcdSetAddress( 0 );
    }

    /**********************************************************************//**
    * @brief Returns the LCD CGRAM value at location Address.
    *
    * @param Address The address of the block to be read from the LCD.
    *
    * @return Value The value held at the specified address.
    *************************************************************************/
    int halLcdReadBlock(unsigned int Address)
    {
    int i = 0, Value = 0, ReadData[7];

    halLcdSetAddress( Address );
    halLcdSendCommand(Read_Block_Address_Macro);

    LCD_CS_RST_OUT &= ~LCD_CS_PIN; // start transfer CS=0
    UCB2TXBUF = 0x77; // Transmit first character 0x77

    while (!(UCB2IFG & UCTXIFG));
    while (UCB2STAT & UCBUSY);

    //Read 5 dummies values and 2 valid address data
    LCD_SPI_SEL &= ~LCD_MOSI_PIN; //Change SPI2C Dir
    LCD_SPI_SEL |= LCD_MISO_PIN;

    for (i = 0; i < 7; i ++ )
    {
    UCB2IFG &= ~UCRXIFG;
    UCB2TXBUF = 1; // load dummy byte 1 for clk
    while (!(UCB2IFG & UCRXIFG));
    ReadData[i] = UCB2RXBUF;
    }
    LCD_CS_RST_OUT |= LCD_CS_PIN; // Stop Transfer CS = 1

    LCD_SPI_SEL |= LCD_MOSI_PIN; //Change SPI2C Dir
    LCD_SPI_SEL &= ~LCD_MISO_PIN;
    LCD_CS_RST_DIR |= LCD_MOSI_PIN + LCD_CLK_PIN;
    LCD_CS_RST_DIR &= ~LCD_MISO_PIN;

    Value = (ReadData[5] << 8) + ReadData[6];
    return Value;
    }

    /**********************************************************************//**
    * @brief Draw a Pixel of grayscale at coordinate (x,y) to LCD
    *
    * @param x x-coordinate for grayscale value
    *
    * @param y y-coordinate for grayscale value
    *
    * @param GrayScale The intended grayscale value of the pixel - one of
    * four possible settings.
    *
    * @return none
    *************************************************************************/
    void halLcdPixel( int x, int y, unsigned char GrayScale)
    {
    int Address, Value;
    unsigned char offset;

    //Each line increments by 0x20
    if ( (x>=0 ) && (x<LCD_COL) && (y>=0) && (y<LCD_ROW))
    {
    Address = (y << 5) + (x >> 3) ; //Narrow down to 8 possible pixels

    Value = LCD_MEM[(y << 4)+ y + (x>>3)]; //y * 17 --> row. x>>3 --> column

    offset = (x & 0x07) << 1; //3 LSBs = pos. within the 8 columns
    Value &= ~ (3 << offset); //clear out the corresponding bits
    Value |= GrayScale << offset; //set pixel to GrayScale level

    halLcdDrawBlock( Address, Value );
    }
    }

    /**********************************************************************//**
    * @brief Clears entire LCD CGRAM as well as LCD_MEM.
    *
    * @param none
    *
    * @return none
    *************************************************************************/
    void halLcdClearScreen(void)
    {
    int i, j, k, Current_Location = 0;
    halLcdSetAddress(0);

    for (i=0; i < 110; i++)
    {
    //prepare to send image
    LCD_CS_RST_OUT &= ~LCD_CS_PIN; //CS = 0 --> Start Transfer
    for ( k = 0; k < 3; k++ )
    {
    while (!(UCB2IFG & UCTXIFG)); // Wait for TXIFG
    UCB2TXBUF = Draw_Block_Value_Macro[k]; // Load data
    }
    while (UCB2STAT & UCBUSY);
    LCD_CS_RST_OUT |= LCD_CS_PIN; //CS = 1 --> Stop Transfer
    LCD_CS_RST_OUT &= ~LCD_CS_PIN; //CS = 0 --> Start Transfer
    while (!(UCB2IFG & UCTXIFG)); // Wait for TXIFG
    UCB2TXBUF = Draw_Block_Value_Macro[3]; // Load data

    //send blank line
    for (j=0; j < 17; j++)
    {
    LCD_MEM[ LcdTableAddress++ ] = 0x00;
    while (!(UCB2IFG & UCTXIFG)); // Wait for TXIFG
    UCB2TXBUF = 0x00; // Load data
    while (!(UCB2IFG & UCTXIFG)); // Wait for TXIFG
    UCB2TXBUF = 0x00; // Load data
    }
    //Clear the partially visible block at the edge of the screen
    while (!(UCB2IFG & UCTXIFG)); // Wait for TXIFG
    UCB2TXBUF = 0x00; // Load data
    while (!(UCB2IFG & UCTXIFG)); // Wait for TXIFG
    UCB2TXBUF = 0x00; // Load data
    while (UCB2STAT & UCBUSY);
    LCD_CS_RST_OUT |= LCD_CS_PIN; //CS = 1 --> Stop Transfer

    Current_Location += 0x20;
    halLcdSetAddress(Current_Location );
    }

    halLcdSetAddress(0);
    }

    /**********************************************************************//**
    * @brief Loads an image of size = rows * columns, starting at the
    * coordinate (x,y).
    *
    * @param Image[] The image to be loaded
    *
    * @param Rows The number of rows in the image. Size = Rows * Columns.
    *
    * @param Columns The number of columns in the image. Size = Rows * Columns.
    *
    * @param x x-coordinate of the image's starting location
    *
    * @param y y-coordinate of the image's starting location
    *
    * @return none
    *************************************************************************/
    void halLcdImage(const unsigned int Image[], int Columns, int Rows, int x, int y)
    {
    int i, CurrentLocation;

    CurrentLocation = (y << 5) + (x >> 3);
    halLcdSetAddress(CurrentLocation);
    for (i=0; i < Rows; i++)
    {
    halLcdDrawCurrentLine(Image, Columns);
    Image += Columns;
    CurrentLocation += 0x20;
    halLcdSetAddress(CurrentLocation);
    }
    }

    /**********************************************************************//**
    * @brief Writes Value to LCD CGram and MSP430 internal LCD table.
    *
    * Also updates the LcdAddress and LcdTableAddress to the correct values.
    *
    * @param *value Pointer to the line to be written to the LCD.
    *
    * @return none
    *************************************************************************/
    void halLcdDrawCurrentLine(const unsigned int *value, int Columns)
    {
    unsigned char i;

    //prepare to send image
    LCD_CS_RST_OUT &= ~LCD_CS_PIN; //CS = 0 --> Start Transfer
    for ( i = 0; i < 3; i++ )
    {
    while (!(UCB2IFG & UCTXIFG)); // Wait for TXIFG
    UCB2TXBUF = Draw_Block_Value_Macro[i]; // Load data
    }
    while (UCB2STAT & UCBUSY);
    LCD_CS_RST_OUT |= LCD_CS_PIN; //CS = 1 --> Stop Transfer
    LCD_CS_RST_OUT &= ~LCD_CS_PIN; //CS = 0 --> Start Transfer
    while (!(UCB2IFG & UCTXIFG)); // Wait for TXIFG
    UCB2TXBUF = Draw_Block_Value_Macro[3]; // Load data

    //send the image
    for ( i = 0; i < Columns; i++ )
    {
    // Make sure we are not writing outside LCD_MEM[]
    if (LcdTableAddress >= sizeof(LCD_MEM)) {
    break;
    }
    LCD_MEM[ LcdTableAddress++ ] = *value;
    while (!(UCB2IFG & UCTXIFG)); // Wait for TXIFG
    UCB2TXBUF = (*value) >> 8; // Load data
    while (!(UCB2IFG & UCTXIFG)); // Wait for TXIFG
    UCB2TXBUF = (*value++) & 0xFF; // Load data
    }

    while (UCB2STAT & UCBUSY);
    LCD_CS_RST_OUT |= LCD_CS_PIN; //CS = 1 --> Stop Transfer
    }

    /**********************************************************************//**
    * @brief Clears an image of size rows x columns starting at (x, y).
    *
    * @param Columns The size, in columns, of the image to be cleared.
    *
    * @param Rows The size, in rows, of the image to be cleared.
    *
    * @param x x-coordinate of the image to be cleared
    *
    * @param y y-coordinate of the image to be cleared
    *
    * @return none
    *************************************************************************/
    void halLcdClearImage(int Columns, int Rows, int x, int y)
    {
    int i,j,k, Current_Location;
    Current_Location = (y << 5) + (x >> 3);
    halLcdSetAddress( Current_Location );

    for (i=0; i < Rows; i++)
    {
    //prepare to send image
    LCD_CS_RST_OUT &= ~LCD_CS_PIN; //CS = 0 --> Start Transfer
    for ( k = 0; k < 3; k++ )
    {
    while (!(UCB2IFG & UCTXIFG)); // Wait for TXIFG
    UCB2TXBUF = Draw_Block_Value_Macro[k]; // Load data
    }
    while (UCB2STAT & UCBUSY);
    LCD_CS_RST_OUT |= LCD_CS_PIN; //CS = 1 --> Stop Transfer
    LCD_CS_RST_OUT &= ~LCD_CS_PIN; //CS = 0 --> Start Transfer
    while (!(UCB2IFG & UCTXIFG)); // Wait for TXIFG
    UCB2TXBUF = Draw_Block_Value_Macro[3]; // Load data

    //send blank line
    for (j=0; j < Columns; j++)
    {
    LCD_MEM[ LcdTableAddress++ ] = 0x00;
    while (!(UCB2IFG & UCTXIFG)); // Wait for TXIFG
    UCB2TXBUF = 0x00; // Load data
    while (!(UCB2IFG & UCTXIFG)); // Wait for TXIFG
    UCB2TXBUF = 0x00; // Load data
    }
    while (UCB2STAT & UCBUSY);
    LCD_CS_RST_OUT |= LCD_CS_PIN; //CS = 1 --> Stop Transfer

    Current_Location += 0x20;
    halLcdSetAddress(Current_Location );
    }
    }

    /**********************************************************************//**
    * @brief Writes Value to LCD CGRAM. Pointers internal to the LCD
    * are also updated.
    *
    * @param Value The value to be written to the current LCD pointer
    *
    * @return none
    *************************************************************************/
    void halLcdDrawTextBlock(unsigned int Value)
    {
    int temp;

    Draw_Block_Value_Macro[4] = Value >> 8;
    Draw_Block_Value_Macro[5] = Value & 0xFF;
    LCD_MEM[ LcdTableAddress ] = Value;

    halLcdSendCommand(Draw_Block_Value_Macro);

    LcdAddress++;
    temp = LcdAddress >> 5; // Divided by 0x20
    temp = temp + (temp << 4);
    //Multiplied by (1+16) and added by the offset
    LcdTableAddress = temp + (LcdAddress & 0x1F);

    // If LcdAddress gets off the right edge, move to next line
    if ((LcdAddress & 0x1F) > 0x10)
    halLcdSetAddress( (LcdAddress & 0xFFE0) + 0x20 );

    if (LcdAddress >= LCD_Size)
    halLcdSetAddress( 0 );
    }

    /**********************************************************************//**
    * @brief Displays the string to the LCD starting at current location.
    *
    * Writes all the data to LCD_MEM first, then updates all corresponding
    * LCD CGRAM locations at once, in a continuous fashion.
    *
    * @param String[] The string to be displayed on LCD.
    *
    * @param TextStyle Value that specifies whether the string is to be
    * inverted or overwritten.
    * - Invert = 0x01
    * - Overwrite = 0x04
    *
    * @return none
    *************************************************************************/
    void halLcdPrint( char String[], unsigned char TextStyle)
    {
    int i, j, Counter=0, BlockValue;
    int Address, LCD_MEM_Add, ActualAddress;
    int temp;
    char LookUpChar;

    ActualAddress = LcdAddress;
    Counter = LcdAddress & 0x1F;
    i=0;

    while (String[i]!=0) // Stop on null character
    {
    LookUpChar = fonts_lookup[String[i]];

    for (j=0;j < FONT_HEIGHT ;j++)
    {
    Address = ActualAddress + j*0x20;
    temp = Address >> 5;
    temp += (temp <<4);

    LCD_MEM_Add = temp + (Address & 0x1F);

    BlockValue = LCD_MEM[ LCD_MEM_Add ];

    if(TextStyle & GRAYSCALE_TEXT)
    {
    if (TextStyle & INVERT_TEXT)
    if (TextStyle & OVERWRITE_TEXT)
    BlockValue = 0xAAAA - GrayScale_fonts[LookUpChar*(FONT_HEIGHT+1) +j];
    else
    BlockValue |= 0xAAAA - GrayScale_fonts[LookUpChar*(FONT_HEIGHT+1) +j];
    else
    if (TextStyle & OVERWRITE_TEXT)
    BlockValue = GrayScale_fonts[LookUpChar*(FONT_HEIGHT+1) +j];
    else
    BlockValue |= GrayScale_fonts[LookUpChar*(FONT_HEIGHT+1) +j];
    }
    else
    {
    if (TextStyle & INVERT_TEXT)
    if (TextStyle & OVERWRITE_TEXT)
    BlockValue = 0xFFFF - fonts[LookUpChar*13+j];
    else
    BlockValue |= 0xFFFF - fonts[LookUpChar*13+j];

    else
    if (TextStyle & OVERWRITE_TEXT)
    BlockValue = fonts[LookUpChar*(FONT_HEIGHT+1) +j];
    else
    BlockValue |= fonts[LookUpChar*(FONT_HEIGHT+1) +j];
    }
    halLcdDrawBlock( Address, BlockValue);
    }

    Counter++;
    if (Counter == 17)
    {
    Counter = 0;
    ActualAddress += 0x20*FONT_HEIGHT - 16;
    if (ActualAddress > LCD_Last_Pixel-0x20*FONT_HEIGHT )
    ActualAddress = 0;
    }
    else
    ActualAddress++;
    i++;
    }
    halLcdSetAddress(ActualAddress);

    }

    /**********************************************************************//**
    * @brief Displays the string to the LCD starting at (x,y) location.
    *
    * Writes all the data to LCD_MEM first, then updates all corresponding
    * LCD CGRAM locations at once, in a continuous fashion.
    *
    * @param String[] String to be displayed on LCD
    *
    * @param x x-coordinate of the write location on the LCD
    *
    * @param y y-coordinate of the write location on the LCD
    *
    * @param TextStyle Value that specifies whether the string is to be
    * inverted or overwritten.
    * - Invert = 0x01
    * - Overwrite = 0x04
    *************************************************************************/
    void halLcdPrintXY( char String[], int x, int y, unsigned char TextStyle)
    {
    //Each line increments by 0x20
    halLcdSetAddress( (y << 5) + (x >> 3)) ; //Narrow down to 8 possible pixels
    halLcdPrint(String, TextStyle);
    }

    /**********************************************************************//**
    * @brief Displays a string on the LCD on the specified line.
    *
    * @param String[] The string to be displayed on LCD.
    *
    * @param Line The line on the LCD on which to print the string.
    *
    * @param TextStyle Value that specifies whether the string is to be
    * inverted or overwritten.
    * - Invert = 0x01
    * - Overwrite = 0x04
    *
    * @return none
    *************************************************************************/
    void halLcdPrintLine(char String[], unsigned char Line, unsigned char TextStyle)
    {
    int temp;
    temp = Line * FONT_HEIGHT ;
    halLcdSetAddress( temp << 5 ) ; // 0x20 = 2^5
    halLcdPrint(String, TextStyle);
    }

    /**********************************************************************//**
    * @brief Prints a string beginning on a given line and column.
    *
    * @param String[] The string to be displayed on LCD.
    *
    * @param Line The line on which to print the string of text
    *
    * @param Col The column on which to print the string of text
    *
    * @param TextStyle Value that specifies whether the string is to be
    * inverted or overwritten.
    * - Invert = 0x01
    * - Overwrite = 0x04
    *
    * @return none
    *************************************************************************/
    void halLcdPrintLineCol(char String[], unsigned char Line, unsigned char Col,
    unsigned char TextStyle)
    {
    int temp;

    temp = Line * FONT_HEIGHT;
    temp <<= 5;
    temp += Col;

    halLcdSetAddress( temp ) ; // 0x20 = 2^5
    halLcdPrint(String, TextStyle);
    }


    /**********************************************************************//**
    * @brief Draws a horizontral line from (x1,y) to (x2,y) of GrayScale level
    *
    * @param x1 x-coordinate of the first point
    *
    * @param x2 x-coordinate of the second point
    *
    * @param y y-coordinate of both points
    *
    * @param GrayScale Grayscale level of the horizontal line
    *
    * @return none
    *************************************************************************/
    void halLcdHLine( int x1, int x2, int y, unsigned char GrayScale)
    {
    int x_dir, x;
    if ( x1 < x2 )
    x_dir = 1;
    else
    x_dir = -1;
    x = x1;
    while (x != x2)
    {
    halLcdPixel( x,y, GrayScale);
    x += x_dir;
    }
    }

    /**********************************************************************//**
    * @brief Draws a vertical line from (x,y1) to (x,y2) of GrayScale level
    *
    * @param x x-coordinate of both points
    *
    * @param y1 y-coordinate of the first point
    *
    * @param y2 y-coordinate of the second point
    *
    * @param GrayScale GrayScale level of the vertical line
    *
    * @return none
    *************************************************************************/
    void halLcdVLine( int x, int y1, int y2, unsigned char GrayScale)
    {
    int y_dir, y;
    if ( y1 < y2 )
    y_dir = 1;
    else
    y_dir = -1;
    y = y1;
    while (y != y2)
    {
    halLcdPixel( x,y, GrayScale);
    y += y_dir;
    }
    }

    /**********************************************************************//**
    * @brief Draws a line from (x1,y1) to (x2,y2) of GrayScale level.
    *
    * Uses Bresenham's line algorithm.
    *
    * @param x1 x-coordinate of the first point
    *
    * @param y1 y-coordinate of the first point
    *
    * @param x2 x-coordinate of the second point
    *
    * @param y2 y-coordinate of the second point
    *
    * @param GrayScale Grayscale level of the line
    *
    * @return none
    *************************************************************************/
    void halLcdLine( int x1, int y1, int x2, int y2, unsigned char GrayScale)
    {
    int x, y, deltay, deltax, d;
    int x_dir, y_dir;

    if ( x1 == x2 )
    halLcdVLine( x1, y1, y2, GrayScale );
    else
    {
    if ( y1 == y2 )
    halLcdHLine( x1, x2, y1, GrayScale );
    else // a diagonal line
    {
    if (x1 > x2)
    x_dir = -1;
    else x_dir = 1;
    if (y1 > y2)
    y_dir = -1;
    else y_dir = 1;

    x = x1;
    y = y1;
    deltay = ABS(y2 - y1);
    deltax = ABS(x2 - x1);

    if (deltax >= deltay)
    {
    d = (deltay << 1) - deltax;
    while (x != x2)
    {
    halLcdPixel(x, y, GrayScale);
    if ( d < 0 )
    d += (deltay << 1);
    else
    {
    d += ((deltay - deltax) << 1);
    y += y_dir;
    }
    x += x_dir;
    }
    }
    else
    {
    d = (deltax << 1) - deltay;
    while (y != y2)
    {
    halLcdPixel(x, y, GrayScale);
    if ( d < 0 )
    d += (deltax << 1);
    else
    {
    d += ((deltax - deltay) << 1);
    x += x_dir;
    }
    y += y_dir;
    }
    }
    }
    }
    }


    /**********************************************************************//**
    * @brief Draw a circle of Radius with center at (x,y) of GrayScale level.
    *
    * Uses Bresenham's circle algorithm
    *
    * @param x x-coordinate of the circle's center point
    *
    * @param y y-coordinate of the circle's center point
    *
    * @param Radius Radius of the circle
    *
    * @param GrayScale Grayscale level of the circle
    *************************************************************************/
    void halLcdCircle(int x, int y, int Radius, int GrayScale)
    {
    int xx, yy, ddF_x, ddF_y, f;

    ddF_x = 0;
    ddF_y = -(2 * Radius);
    f = 1 - Radius;

    xx = 0;
    yy = Radius;
    halLcdPixel(x + xx, y + yy, GrayScale);
    halLcdPixel(x + xx, y - yy, GrayScale);
    halLcdPixel(x - xx, y + yy, GrayScale);
    halLcdPixel(x - xx, y - yy, GrayScale);
    halLcdPixel(x + yy, y + xx, GrayScale);
    halLcdPixel(x + yy, y - xx, GrayScale);
    halLcdPixel(x - yy, y + xx, GrayScale);
    halLcdPixel(x - yy, y - xx, GrayScale);
    while (xx < yy)
    {
    if (f >= 0)
    {
    yy--;
    ddF_y += 2;
    f += ddF_y;
    }
    xx++;
    ddF_x += 2;
    f += ddF_x + 1;
    halLcdPixel(x + xx, y + yy, GrayScale);
    halLcdPixel(x + xx, y - yy, GrayScale);
    halLcdPixel(x - xx, y + yy, GrayScale);
    halLcdPixel(x - xx, y - yy, GrayScale);
    halLcdPixel(x + yy, y + xx, GrayScale);
    halLcdPixel(x + yy, y - xx, GrayScale);
    halLcdPixel(x - yy, y + xx, GrayScale);
    halLcdPixel(x - yy, y - xx, GrayScale);
    }
    }

    /**********************************************************************//**
    * @brief Scrolls a single row of pixels one column to the left.
    *
    * The column that is scrolled out of the left side of the LCD will be
    * displayed the right side of the LCD.
    *
    * @param y The row of pixels to scroll. y = 0 is at the top-left
    * corner of the LCD.
    *
    * @return none
    *************************************************************************/
    void halLcdScrollRow(int y)
    {
    int i, Address, LcdTableAddressTemp;
    unsigned int temp;

    Address = y << 5;

    halLcdSetAddress( Address );

    //Multiplied by (1+16) and added by the offset
    LcdTableAddressTemp = y + (y << 4);
    temp = ((LCD_MEM[LcdTableAddressTemp] & 0x0003) <<14);

    for (i = 0; i < 0x10; i++)
    halLcdDrawCurrentBlock( ( (LCD_MEM[LcdTableAddressTemp+i] & 0xFFFC ) >> 2 ) \
    + ((LCD_MEM[LcdTableAddressTemp+i+1] & 0x0003) << 14 ));

    halLcdDrawCurrentBlock( (( LCD_MEM[LcdTableAddressTemp + 0x10] & 0xFFFC ) >> 2) + temp);
    }

    /**********************************************************************//**
    * @brief Scrolls multiple rows of pixels, yStart to yEnd,
    * one column to the left.
    *
    * The column that is scrolled out of the left side of the LCD will be
    * displayed the right side of the LCD. y = 0 is at the top-left of the
    * LCD screen.
    *
    * @param yStart The beginning row to be scrolled
    *
    * @param yEnd The last row to be scrolled
    *
    * @return none
    *************************************************************************/
    void halLcdHScroll(int yStart, int yEnd)
    {
    int i ;

    for (i = yStart; i < yEnd+1; i++)
    halLcdScrollRow(i);
    }

    /**********************************************************************//**
    * @brief Scrolls a line of text one column to the left.
    *
    * @param Line The line of text to be scrolled.
    *
    * @return none
    *************************************************************************/
    void halLcdScrollLine(int Line)
    {
    int i, Row ;

    Row = Line * FONT_HEIGHT;

    for (i = Row; i < Row + FONT_HEIGHT ; i++)
    halLcdScrollRow(i);
    }
  • i think i just need to modify this small file, i commented out the FFT stuffs as my friend told me, he said i just need to write some code that plots voice_data[i] on y axis and i on x axis.

    /**********************************************************************//**
    * @file FFT.c
    *
    * Copyright 2010 Texas Instruments, Inc.
    ***************************************************************************/
    #include "msp430.h"
    #include "MSP-EXP430F5438_HAL\hal_MSP-EXP430F5438.h"
    #include "UserExperience_F5438A.h"
    #include "FFT.h"
    #include "FFT_430.h"

    int FBuff[512],outer;
    unsigned short index1;

    unsigned int voice_data[1024];
    unsigned int index;
    const int bit_rev_index[]={0x00,0x80,0x40,0xC0,0x20,0xA0,0x60,0xE0,0x10,0x90,0x50,
    0xD0,0x30,0xB0,0x70,0xF0,0x08,0x88,0x48,0xC8,0x28,0xA8,
    0x68,0xE8,0x18,0x98,0x58,0xD8,0x38,0xB8,0x78,0xF8,0x04,
    0x84,0x44,0xC4,0x24,0xA4,0x64,0xE4,0x14,0x94,0x54,0xD4,
    0x34,0xB4,0x74,0xF4,0x0C,0x8C,0x4C,0xCC,0x2C,0xAC,0x6C,
    0xEC,0x1C,0x9C,0x5C,0xDC,0x3C,0xBC,0x7C,0xFC,0x02,0x82,
    0x42,0xC2,0x22,0xA2,0x62,0xE2,0x12,0x92,0x52,0xD2,0x32,
    0xB2,0x72,0xF2,0x0A,0x8A,0x4A,0xCA,0x2A,0xAA,0x6A,0xEA,
    0x1A,0x9A,0x5A,0xDA,0x3A,0xBA,0x7A,0xFA,0x06,0x86,0x46,
    0xC6,0x26,0xA6,0x66,0xE6,0x16,0x96,0x56,0xD6,0x36,0xB6,
    0x76,0xF6,0x0E,0x8E,0x4E,0xCE,0x2E,0xAE,0x6E,0xEE,0x1E,
    0x9E,0x5E,0xDE,0x3E,0xBE,0x7E,0xFE,0x01,0x81,0x41,0xC1,
    0x21,0xA1,0x61,0xE1,0x11,0x91,0x51,0xD1,0x31,0xB1,0x71,
    0xF1,0x09,0x89,0x49,0xC9,0x29,0xA9,0x69,0xE9,0x19,0x99,
    0x59,0xD9,0x39,0xB9,0x79,0xF9,0x05,0x85,0x45,0xC5,0x25,
    0xA5,0x65,0xE5,0x15,0x95,0x55,0xD5,0x35,0xB5,0x75,0xF5,
    0x0D,0x8D,0x4D,0xCD,0x2D,0xAD,0x6D,0xED,0x1D,0x9D,0x5D,
    0xDD,0x3D,0xBD,0x7D,0xFD,0x03,0x83,0x43,0xC3,0x23,0xA3,
    0x63,0xE3,0x13,0x93,0x53,0xD3,0x33,0xB3,0x73,0xF3,0x0B,
    0x8B,0x4B,0xCB,0x2B,0xAB,0x6B,0xEB,0x1B,0x9B,0x5B,0xDB,
    0x3B,0xBB,0x7B,0xFB,0x07,0x87,0x47,0xC7,0x27,0xA7,0x67,
    0xE7,0x17,0x97,0x57,0xD7,0x37,0xB7,0x77,0xF7,0x0F,0x8F,
    0x4F,0xCF,0x2F,0xAF,0x6F,0xEF,0x1F,0x9F,0x5F,0xDF,0x3F,
    0xBF,0x7F,0xFF};


    int imag, real,real_abs,imag_abs,mag,max,min;
    int FFT_data[512];

    unsigned int FFT_Image[1344];

    /**********************************************************************//**
    * @brief Sets up board for recording from microphone
    *
    * @param none
    *
    * @return none
    *************************************************************************/
    void shutdownRecorder(void)
    {
    halLcdSetBackLight(lcdBackLightLevelSettingLOCAL);

    // Power-down MSP430 modules
    TBCTL = 0; // Disable Timer_B
    ADC12CTL1 &= ~ADC12CONSEQ_2; // Stop conversion immediately
    ADC12CTL0 &= ~ADC12ENC; // Disable ADC12 conversion
    ADC12CTL0 = 0x00; // Switch off ADC12
    ADC12IE = 0x00;

    AUDIO_PORT_OUT &= ~MIC_POWER_PIN; // Turn of MIC
    AUDIO_PORT_SEL &= ~MIC_INPUT_PIN;
    }

    void setupRecorder()
    {
    AUDIO_PORT_OUT |= MIC_POWER_PIN;
    AUDIO_PORT_OUT &= ~MIC_INPUT_PIN;
    AUDIO_PORT_SEL |= MIC_INPUT_PIN;

    UCSCTL8 |= MODOSCREQEN;
    ADC12CTL0 &= ~ADC12ENC; // Disable conversions to configure ADC12
    ADC12CTL0 = ADC12ON + ADC12SHT02; // Configure ADC12 to sample a sequence of channels, once
    ADC12CTL1 = ADC12SHP + ADC12CONSEQ_2 + ADC12SSEL_2 + ADC12SHS_3;
    ADC12CTL2 = ADC12RES_0; // Select 8-bit resolution
    ADC12MCTL0 = MIC_INPUT_CHAN | ADC12EOS;
    ADC12CTL0 |= ADC12ENC; // Enable
    ADC12IE = BIT0;

    // Initialize Timer_B to be used as ADC12 trigger
    TBCTL = TBSSEL_2 + TBCLR; // Use SMCLK as Timer_B source
    TBCCR0 = 2047; // Initialize TBCCR0 (period register)
    TBCCR1= 2047 - 100; // Initialize TBCCR1 (ADC12 trigger)
    TBCCTL0 = 0x0000;
    TBCCTL1 = OUTMOD_7;
    TBCCTL2 = 0x0000;
    TBCCTL3 = 0x0000;
    TBCCTL4 = 0x0000;
    TBCCTL5 = 0x0000;
    TBCCTL6 = 0x0000;
    }

    /**********************************************************************//**
    * @brief Runs the FFT app. Performs the FFT and displays it to the screen.
    *
    * @param none
    *
    * @return none
    *************************************************************************/
    void FFTrecorder(void)
    {
    unsigned int i, //j;
    // unsigned int mask = 0x0000;

    // fftISR = 1;

    // Initialize FFT variables
    buf_index = 0;
    for(i=0; i<1344; i++) {
    FFT_Image[i] = 0x0000;
    }

    halLcdClearScreen();
    halLcdPrintLine(" FFT DEMO ", 0, 0 );
    halLcdPrintLine("0", 8, 0 );
    halLcdPrintLineCol("Fs 2", 8, 13, 0 );
    halLcdLine(120, 107, 126, 97, PIXEL_ON);
    halLcdHLine(0, 138, 96, PIXEL_ON);

    halButtonsInit( BUTTON_ALL );
    halButtonsInterruptEnable( BUTTON_ALL );
    buttonsPressed = 0;

    setupRecorder();

    while(!buttonsPressed)
    {
    TBCCTL1 &= ~CCIFG;
    TBCTL |= MC0; //start timer B
    __bis_SR_register(LPM0_bits + GIE);
    __no_operation();
    TBCTL &= ~MC0;

    if (buf_index == 512)
    for (i=0;i<512;i++)
    voice_data[i] = buffer[i];
    else
    for (i=0;i<512;i++)
    voice_data[i] = buffer[i + 512];

    /* FFT_prog(); // Perform FFT and store

    for (i=0;i<256;i++)
    {
    index=bit_rev_index[i];
    real=FBuff[2*index];
    imag=FBuff[2*index+1];
    if(real < 0)
    real_abs=~real+1;
    else
    real_abs=real;
    if(imag < 0)
    imag_abs=~imag+1;
    else
    imag_abs=imag;
    if(real_abs >= imag_abs)
    {
    max=real_abs;
    min=imag_abs;
    }
    else
    {
    max=imag_abs;
    min=real_abs;
    }
    mag=max+3*(min>>3);
    FFT_data[i]=mag;
    }*/

    //prepare the image of the FFT for display
    /* for (i=1;i<128;i++)
    {
    switch(i%8)
    {
    case 1: mask = 0x0003; break;
    case 2: mask = 0x000C; break;
    case 3: mask = 0x0030; break;
    case 4: mask = 0x00C0; break;
    case 5: mask = 0x0300; break;
    case 6: mask = 0x0C00; break;
    case 7: mask = 0x3000; break;
    case 0: mask = 0xC000; break;
    default: mask = 0x0000; break;
    }
    for (j=0; j<84; j++)
    {
    if (j<(84-FFT_data[i]*2))
    FFT_Image[((i-1)/8)+j*16] &= ~mask;
    else
    FFT_Image[((i-1)/8)+j*16] |= mask;
    }
    }*/
    halLcdImage(FFT_Image, 16, 84, 1, 12); //display the image
    }
    // fftISR = 0;
    shutdownRecorder();
    }
  • Hi,

    Basically use the microphone as input device and it draws a graph voice_data[i] on y axis and i on x axis. x is time passing, y is voice amplitude. That is the time domain. I think I need a permanet for loop that uses the function halLCDline(x1, x2, y1, y2, grayscale) to draw onto the LCD screen.

    The code provided is teh frequency domain after Fast Fourier Transform, we need to disable this FFT_prog() and draw the time domain function instead.

    Can you help?

  • Basically to draw a real time oscilloscope with loudness of voice as amplitude y axis vs time on x axis.
    Part of the code has been pasted, just need to modify it a little.
  • Questions like these plague me so often but I have no idea where to start with all of the code that you have put up. Have you tried resetting it and re uploading any code that worked previously. This can sometimes be the problem, that the boards isnot responding correctly.
  • Hi Jackie,

    Someone told me that I need to scale it because the values are over a thousand while the LCD screen is just a 138 * 108.

    How do I scale it? divide i by a number to shrink it?

    One of the question is that I need to code an automatic scaling function that will make the wave fit he LCD screen automatically.

    Regards,

    M

  • for (i=0, i<256, i++)
    {
    halLcdLine(i, voice_data[i], i+1, voice_data[i+1], PIXEL_OFF);
    halLcdLine(i, voice_data[i], i+1, voice_data[i+1], PIXEL_ON);
    }

    This just draws multiple vertical lines and 1 squiggly horizontal line when button is pressed. Refreshes everytime button is pressed, does not continue by itself.

    I tried using another code drawing the original FET_image, there are lots of vertical lines as well as a continuous horizontal line that moves when sound is introduce to the microphone.

    void FFTrecorder(void)
    {
    unsigned int i, //j;
    // unsigned int mask = 0x0000;

    // fftISR = 1;

    // Initialize FFT variables
    buf_index = 0;
    for(i=0; i<1344; i++) {
    FFT_Image[i] = 0x0000;
    }

    halLcdClearScreen();
    halLcdPrintLine(" FFT DEMO ", 0, 0 );
    halLcdPrintLine("0", 8, 0 );
    halLcdPrintLineCol("Fs 2", 8, 13, 0 );
    halLcdLine(120, 107, 126, 97, PIXEL_ON);
    halLcdHLine(0, 138, 96, PIXEL_ON);

    halButtonsInit( BUTTON_ALL );
    halButtonsInterruptEnable( BUTTON_ALL );
    buttonsPressed = 0;

    setupRecorder();

    while(!buttonsPressed)
    {
    TBCCTL1 &= ~CCIFG;
    TBCTL |= MC0; //start timer B
    __bis_SR_register(LPM0_bits + GIE);
    __no_operation();
    TBCTL &= ~MC0;

    if (buf_index == 512)
    for (i=0;i<512;i++)
    voice_data[i] = buffer[i];
    else
    for (i=0;i<512;i++)
    voice_data[i] = buffer[i + 512];

    //prepare the image of the FFT for display
    for (i=1;i<128;i++)
    {
    switch(i%8)
    {
    case 1: mask = 0x0003; break;
    case 2: mask = 0x000C; break;
    case 3: mask = 0x0030; break;
    case 4: mask = 0x00C0; break;
    case 5: mask = 0x0300; break;
    case 6: mask = 0x0C00; break;
    case 7: mask = 0x3000; break;
    case 0: mask = 0xC000; break;
    default: mask = 0x0000; break;
    }
    for (j=0; j<84; j++)
    {
    if (j<(84-FFT_data[i]*2))
    FFT_Image[((i-1)/8)+j*16] &= ~mask;
    else
    FFT_Image[((i-1)/8)+j*16] |= mask;
    }

    halLcdImage(FFT_Image, 16, 84, 1, 12); //display the image
    }
    fftISR = 0;
  • forgot to put this loop just before yhe pmage preparation code:

    for (i=0, i<256, i++)
    {
    halLcdLine(i, voice_data[i], i+1, voice_data[i+1], PIXEL_ON);
    }

    This draws the vertical and horizontal noise line continously but I don't need to draw the vertical lines, how do i disable that?
  • {
    while(1)
    if (j<(84-Vdata[i]*2))
    FFT_Image[((i-1)/8)+j*16] &= ~mask;
    else
    FFT_Image[((i-1)/8)+j*16] |= mask;
    }

    try adding this in it should scale it to an 1/8 of the size

  • Where exactly do I add that in?

    Is it inside the for loop? Above or below the line: halLcdLine(i, voice_data[i], i + 1, voice_data[i + 1], PIXEL_ON);

         for (i=0;i<256;i++)
         
        { 
         
            halLcdLine(i, voice_data[i], i + 1, voice_data[i + 1], PIXEL_ON);
            
         } 
    Should I change the for loop into a while loop?
    Also, in my code: mask and j is commented out. Should I declare these variables back in?
    Also, Vdata[i]*2 is not declared either, there is a variable call voice_data[i] but not Vdata[i], should I declare another variable Vdata[i]?
  • I see that your code is similar to the code at the bottom, do I comment out the switch case which assigns hex number to the mask? Should I also comment out:

    "halLcdImage(FFT_Image, 16, 84, 1, 12); //display the image
    }
    fftISR = 0; "

    And change the for loop into a while loop??? As per your recommendation?

    //prepare the image of the FFT for display
    for (i=1;i<128;i++)
    {
    switch(i%8)
    {
    case 1: mask = 0x0003; break;
    case 2: mask = 0x000C; break;
    case 3: mask = 0x0030; break;
    case 4: mask = 0x00C0; break;
    case 5: mask = 0x0300; break;
    case 6: mask = 0x0C00; break;
    case 7: mask = 0x3000; break;
    case 0: mask = 0xC000; break;
    default: mask = 0x0000; break;
    }
    for (j=0; j<84; j++)
    {
    if (j<(84-FFT_data[i]*2))
    FFT_Image[((i-1)/8)+j*16] &= ~mask;
    else
    FFT_Image[((i-1)/8)+j*16] |= mask;
    }
    }
    halLcdImage(FFT_Image, 16, 84, 1, 12); //display the image
    }
    fftISR = 0;
  • Hi,

    I declared the variables, j, mask, and change the Vdata[i] to FFT_data[i].

    I put that code in right below the halLCDline function, nothing appears on the LCD screen:

    for (i=0;i<256;i++)

    {

    halLcdLine(i, voice_data[i], i + 1, voice_data[i + 1], PIXEL_ON);

    }

    {
    while(1)
    if (j<(84-FFT_data[i]*2))
    FFT_Image[((i-1)/8)+j*16] &= ~mask;
    else
    FFT_Image[((i-1)/8)+j*16] |= mask;
    }

  • hi,

    someone told me that the FFT_image is wrong?!!? I don't need the FFT_image.

    i just draw the code using halLcdLine(i, voice_data[i], i+1, voice_data[i+1], PIXEL_ON);
  • This code draws the lines of voice amplitude but it does not refresh and erase the lines so each iteration, more and more lines are drawn onto the LCD until it's all black. How do I refresh the screen after each iteration? Someone told me it's something to do with       // halLcdLine(i, voice_data[i], i + 1, voice_data[i + 1], PIXEL_OFF);

    but ive tried and it doesn't erase the lines.

    /**********************************************************************//**
     * @file FFT.c
     *
     * Copyright 2010 Texas Instruments, Inc.
    ***************************************************************************/
    #include "msp430.h"
    #include "MSP-EXP430F5438_HAL\hal_MSP-EXP430F5438.h"
    #include "UserExperience_F5438A.h"
    #include "FFT.h"
    #include "FFT_430.h"

    int FBuff[512],outer;
    unsigned short index1;

    unsigned int voice_data[1024];
    unsigned int index;
    const int bit_rev_index[]={0x00,0x80,0x40,0xC0,0x20,0xA0,0x60,0xE0,0x10,0x90,0x50,
                               0xD0,0x30,0xB0,0x70,0xF0,0x08,0x88,0x48,0xC8,0x28,0xA8,
                               0x68,0xE8,0x18,0x98,0x58,0xD8,0x38,0xB8,0x78,0xF8,0x04,
                               0x84,0x44,0xC4,0x24,0xA4,0x64,0xE4,0x14,0x94,0x54,0xD4,
                               0x34,0xB4,0x74,0xF4,0x0C,0x8C,0x4C,0xCC,0x2C,0xAC,0x6C,
                               0xEC,0x1C,0x9C,0x5C,0xDC,0x3C,0xBC,0x7C,0xFC,0x02,0x82,
                               0x42,0xC2,0x22,0xA2,0x62,0xE2,0x12,0x92,0x52,0xD2,0x32,
                               0xB2,0x72,0xF2,0x0A,0x8A,0x4A,0xCA,0x2A,0xAA,0x6A,0xEA,
                               0x1A,0x9A,0x5A,0xDA,0x3A,0xBA,0x7A,0xFA,0x06,0x86,0x46,
                               0xC6,0x26,0xA6,0x66,0xE6,0x16,0x96,0x56,0xD6,0x36,0xB6,
                               0x76,0xF6,0x0E,0x8E,0x4E,0xCE,0x2E,0xAE,0x6E,0xEE,0x1E,
                               0x9E,0x5E,0xDE,0x3E,0xBE,0x7E,0xFE,0x01,0x81,0x41,0xC1,
                               0x21,0xA1,0x61,0xE1,0x11,0x91,0x51,0xD1,0x31,0xB1,0x71,
                               0xF1,0x09,0x89,0x49,0xC9,0x29,0xA9,0x69,0xE9,0x19,0x99,
                               0x59,0xD9,0x39,0xB9,0x79,0xF9,0x05,0x85,0x45,0xC5,0x25,
                               0xA5,0x65,0xE5,0x15,0x95,0x55,0xD5,0x35,0xB5,0x75,0xF5,
                               0x0D,0x8D,0x4D,0xCD,0x2D,0xAD,0x6D,0xED,0x1D,0x9D,0x5D,
                               0xDD,0x3D,0xBD,0x7D,0xFD,0x03,0x83,0x43,0xC3,0x23,0xA3,
                               0x63,0xE3,0x13,0x93,0x53,0xD3,0x33,0xB3,0x73,0xF3,0x0B,
                               0x8B,0x4B,0xCB,0x2B,0xAB,0x6B,0xEB,0x1B,0x9B,0x5B,0xDB,
                               0x3B,0xBB,0x7B,0xFB,0x07,0x87,0x47,0xC7,0x27,0xA7,0x67,
                               0xE7,0x17,0x97,0x57,0xD7,0x37,0xB7,0x77,0xF7,0x0F,0x8F,
                               0x4F,0xCF,0x2F,0xAF,0x6F,0xEF,0x1F,0x9F,0x5F,0xDF,0x3F,
                               0xBF,0x7F,0xFF};


    int imag, real,real_abs,imag_abs,mag,max,min;
    int FFT_data[512];

    unsigned int FFT_Image[1344];

    /**********************************************************************//**
     * @brief  Sets up board for recording from microphone
     *
     * @param  none
     *
     * @return none
     *************************************************************************/
    void shutdownRecorder(void)
    {
      halLcdSetBackLight(lcdBackLightLevelSettingLOCAL);
     
      // Power-down MSP430 modules
      TBCTL = 0;                                // Disable Timer_B
      ADC12CTL1 &= ~ADC12CONSEQ_2;              // Stop conversion immediately
      ADC12CTL0 &= ~ADC12ENC;                   // Disable ADC12 conversion
      ADC12CTL0 = 0x00;                         // Switch off ADC12
      ADC12IE = 0x00;

      AUDIO_PORT_OUT &= ~MIC_POWER_PIN;         // Turn of MIC   
      AUDIO_PORT_SEL &= ~MIC_INPUT_PIN;   
    }

    void setupRecorder()
    {
      AUDIO_PORT_OUT |= MIC_POWER_PIN;
      AUDIO_PORT_OUT &= ~MIC_INPUT_PIN;
      AUDIO_PORT_SEL |= MIC_INPUT_PIN;
     
      UCSCTL8 |= MODOSCREQEN;
      ADC12CTL0 &= ~ADC12ENC;                   // Disable conversions to configure ADC12
      ADC12CTL0 = ADC12ON + ADC12SHT02;         // Configure ADC12 to sample a sequence of channels, once
      ADC12CTL1 = ADC12SHP + ADC12CONSEQ_2 + ADC12SSEL_2 + ADC12SHS_3;     
      ADC12CTL2 = ADC12RES_0;                   // Select 8-bit resolution
      ADC12MCTL0 = MIC_INPUT_CHAN | ADC12EOS;
      ADC12CTL0 |= ADC12ENC;                    // Enable
      ADC12IE = BIT0;

      // Initialize Timer_B to be used as ADC12 trigger
      TBCTL = TBSSEL_2 + TBCLR;          // Use SMCLK as Timer_B source
      TBCCR0 = 2047;                     // Initialize TBCCR0 (period register)
      TBCCR1= 2047 - 100; // Initialize TBCCR1 (ADC12 trigger)
      TBCCTL0 = 0x0000;
      TBCCTL1 = OUTMOD_7;   
      TBCCTL2 = 0x0000;
      TBCCTL3 = 0x0000;
      TBCCTL4 = 0x0000;
      TBCCTL5 = 0x0000;
      TBCCTL6 = 0x0000;
    }

    /**********************************************************************//**
     * @brief  Runs the FFT app. Performs the FFT and displays it to the screen.
     *
     * @param  none
     *
     * @return none
     *************************************************************************/
    void FFTrecorder(void)
    {    
      unsigned int i;
     // unsigned int mask = 0x0000;
     
      fftISR = 1;
     
      // Initialize FFT variables   
      buf_index = 0;
    //  for(i=0; i<1344; i++) {
    //  FFT_Image[i] = 0x0000;
    //  }

      halLcdClearScreen();
      halLcdPrintLine("    FFT DEMO   ", 0, 0 );
      halLcdPrintLine("0", 8, 0 );
      halLcdPrintLineCol("Fs 2", 8, 13, 0 );
      halLcdLine(120, 107, 126, 97, PIXEL_ON);
      halLcdHLine(0, 138, 96, PIXEL_ON);

      halButtonsInit( BUTTON_ALL );
      halButtonsInterruptEnable( BUTTON_ALL );
      buttonsPressed = 0;
     
      setupRecorder();
     
      while(!buttonsPressed)
      {
        TBCCTL1 &= ~CCIFG;
      TBCTL |= MC0; //start timer B
        __bis_SR_register(LPM0_bits + GIE);  
        __no_operation();
        TBCTL &= ~MC0;
     
        if (buf_index == 512)    
          for (i=0;i<512;i++)
        voice_data[i] = buffer[i];         
        else
          for (i=0;i<512;i++)
        voice_data[i] = buffer[i + 512];
        
     /*   FFT_prog();                     // Perform FFT and store
        
        for (i=0;i<256;i++)
        {
          index=bit_rev_index[i];
          real=FBuff[2*index];
          imag=FBuff[2*index+1];
          if(real < 0)
            real_abs=~real+1;
          else
            real_abs=real;  
          if(imag < 0)
            imag_abs=~imag+1;
          else
            imag_abs=imag;  
          if(real_abs >= imag_abs)
          {
            max=real_abs;
            min=imag_abs;
          }
          else
          {
             max=imag_abs;
             min=real_abs;
          }
          mag=max+3*(min>>3); */
         
         for (i=0;i<256;i++)
         
        {
     
            halLcdLine(i, voice_data[i], i + 2, voice_data[i + 2], PIXEL_ON);
           // halLcdLine(i, voice_data[i], i + 1, voice_data[i + 1], PIXEL_OFF);
            
         }  
     
       //prepare the image of the FFT for display
    ////    for (i=1;i<128;i++)
    //    {
    ////    switch(i%8)
    ////    {
    ////   case 1: mask = 0x0003; break;
    ////   case 2: mask = 0x000C; break;
    ////   case 3: mask = 0x0030; break;
    ////   case 4: mask = 0x00C0; break;
    ////   case 5: mask = 0x0300; break;
    ////   case 6: mask = 0x0C00; break;
    ////   case 7: mask = 0x3000; break;
    ////   case 0: mask = 0xC000; break;
    ////   default: mask = 0x0000; break;
    ////      }
    //      for (j=0; j<84; j++)
    //      {
    //     if (j<(84-FFT_data[i]*2))
    //      FFT_Image[((i-1)/8)+j*16] &= ~mask;
    //     else
    //    FFT_Image[((i-1)/8)+j*16] |= mask;
    //      }
    //    }
      //  halLcdImage(FFT_Image, 16, 84, 1, 12); //display the image
      }
    //  fftISR = 0;   
      shutdownRecorder();  
    }

  • turns out i just need to add a clear screen line before or after the for loop to rewrite the lines. the pixel_off before the pixel_on doesn't seem to do anything but i might just leave it in anyway because someone told me that it was required but i can't why it is required since the code works without it.

    halLcdClearScreen();
    for (i=0;i<128;i++)

    {

    //halLcdLine(i, voice_data[i], i + 2, voice_data[i + 2], PIXEL_OFF);
    halLcdLine(i, voice_data[i], i + 2, voice_data[i + 2], PIXEL_ON);


    }

    now the only thing is that the time is going too fast, i wonder how to delay it? i think ive seen some delay code somewhere but can't remember where?
  • I hope you find the answers soon. for i have not a clue how to fix it. if you find the answer you seek please let me know. 

  • here's an easier one, how do i change sampling rate on below code? and then another question for this exercise is:  

    Provide signal FFT functionality (note: this is dependent on sampling rate)?

    /**********************************************************************//**
     * @file FFT.c
     * 
     * Copyright 2010 Texas Instruments, Inc.
    ***************************************************************************/
    #include "msp430.h"
    #include "MSP-EXP430F5438_HAL\hal_MSP-EXP430F5438.h"
    #include "UserExperience_F5438A.h"
    #include "FFT.h"
    #include "FFT_430.h"
    int FBuff[512],outer;
    unsigned short index1;
    unsigned int voice_data[1024];
    unsigned int index;
    const int bit_rev_index[]={0x00,0x80,0x40,0xC0,0x20,0xA0,0x60,0xE0,0x10,0x90,0x50, 
                               0xD0,0x30,0xB0,0x70,0xF0,0x08,0x88,0x48,0xC8,0x28,0xA8,
                               0x68,0xE8,0x18,0x98,0x58,0xD8,0x38,0xB8,0x78,0xF8,0x04,
                               0x84,0x44,0xC4,0x24,0xA4,0x64,0xE4,0x14,0x94,0x54,0xD4,
                               0x34,0xB4,0x74,0xF4,0x0C,0x8C,0x4C,0xCC,0x2C,0xAC,0x6C,
                               0xEC,0x1C,0x9C,0x5C,0xDC,0x3C,0xBC,0x7C,0xFC,0x02,0x82,
                               0x42,0xC2,0x22,0xA2,0x62,0xE2,0x12,0x92,0x52,0xD2,0x32,
                               0xB2,0x72,0xF2,0x0A,0x8A,0x4A,0xCA,0x2A,0xAA,0x6A,0xEA,
                               0x1A,0x9A,0x5A,0xDA,0x3A,0xBA,0x7A,0xFA,0x06,0x86,0x46,
                               0xC6,0x26,0xA6,0x66,0xE6,0x16,0x96,0x56,0xD6,0x36,0xB6,
                               0x76,0xF6,0x0E,0x8E,0x4E,0xCE,0x2E,0xAE,0x6E,0xEE,0x1E,
                               0x9E,0x5E,0xDE,0x3E,0xBE,0x7E,0xFE,0x01,0x81,0x41,0xC1,
                               0x21,0xA1,0x61,0xE1,0x11,0x91,0x51,0xD1,0x31,0xB1,0x71,
                               0xF1,0x09,0x89,0x49,0xC9,0x29,0xA9,0x69,0xE9,0x19,0x99,
                               0x59,0xD9,0x39,0xB9,0x79,0xF9,0x05,0x85,0x45,0xC5,0x25,
                               0xA5,0x65,0xE5,0x15,0x95,0x55,0xD5,0x35,0xB5,0x75,0xF5,
                               0x0D,0x8D,0x4D,0xCD,0x2D,0xAD,0x6D,0xED,0x1D,0x9D,0x5D,
                               0xDD,0x3D,0xBD,0x7D,0xFD,0x03,0x83,0x43,0xC3,0x23,0xA3,
                               0x63,0xE3,0x13,0x93,0x53,0xD3,0x33,0xB3,0x73,0xF3,0x0B,
                               0x8B,0x4B,0xCB,0x2B,0xAB,0x6B,0xEB,0x1B,0x9B,0x5B,0xDB,
                               0x3B,0xBB,0x7B,0xFB,0x07,0x87,0x47,0xC7,0x27,0xA7,0x67,
                               0xE7,0x17,0x97,0x57,0xD7,0x37,0xB7,0x77,0xF7,0x0F,0x8F,
                               0x4F,0xCF,0x2F,0xAF,0x6F,0xEF,0x1F,0x9F,0x5F,0xDF,0x3F,
                               0xBF,0x7F,0xFF};
    int imag, real,real_abs,imag_abs,mag,max,min;
    int FFT_data[512];
    unsigned int FFT_Image[1344];
    /**********************************************************************//**
     * @brief  Sets up board for recording from microphone
     * 
     * @param  none 
     * 
     * @return none 
     *************************************************************************/
    void shutdownRecorder(void)
      halLcdSetBackLight(lcdBackLightLevelSettingLOCAL);
      
      // Power-down MSP430 modules
      TBCTL = 0;                                // Disable Timer_B
      ADC12CTL1 &= ~ADC12CONSEQ_2;              // Stop conversion immediately
      ADC12CTL0 &= ~ADC12ENC;                   // Disable ADC12 conversion
      ADC12CTL0 = 0x00;                         // Switch off ADC12
      ADC12IE = 0x00;
      AUDIO_PORT_OUT &= ~MIC_POWER_PIN;         // Turn of MIC   
      AUDIO_PORT_SEL &= ~MIC_INPUT_PIN;   
    }
    void setupRecorder()
    {
      AUDIO_PORT_OUT |= MIC_POWER_PIN;
      AUDIO_PORT_OUT &= ~MIC_INPUT_PIN;
      AUDIO_PORT_SEL |= MIC_INPUT_PIN;
      
      UCSCTL8 |= MODOSCREQEN;
      ADC12CTL0 &= ~ADC12ENC;                   // Disable conversions to configure ADC12
      ADC12CTL0 = ADC12ON + ADC12SHT02;         // Configure ADC12 to sample a sequence of channels, once
      ADC12CTL1 = ADC12SHP + ADC12CONSEQ_2 + ADC12SSEL_2 + ADC12SHS_3;     
      ADC12CTL2 = ADC12RES_0;                   // Select 8-bit resolution
      ADC12MCTL0=ADC12INCH_7+ADC12EOS;  
      ADC12CTL0 |= ADC12ENC;                    // Enable
      ADC12IE = BIT0;
      // Initialize Timer_B to be used as ADC12 trigger
      TBCTL = TBSSEL_2 + TBCLR;          // Use SMCLK as Timer_B source
      TBCCR0 = 2047;                     // Initialize TBCCR0 (period register)
      TBCCR1= 2047 - 100; // Initialize TBCCR1 (ADC12 trigger)
      TBCCTL0 = 0x0000;
      TBCCTL1 = OUTMOD_7;   
      TBCCTL2 = 0x0000;
      TBCCTL3 = 0x0000;
      TBCCTL4 = 0x0000;
      TBCCTL5 = 0x0000;
      TBCCTL6 = 0x0000;
    }
    /**********************************************************************//**
     * @brief  Runs the FFT app. Performs the FFT and displays it to the screen.
     * 
     * @param  none 
     * 
     * @return none 
     *************************************************************************/
    void FFTrecorder(void)
    {    
      unsigned int i, j;
      unsigned int mask = 0x0000;
      
      fftISR = 1;
      
      // Initialize FFT variables   
      buf_index = 0;
      for(i=0; i<1344; i++) {
      FFT_Image[i] = 0x0000;
      }
      halLcdClearScreen();
      halLcdPrintLine("    FFT DEMO   ", 0, 0 );
      halLcdPrintLine("0", 8, 0 );
      halLcdPrintLineCol("Fs 2", 8, 13, 0 );
      halLcdLine(120, 107, 126, 97, PIXEL_ON);
      halLcdHLine(0, 138, 96, PIXEL_ON);
      halButtonsInit( BUTTON_ALL );
      halButtonsInterruptEnable( BUTTON_ALL );
      buttonsPressed = 0;
      
      setupRecorder();
      
      while(!buttonsPressed)
      {
        TBCCTL1 &= ~CCIFG;
      TBCTL |= MC0; //start timer B
        __bis_SR_register(LPM0_bits + GIE);  
        __no_operation();
        TBCTL &= ~MC0;
     
        if (buf_index == 512)    
          for (i=0;i<512;i++)
        voice_data[i] = buffer[i];        
        else
          for (i=0;i<512;i++)
        FFT_data[i] = buffer[i + 512];
    //    
    //    FFT_prog();                     // Perform FFT and store
    //    
    //    for (i=0;i<256;i++)
    //    {
    //      index=bit_rev_index[i];
    //      real=FBuff[2*index];
    //      imag=FBuff[2*index+1];
    //      if(real < 0)
    //        real_abs=~real+1;
    //      else
    //        real_abs=real;  
    //      if(imag < 0)
    //        imag_abs=~imag+1;
    //      else
    //        imag_abs=imag;  
    //      if(real_abs >= imag_abs)
    //      {
    //        max=real_abs;
    //        min=imag_abs;
    //      }
    //      else
    //      {
    //         max=imag_abs;
    //         min=real_abs;
    //      }
    //      mag=max+3*(min>>3);
    //      FFT_data[i]=mag;
    //    }  
    //  
       //prepare the image of the FFT for display
        for (i=1;i<128;i++)
        { 
         switch(i%8)
         {
        case 1: mask = 0x0003; break;
        case 2: mask = 0x000C; break;
        case 3: mask = 0x0030; break;
        case 4: mask = 0x00C0; break;
        case 5: mask = 0x0300; break;
        case 6: mask = 0x0C00; break;
        case 7: mask = 0x3000; break;
        case 0: mask = 0xC000; break;
        default: mask = 0x0000; break;
          }
          for (j=0; j<84; j++)
          {
        if (j<(84-FFT_data[i]*2))
         FFT_Image[((i-1)/8)+j*16] &= ~mask;
        else
         FFT_Image[((i-1)/8)+j*16] |= mask;
          }
        }
        halLcdImage(FFT_Image, 16, 84, 1, 12); //display the image
      } 
      fftISR = 0;   
      shutdownRecorder();  
    }
  • may as well ask these 3 questions of the exercise, maybe you find it easy, just modify the earlier code i sent a few minutes ago:

    • Provide digital filtering functionality.
    • Provide automatic scaling.
    • Provide varying sampling rates.
    • Provide signal FFT functionality (note: this is dependent on sampling rate).
    • Provide store/recall scope functionality.

    thanks if you have any clue.
  • +#include <msp430g2553.h> // Specific device
    +#include <stdint.h>
    +
    +// Pins for LEDs
    +#define LED1 BIT0
    +#define LED2 BIT6
    +
    +// Iterations of delay loop; reduce for simulation
    +#define DELAYLOOPS 50000
    +
    +void main (void)
    +{
    + volatile uint16_t LoopCtr; // Loop counter: volatile!
    + WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
    + P1OUT = ~LED1; // Preload LED1 on , LED2 off
    + P1DIR = LED1|LED2; // Set pins with LED1 ,2 to output
    +
    + for (;;) { // Loop forever
    + for (LoopCtr = 0; LoopCtr < DELAYLOOPS; ++ LoopCtr) {
    + } // Empty delay loop
    +
    + P1OUT ^= LED1|LED2; // Toggle LEDs
    + }
    +}

**Attention** This is a public forum