//! The main function
int main(int argc, char *argv[])
{
  dsp32_t vect1[SIZE];
  int cycle_count;
  int frequency, sample_rate;
  dsp32_t phase, amplitude;

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

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

  // 1 KHz
  frequency = 1000;
  // 10 KHz
  sample_rate = 100000;
  // phase = PI/2
  phase = DSP32_Q(0.5);
  // amplitude
  amplitude = DSP32_Q(1.);

  dsp32_debug_printf("32-bit signal generation program test\n");

  // Compute the signal to generate
  switch(SIGNAL_TO_USE)
  {
  // Sinusoidal
  case SIGNAL_SIN:
    dsp32_debug_printf("Sine\n");
    dsp32_debug_printf("Frequency: %d, Fs: %d, Phase: %f\n", frequency, sample_rate, phase);
    cycle_count = Get_sys_count();
    dsp32_gen_sin(vect1, SIZE, frequency, sample_rate, phase);
    cycle_count = Get_sys_count() - cycle_count;
    break;
  // Cosinusoidal
  case SIGNAL_COS:
    dsp32_debug_printf("Cosine\n");
    dsp32_debug_printf("Frequency: %d, Fs: %d, Phase: %f\n", frequency, sample_rate, phase);
    cycle_count = Get_sys_count();
    dsp32_gen_cos(vect1, SIZE, frequency, sample_rate, phase);
    cycle_count = Get_sys_count() - cycle_count;
    break;
  // Noise
  case SIGNAL_NOISE:
    dsp32_debug_printf("Noise\n");
    dsp32_debug_printf("Amplitude: %d\n", amplitude);
    cycle_count = Get_sys_count();
    dsp32_gen_noise(vect1, SIZE, amplitude);
    cycle_count = Get_sys_count() - cycle_count;
    break;
  }

  // Print the number of cycles
  dsp32_debug_printf("Cycle count: %d\n", cycle_count);
  // Print the signal
  dsp32_debug_print_vect(vect1, SIZE);

  while(1);
}
Example #2
0
//! The main function
int main(int argc, char *argv[])
{
  unsigned int cycle_count;

  // 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 convolution
  dsp32_vect_conv(vect1, vect2, VECT2_SIZE, vect3, VECT3_SIZE);

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

  // Print the number of cycles
  dsp32_debug_printf("Cycle count: %d\n", cycle_count);
  // Print the  output signal
  dsp32_debug_print_vect(vect1, VECT2_SIZE + VECT3_SIZE - 1);

  while(1);
}
Example #3
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);
}
Example #4
0
//! The main function
int main(int argc, char *argv[])
{
  unsigned int cycle_count;

  // 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 25-taps FIR
  dsp32_filt_iirpart(y, x, SIZE, num, NUM_SIZE, den, DEN_SIZE, PREDIV, PREDIV);

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

  // Print the number of cycles
  dsp32_debug_printf("Cycle count: %d\n", cycle_count);

  // Print the  output signal
  dsp32_debug_print_vect(y, SIZE - NUM_SIZE + 1);

  while(1);
}
Example #5
0
//! The main function
int main(int argc, char *argv[])
{
  dsp32_t number, result;
  int cycle_count;

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

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

  dsp32_debug_printf("32-bit fixed point operators program test\n");

  dsp32_debug_printf("Type a number: ");
  number = dsp_debug_read_q(DSP32_QA, DSP32_QB);

  dsp32_debug_printf("Number to compute: %f\n", number);

  // 32-bit fixed point cosine
  cycle_count = Get_sys_count();
  result = dsp32_op_cos(number);
  cycle_count = Get_sys_count() - cycle_count;
  dsp32_debug_printf("cos(%f)\t\t%f\t(%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_printf("sin(%f)\t\t%f\t(%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_printf("acos(%f)\t\t%f\t(%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_printf("asin(%f)\t\t%f\t(%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_printf("rand()\t\t\t\t%f\t(%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_printf("sqrt(%f)\t\t%f\t(%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_printf("abs(%f)\t\t%f\t(%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_printf("ln(%f)\t\t%f\t(%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_printf("log2(%f)\t\t%f\t(%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_printf("log10(%f)\t\t%f\t(%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_printf("exp(%f)\t\t%f\t(%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_printf("pow(0.5, %f)\t\t%f\t(%i cycles)\n", number, result, cycle_count);

  while(1);
}