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.

CCS/MSP432P401R: CCS Sine Wave Graphing in GUI Composer

Part Number: MSP432P401R

Tool/software: Code Composer Studio

Hello,

I have a adc14_single_conversion_repeat code that gives me an array with the x and y values to plot the sine wave, however how would I graph this array in GUI composer as when I use the default Scalar Graph option and have it display the normalizedADCRes for the graph the output cannot keep up with any sine wave with higher than 100mHz frequency.

So is there a way to graph through GUI Composer using an array of the x and y values to be graphed to graph the sine wave, or is there a way to utilize the in built graph widgets to reliably graph the waves with frequencies higher than 100mHz - 10kHz.

My Code from CCS:

/* DriverLib Includes */
#include <ti/devices/msp432p4xx/driverlib/driverlib.h>

/* Standard Includes */
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>

/* Statics */
static volatile uint16_t curADCResult; //uint16_t
static volatile float normalizedADCRes;

/* Other variables*/
float graph;
float val[100]; //Moved val[] and i,j,k variables
int i = 0;
int j = 0;
int k = 0;

static float convertToFloat(uint16_t result)
{
    int32_t temp;
    if(0x8000 & result)
    {
        temp = (result >> 2) | 0xFFFFC000;
        //printf("hit if");
        return ((temp * 3.3f) / 8191);
    }
    else
    {
        //printf("hit else");
        return ((result/2)*3.3f) / (8191);
    }
}


int main(void)
{
    //10kHz then 17.5 Samples in between Peaks
    //5kHz then 35 Samples in between Peaks
    //5.8 us

    /* Halting the Watchdog */
    MAP_WDT_A_holdTimer();

    /* Initializing Variables */
    curADCResult = 0;

    /* Setting Flash wait state */
    MAP_FlashCtl_setWaitState(FLASH_BANK0, 1);
    MAP_FlashCtl_setWaitState(FLASH_BANK1, 1);
    
    /* Setting DCO to 48MHz */
    MAP_PCM_setPowerState(PCM_AM_LDO_VCORE1);
    MAP_CS_setDCOCenteredFrequency(CS_DCO_FREQUENCY_48);

    /* Enabling the FPU for floating point operation */
    MAP_FPU_enableModule();
    MAP_FPU_enableLazyStacking();

    //![Single Sample Mode Configure]
    /* Initializing ADC (MCLK/1/4) */
    MAP_ADC14_enableModule();
    MAP_ADC14_initModule(ADC_CLOCKSOURCE_MCLK, ADC_PREDIVIDER_1, ADC_DIVIDER_4,
    0);
    //MAP_ADC14_initModule(ADC_CLOCKSOURCE_MCLK, ADC_PREDIVIDER_1, ADC_DIVIDER_4,0);

    /* Configuring GPIOs (5.5 A0) */
    MAP_GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P5, GPIO_PIN5,
    GPIO_TERTIARY_MODULE_FUNCTION);

    /* Configuring ADC Memory */
    MAP_ADC14_configureSingleSampleMode(ADC_MEM0, true);
    MAP_ADC14_configureConversionMemory(ADC_MEM0, ADC_VREFPOS_AVCC_VREFNEG_VSS,
    ADC_INPUT_A0, false);

    /* Configuring Sample Timer */
    MAP_ADC14_enableSampleTimer(ADC_MANUAL_ITERATION);

    /* Enabling/Toggling Conversion */
    MAP_ADC14_enableConversion();
    MAP_ADC14_toggleConversionTrigger();
    //![Single Sample Mode Configure]

    /* Enabling interrupts */
    MAP_ADC14_enableInterrupt(ADC_INT0);
    MAP_Interrupt_enableInterrupt(INT_ADC14);
    MAP_Interrupt_enableMaster();

    while (1)
    {
        MAP_PCM_gotoLPM0();
    }

}

//![Single Sample Result]
/* ADC Interrupt Handler. This handler is called whenever there is a conversion
* that is finished for ADC_MEM0.
*/
void ADC14_IRQHandler(void)
{
    float avg = 0;

    //double nRes;
    uint64_t status = MAP_ADC14_getEnabledInterruptStatus();
    //float nRes;
    //uint32_t temp;
    MAP_ADC14_clearInterruptFlag(status);

    if (ADC_INT0 & status)
    {
        while(i<100)
        {
            curADCResult = MAP_ADC14_getResult(ADC_MEM0);
            normalizedADCRes = convertToFloat(curADCResult);
            //normalizedADCRes = (curADCResult * 3.3) / 16384;
            //nRes = (double)normalizedADCRes;
            //printf("\n\r> D0 = %d.%03d V", nRes);
            val[i] = normalizedADCRes;
            
            //printf("%f\n", normalizedADCRes);
            //printf("%f\n", val[i]);
            MAP_ADC14_toggleConversionTrigger();
            i++;

            if(i == 100) //trigger when array is filled and print out values of the array once hit
            {
                while(k < 100)
                {
                    graph = val[k];
                    printf("%f\n", val[k]);
                    k++;
                }
            }
}

//printf("FINISHED 100 samples\n");

    while(j < 100) //calculates the average using the values stored in array
    {
        avg = avg + val[j];
        j++;
    }

        avg = avg/100;
        printf("Average: %f\n", avg);
        //ADC14_disableConversion(); //instead of exit() disabling conversion to exit
}


}

My Outputs:

Thank You and Please Help!

  • SunHo Kim said:
    s there a way to utilize the in built graph widgets to reliably graph the waves with frequencies higher than 100mHz - 10kHz.

    The graphing capabilities are more limited at those frequencies. For best accuracy, I would really suggest using a HW solution like a high speed oscilloscope.