cic_process

Resampling and filtering of a signal

Calling sequence

`[cic,y] = cic_process(cic, x)`

Parameters

cic:

CIC filter object, as created by cic_init

x:

input signal (1d column vector), sampled at frequency y:

output signal (1d column vector), sampled at frequency (for decimation) or (for upsampling)

Description

This function take as input 1d vector `x` of size , and outputs about (if a decimating filter was configured) or (if an upsampling filter was configured) samples in the vector `y`. The context is saved in the `cic` object.

Before computing, the input vector `x` will be truncated as a `int32` vector, as a CIC filter can only process integer or fixed point samples (no floating point). So, it is recommended to scale accordingly the data before calling the filter.

Example 1: decimation

 ```// Input sampling frequency = 10 MHz fs = 10e6; // Decimate by 16 (e.g. output sample frequency = 625 KHz) R = 16; N = 4; // Creation of the CIC filter cic = cic_init(R, N); ; // Build a signal which is the superposition of 2 pure sine wave: // - one at 2 MHz // - one at 20 KHz t = (0:1/fs:1e-3); // 1 ms time slot f1 = 2e6; f2 = 20e3; x = sin(t*2*%pi*f1) + sin(t*2*%pi*f2); // Scale the data to 16 bit precision x = int32(x * 32768); // Decimation by ratio 1/R [cic,xd] = cic_process(cic,x);``` Input and output of the CIC decimation filter (note the disparition of the high frequency component in the output).

Example 2: upsampling

 ```// Upsample by 16 (e.g. output sample frequency = 625 KHz) R = 16; N = 4; fs = (10e6)/R; // Input sampling frequency = 10 MHz / 16 // Creation of the CIC filter cic = cic_init(R, N, 1, 'u'); // Build a signal pure sine wave at 50 KHz t = ((0:1/fs:1e-4))'; // 100 µs time slot f = 50e3; x = 32768 * sin(t*2*%pi*f); ; // Upsampling by ratio R [cic,xd] = cic_process(cic,x);``` Input and output of the CIC upsampling (interpolation) filter.