#include "arm_math.h"
#include "MM32L0xx.h"
#include "math.h"
#define M_PI 3.1415926
#define NUM_TAPS 29
#define BLOCK_SIZE 32
#define LEN_OF_SIG 320
extern uint32_t SystemCoreClock;
volatile uint32_t ticks=0;
uint32_t numBlocks=LEN_OF_SIG/BLOCK_SIZE;
uint32_t blockSize=32;
static float32_t x[LEN_OF_SIG];
static float32_t y[LEN_OF_SIG];
static float32_t firStateF32[BLOCK_SIZE+NUM_TAPS-1];
const float32_t coeffs[29] = {
-0.001822523074,-0.001587929321,1.226008847e-018, 0.003697750857, 0.008075430058,
0.008530221879,-4.273456581e-018, -0.01739769801, -0.03414586186, -0.03335915506,
8.073562366e-018, 0.06763084233, 0.1522061825, 0.2229246944, 0.2504960895,
0.2229246944, 0.1522061825, 0.06763084233,8.073562366e-018, -0.03335915506,
-0.03414586186, -0.01739769801,-4.273456581e-018, 0.008530221879, 0.008075430058,
0.003697750857,1.226008847e-018,-0.001587929321,-0.001822523074
};
void SysTick_init()
{
if (SysTick_Config(SystemCoreClock / 10000))
{
/* Capture error */
while (1);
}
/* Configure the SysTick handler priority */
NVIC_SetPriority(SysTick_IRQn, 0x0);//SysTick中断优先级设置
}
void SysTick_Handler(void)
{
ticks++;
}
static void arm_fir_f32_lp(void)
{
uint32_t i=0;
arm_fir_instance_f32 S;
float32_t *input,*output;
input=&x[0];
output=&y[0];
arm_fir_init_f32(&S,NUM_TAPS,(float32_t *)&coeffs[0],&firStateF32[0],blockSize);
for(i=0;i<numBlocks;i++)
{
arm_fir_f32(&S,input+(i*blockSize),output+(i*blockSize),blockSize);
}
}
int main(void)
{
uint32_t i=0;
for(i=0;i<LEN_OF_SIG;i++)
{
x[i]=sin(2.0*M_PI*20*i/LEN_OF_SIG);
}
while(1)
{
arm_fir_f32_lp();
}
}
|