Hi all,
Iam using TM4C1294XL launchpad and Iam trying to implement low pass filter function of CMSIS DSP Library.
I'am facing an issue of sending the filter output continuously via UART to another TM4C129x MCU which is running the TFT. I'am able to implement the filter but the data is being sent block by block to the other MCU due to which I'am getting unexpected results.
Iam using timer to trigger the ADC @ sampling rate of 256Hz.
Input signal is sine wave with varying frequency between10-50Hz and the cutoff frequency is 30Hz.
Below is the while(1) loop of my code for reading ADC & sending filter data.I've also attached the screen shot of the data plotting on TFT using Graphics library. It can be seen that the sine wave is not continuous.
Kindly help me to sort this issue
float32_t p[256];
#define TEST_LENGTH_SAMPLES 256
#define BLOCK_SIZE 128
#define NUM_TAPS 29
static float32_t firStateF32[BLOCK_SIZE + NUM_TAPS - 1];
float32_t testOutput[TEST_LENGTH_SAMPLES];
float32_t inputsamples[TEST_LENGTH_SAMPLES];
arm_fir_instance_f32 S;
float32_t *inputF32, *outputF32;
uint32_t blockSize = BLOCK_SIZE;
uint32_t numBlocks = TEST_LENGTH_SAMPLES/BLOCK_SIZE;
void Timer0IntHandler(void)
{
TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
ADCSequenceConfigure(ADC0_BASE, 1, ADC_TRIGGER_TIMER, 0);
}
int main(void)
{
FPULazyStackingEnable();
FPUEnable();
uint32_t ui32Period;
uint32_t l=0;
int32_t CH1DATA ;
inputF32 = &inputsamples[0];
outputF32 = &testOutput[0];
ui32SysClkFreq= SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000);
********************ALL INITIALIZATION CODE OMITTED TO BE SPECIFIC TO THE ISSUE*********
while(1)
{
ADCIntClear(ADC0_BASE, 1);
while(!ADCIntStatus(ADC0_BASE, 1, false))
{
}
ADCSequenceDataGet(ADC0_BASE, 1, ui32ADC0Value);
if(l==256)
{
l=0;
arm_fir_init_f32(&S, NUM_TAPS, (float32_t *)&firCoeffs32[0], &firStateF32[0], blockSize);
for(i=0; i < numBlocks; i++)
{
arm_fir_f32(&S, inputF32 + (i * blockSize), outputF32 + (i * blockSize), blockSize);
}
}
p[l] = (float32_t)ui32ADC0Value[0];
p[l] = p[l] - (float32_t)0x0810;
inputsamples[l]= p[l];
UARTCharPutNonBlocking(UART6_BASE,'a'); // To tell the other MCU to start plotting the incoming data.
CH1DATA= (int32_t)testOutput[l]+ (int32_t)0x0810;
al = CH1DATA & 0xF00;
al = al>>8;
ah = CH1DATA & 0xFF;
UARTCharPutNonBlocking(UART6_BASE,ah);
UARTCharPutNonBlocking(UART6_BASE,al);
l=l+1;
}
}