예제 #1
0
//! The main function
int main(int argc, char *argv[])
{
  unsigned int cycle_count;
  volatile  dsp32_t fft32_max;

    // Switch to external Oscillator 0.
  pm_switch_to_osc0(&AVR32_PM, FOSC0, OSC0_STARTUP);

    // Initialize the DSP debug module
  dsp_debug_initialization(FOSC0);

    // 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 number of cycles
  dsp32_debug_printf("Cycle count: %d\n", cycle_count);
    // Print the complex FFT output signal
  dsp32_debug_print_complex_vect(vect1, SIZE);

  while(1);
}
예제 #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.
	}
}
/**
 * \brief Function to find Vector Maximum
 * \param size Pointer to store output Vector Size
 */
int maximum(int *size)
{
    int cycle_count;

    // Conditions
    CHECK_CONDITIONS(VECT1_SIZE > 0)
    CHECK_CONDITIONS(VECT2_SIZE > 0)

    *size = 1;

    cycle_count = Get_sys_count();
    vect1[0] = dsp32_vect_max(vect2, VECT2_SIZE);

    return Get_sys_count() - cycle_count;
}