//! \brief Main Function
int main(int argc, char *argv[])
{
    int cycle_count, size;
    int i;
    struct {
        char menu[25];
        char result[VECT1_SIZE][15];
    } vectors_result;
    /**
     * \note the call to sysclk_init() will disable all non-vital
     * peripheral clocks, except for the peripheral clocks explicitly
     * enabled in conf_clock.h.
     */
    sysclk_init();

    // Initialize the DSP debug USART module when running in external board
#if BOARD != AVR_SIMULATOR_UC3
    dsp_debug_initialization(FOSC0);
#endif

    for (i = 0; i >= 0 && i < (sizeof(item_menu) / sizeof(s_item_menu)); i++) {
        // Call the function to execute
        cycle_count = item_menu[i].action(&size);
        dsp32_debug_sprintf(vectors_result.menu, "%s", item_menu[i].title);
        if (cycle_count != -1) {
            // Print the result
            for (i = 0; i < size; i++) {
                dsp32_debug_sprintf(vectors_result.result[i],"%f", vect1[i]);
            }
            /*
             * Place a breakpoint here and check the ASCII output in
             * vectors_result in Memory Window.
             * Note: Find the variable address in Watch Window and enter it in
             * Memory Window
             */
            asm("nop");
        }
    }

    while (1) {
        // Intentionally left blank.
    }
}
Пример #2
0
// The main function
int main(int argc, char *argv[])
{
	unsigned int cycle_count, i;
	volatile  dsp32_t fft32_max;
	char *temp = " +";
	char complex_vect_result[SIZE][31];

	/**
	 * \note the call to sysclk_init() will disable all non-vital
	 * peripheral clocks, except for the peripheral clocks explicitly
	 * enabled in conf_clock.h.
	 */
	sysclk_init();

	// Initialize the DSP debug USART module when running in external board
#if BOARD != AVR_SIMULATOR_UC3
	dsp_debug_initialization(FOSC0);
#endif

	// Get the actual cycle count
	cycle_count = Get_sys_count();
	// Perform a 64-point complex FFT
	dsp32_trans_realcomplexfft(vect1, vect2, NLOG);
	// Perform the absolute value of a complex vector
	dsp32_vect_complex_abs(fft_real, vect1, SIZE);
	// Retrieves the maximum of a vector
	fft32_max = dsp32_vect_max(fft_real, SIZE);

	// Calculate the number of cycles the FFT took
	cycle_count = Get_sys_count() - cycle_count;

	// Print the  output signal
	for (i = 0; i < SIZE; i++) {
		if (vect1[i].imag >= 0) {
			temp = " +";
		} else {
			temp = " ";
		}
		dsp32_debug_sprintf(complex_vect_result[i],"%f%s%f", vect1[i].real,
				temp,vect1[i].imag);
	}
	/*
	 * Place a breakpoint here and check ASCII output in complex_vect_result
	 * in Memory Window.
	 * Note: Find the variable address in Watch Window and enter it in
	 * Memory Window
	 */

	while (1) {
		// Intentionally left blank.
	}
}
// The main function
int main(int argc, char *argv[])
{
	dsp32_t sample_x,sample_d;
	dsp32_t y, e;
	int i;
	char lms_vect_result[FIR_COEF_SIZE][15];

	/**
	 * \note the call to sysclk_init() will disable all non-vital
	 * peripheral clocks, except for the peripheral clocks explicitly
	 * enabled in conf_clock.h.
	 */
	sysclk_init();

	// Initialize the DSP debug USART module when running in external board
#if BOARD != AVR_SIMULATOR_UC3
	dsp_debug_initialization(FOSC0);
#endif

	// Initialization of the buffers
	for (i = 0; i < FIR_COEF_SIZE; i++) {
		w[i] = 0;
		x[i] = 0;
	}

	for (i = 0; i < SIZE; i++) {
		// Compute a new sample
		sample_x = input_x[i];
		sample_d = input_d[i];
		// Compute the LMS filter
		dsp32_filt_lms(x, w, FIR_COEF_SIZE, sample_x, sample_d, &y, &e);
	}

	// Print the  output signal
	for (i = 0; i < FIR_COEF_SIZE; i++) {
		dsp32_debug_sprintf(lms_vect_result[i],"%f", w[i]);
	}
	/*
	 * Place a breakpoint here and check the ASCII output in lms_vect_result
	 * in Memory Window.
	 * Note: Find the variable address in Watch Window and enter it in
	 * Memory Window
	 */

	while (1) {
		// Intentionally left blank.
	}
}
Пример #4
0
//! The main function
int main(int argc, char *argv[])
{
	unsigned int cycle_count, i;
	char fir_vect_result[SIZE][15];

	/**
	 * \note the call to sysclk_init() will disable all non-vital
	 * peripheral clocks, except for the peripheral clocks explicitly
	 * enabled in conf_clock.h.
	 */
	sysclk_init();

	// Initialize the DSP debug USART module when running in external board
#if BOARD != AVR_SIMULATOR_UC3
	dsp_debug_initialization(FOSC0);
#endif

	// Get the actual cycle count
	cycle_count = Get_sys_count();

	// Perform a 25-taps FIR
	dsp32_filt_fir(y, x, SIZE, fir_coef, FIR_COEF_SIZE);

	// Calculate the number of cycles
	cycle_count = Get_sys_count() - cycle_count;

	// Print the  output signal
	for (i = 0; i < SIZE; i++) {
		dsp32_debug_sprintf(fir_vect_result[i],"%f", y[i]);
	}
	/*
	 * Place a breakpoint here and check the ASCII output in fir_vect_result
	 * in Memory Window.
	 * Note: Find the variable address in Watch Window and enter it in
	 * Memory Window
	 */

	while (1) {
		// Intentionally left blank.
	}
}
//! The main function
int main(int argc, char *argv[])
{
	int i;
	char iir_vect_result[SIZE][15];

	/**
	 * \note the call to sysclk_init() will disable all non-vital
	 * peripheral clocks, except for the peripheral clocks explicitly
	 * enabled in conf_clock.h.
	 */
	sysclk_init();

	// Initialize the DSP debug USART module when running in external board
#if BOARD != AVR_SIMULATOR_UC3
	dsp_debug_initialization(FOSC0);
#endif

	// Number of recursions - Reduced to 5 decrease the time in Simulator
	for (i = 0; i < 5; i++) {
		// Perform a IIR filter
		dsp32_filt_iir(&y[DEN_SIZE], &x[NUM_SIZE - 1], SIZE, num, NUM_SIZE,
				den, DEN_SIZE, NUM_PREDIV, DEN_PREDIV);
		// Update the output signal
		memmove(y, &y[SIZE], (DEN_SIZE)*sizeof(dsp32_t));
	}
	// Print the  output signal
	for (i = 0; i < SIZE; i++) {
		dsp32_debug_sprintf(iir_vect_result[i],"%f", y[i]);
	}
	/*
	 * Place a breakpoint here and check the ASCII output in iir_vect_result
	 * in Memory Window.
	 * Note: Find the variable address in Watch Window and enter it in
	 * Memory Window
	 */

	while (1) {
		// Intentionally left blank.
	}
}
Пример #6
0
//! The main function
int main(int argc, char *argv[])
{
	dsp32_t number, result;
	int cycle_count;
	char sin_result[50], cos_result[50], asin_result[50], acos_result[50],
			rand_result[50], sqrt_result[50], abs_result[50], ln_result[50],
			log2_result[50], log10_result[50], exp_result[50], pow_result[50];
	/**
	 * \note the call to sysclk_init() will disable all non-vital
	 * peripheral clocks, except for the peripheral clocks explicitly
	 * enabled in conf_clock.h.
	 */
	sysclk_init();

	// Initialize the DSP debug USART module when running in external board
#if BOARD != AVR_SIMULATOR_UC3
	dsp_debug_initialization(FOSC0);
#endif

	number = DSP32_Q(NUMBER_TO_COMPUTE);
	/*
	 * Place a breakpoint on sprintf and check the ASCII output in
	 * %operator%_result in Watch Window or Memory Window.
	 * Note: Edit the variable name in Watch Window and append
	 * "&" at the start and ",s" at the end for displaying string.
	 * Read Watch Window Format Specifiers for more info.
	 */
	// 32-bit fixed point cosine
	cycle_count = Get_sys_count();
	result = dsp32_op_cos(number);
	cycle_count = Get_sys_count() - cycle_count;
	dsp32_debug_sprintf(cos_result, "cos(%f) %f (%i cycles)\n", number,
			result, cycle_count);

	// 32-bit fixed point sine
	cycle_count = Get_sys_count();
	result = dsp32_op_sin(number);
	cycle_count = Get_sys_count() - cycle_count;
	dsp32_debug_sprintf(sin_result, "sin(%f) %f (%i cycles)\n", number,
			result, cycle_count);

	// 32-bit fixed point arc cosine
	cycle_count = Get_sys_count();
	result = dsp32_op_acos(number);
	cycle_count = Get_sys_count() - cycle_count;
	dsp32_debug_sprintf(acos_result, "acos(%f) %f (%i cycles)\n", number,
			result, cycle_count);

	// 32-bit fixed point arc sine
	cycle_count = Get_sys_count();
	result = dsp32_op_asin(number);
	cycle_count = Get_sys_count() - cycle_count;
	dsp32_debug_sprintf(asin_result, "asin(%f) %f (%i cycles)\n", number,
			result, cycle_count);

	// 32-bit fixed point random
	dsp_op_srand(number);
	cycle_count = Get_sys_count();
	result = dsp32_op_rand();
	cycle_count = Get_sys_count() - cycle_count;
	dsp32_debug_sprintf(rand_result, "rand() %f (%i cycles)\n", result,
			cycle_count);

	// 32-bit fixed point square root
	cycle_count = Get_sys_count();
	result = dsp32_op_sqrt(number);
	cycle_count = Get_sys_count() - cycle_count;
	dsp32_debug_sprintf(sqrt_result, "sqrt(%f) %f (%i cycles)\n", number,
			result, cycle_count);

	// 32-bit fixed point absolute
	cycle_count = Get_sys_count();
	result = dsp32_op_abs(number);
	cycle_count = Get_sys_count() - cycle_count;
	dsp32_debug_sprintf(abs_result, "abs(%f) %f (%i cycles)\n", number,
			result, cycle_count);

	// 32-bit fixed point natural logarithm
	cycle_count = Get_sys_count();
	result = dsp32_op_ln(number);
	cycle_count = Get_sys_count() - cycle_count;
	dsp32_debug_sprintf(ln_result, "ln(%f) %f (%i cycles)\n", number,
			result, cycle_count);

	// 32-bit fixed point binary logarithm
	cycle_count = Get_sys_count();
	result = dsp32_op_log2(number);
	cycle_count = Get_sys_count() - cycle_count;
	dsp32_debug_sprintf(log2_result, "log2(%f) %f (%i cycles)\n", number,
			result, cycle_count);

	// 32-bit fixed point common logarithm
	cycle_count = Get_sys_count();
	result = dsp32_op_log10(number);
	cycle_count = Get_sys_count() - cycle_count;
	dsp32_debug_sprintf(log10_result, "log10(%f) %f (%i cycles)\n", number,
			result, cycle_count);

	// 32-bit fixed point exponential
	cycle_count = Get_sys_count();
	result = dsp32_op_exp(number);
	cycle_count = Get_sys_count() - cycle_count;
	dsp32_debug_sprintf(exp_result, "exp(%f) %f (%i cycles)\n", number,
			result, cycle_count);

	// 32-bit fixed point power
	cycle_count = Get_sys_count();
	result = dsp32_op_pow(DSP32_Q(0.), number);
	cycle_count = Get_sys_count() - cycle_count;
	dsp32_debug_sprintf(pow_result, "pow(0.5, %f) %f (%i cycles)\n", number,
			result, cycle_count);

	while (1) {
		// Intentionally left blank.
	}
}