Part Number: DK-TM4C129X
Tool/software: Code Composer Studio
Hey,
I am new with this CMSIS DSP library functions. I am currently working on a project that involves computing FFT of external analog signal by function generator. I have successfully sampled the analog signal using ADC triggered by TIMER and used DMA to store the values in an 1024 length array "g_ui8RxBufA". Now, I want to compute the FFT of this signal. I built the CMSIS DSP library successfully and ran the examples given there. I ran the FFT example given in there that calculates FFT of test data signal. I want to proceed like that only. So, the output "g_ui8RxBufA" array, I added 0 value at every odd index of array by using for loop as shown in code (as array indexing starts from 0) to form array " testInput_f32_10khz" (of length 2048) and followed same procedure as in example. But when I ran the code, all the values of " testInput_f32_10khz" array were 0. Somehow, the values are not transferring from "g_ui8RxBufA" array. Can anyone please point out the flaw in the code?
Main function:
uint32_t sysclock; sysclock = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000); SysCtlPeripheralEnable(SYSCTL_PERIPH_UDMA); while(!(SysCtlPeripheralReady(SYSCTL_PERIPH_UDMA))); SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_UDMA); IntMasterEnable(); IntEnable(INT_UDMAERR); uDMAEnable(); uDMAControlBaseSet(pui8ControlTable); InitUART1Transfer(sysclock); //FFT begins uint32_t i; for(i = 0; i < 1024; i++) { //if(i % 2 == 0) testInput_f32_10khz[2*i] = g_ui8RxBufA[i]; //else testInput_f32_10khz[2*i + 1] = 0; } /* ---------------------------------------------------------------------- * Max magnitude FFT Bin test * ------------------------------------------------------------------- */ //int32_t main(void) //{ arm_status status; float32_t maxValue; status = ARM_MATH_SUCCESS; /* Process the data through the CFFT/CIFFT module */ arm_cfft_f32(&arm_cfft_sR_f32_len1024, testInput_f32_10khz, ifftFlag, doBitReverse); /* Process the data through the Complex Magnitude Module for calculating the magnitude at each bin */ arm_cmplx_mag_f32(testInput_f32_10khz, testOutput, fftSize); /* Calculates maxValue and returns corresponding BIN value */ arm_max_f32(testOutput, fftSize, &maxValue, &testIndex); if (testIndex != refIndex) { status = ARM_MATH_TEST_FAILURE; } /* ---------------------------------------------------------------------- ** Loop here if the signals fail the PASS check. ** This denotes a test failure ** ------------------------------------------------------------------- */ if ( status != ARM_MATH_SUCCESS) { while (1); } //FFT ends // while (1); /* main function does not return */ while(1) { }
InitUART1Transfer() function:
uint32_t ui32Period; //uint32_t div; SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); while(!(SysCtlPeripheralReady(SYSCTL_PERIPH_ADC0))); SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_ADC0); //ADCClockConfigSet(ADC0_BASE, ADC_CLOCK_SRC_PIOSC | ADC_CLOCK_RATE_FULL, 1); // ADCClockConfigSet(ADC0_BASE, ADC_CLOCK_SRC_PLL | ADC_CLOCK_RATE_FULL, 30); ADCClockConfigSet(ADC0_BASE, ADC_CLOCK_SRC_PLL | ADC_CLOCK_RATE_FULL, 24); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); while(!(SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOE))); GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_3); //ADCSequenceConfigure(ADC0_BASE, 0 /*SS0*/, ADC_TRIGGER_ALWAYS, 3 /*priority*/); // SS0-SS3 priorities must always be different ADCSequenceConfigure(ADC0_BASE, 0, ADC_TRIGGER_TIMER, 0); ADCSequenceStepConfigure(ADC0_BASE, 0, 0, ADC_CTL_CH0 | ADC_CTL_IE | ADC_CTL_END); ADCSequenceEnable(ADC0_BASE, 0); ADCIntClear(ADC0_BASE, 0); // Enable the Timer peripheral SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0); // Timer should run periodically TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC); // Set the value that is loaded into the timer everytime it finishes // it's the number of clock cycles it takes till the timer triggers the ADC //#define F_SAMPLE 1000 ui32Period = 120000000/1024000; TimerLoadSet(TIMER0_BASE, TIMER_A, ui32Period-1); // Enable triggering TimerControlTrigger(TIMER0_BASE, TIMER_A, true); ADCIntEnable(ADC0_BASE, 0); // Enable the timer TimerEnable(TIMER0_BASE, TIMER_A); ADCSequenceDMAEnable(ADC0_BASE, 0); uDMAChannelAttributeDisable(UDMA_CHANNEL_ADC0, UDMA_ATTR_ALTSELECT | UDMA_ATTR_USEBURST | UDMA_ATTR_HIGH_PRIORITY | UDMA_ATTR_REQMASK); uDMAChannelControlSet(UDMA_CHANNEL_ADC0 | UDMA_PRI_SELECT, UDMA_SIZE_32 | UDMA_SRC_INC_NONE | UDMA_DST_INC_32 | UDMA_NEXT_USEBURST | UDMA_ARB_1024); uDMAChannelControlSet(UDMA_CHANNEL_ADC0 | UDMA_ALT_SELECT, UDMA_SIZE_32 | UDMA_SRC_INC_NONE | UDMA_DST_INC_32 | UDMA_NEXT_USEBURST | UDMA_ARB_1024); uDMAChannelTransferSet(UDMA_CHANNEL_ADC0 | UDMA_PRI_SELECT, UDMA_MODE_PINGPONG, (void *)(ADC0_BASE + ADC_O_SSFIFO0), g_ui8RxBufA, MEM_BUFFER_SIZE); uDMAChannelTransferSet(UDMA_CHANNEL_ADC0 | UDMA_ALT_SELECT, UDMA_MODE_PINGPONG, (void *)(ADC0_BASE + ADC_O_SSFIFO0), g_ui8RxBufB, MEM_BUFFER_SIZE); uDMAChannelEnable(UDMA_CHANNEL_ADC0); ADCIntEnableEx(ADC0_BASE, ADC_INT_DMA_SS0); IntEnable(INT_ADC0SS0);