Example #1
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
  dsp16_filt_fir(y, x, SIZE, fir_coef, FIR_COEF_SIZE);

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

  // Print the number of cycles
  dsp16_debug_printf("Cycle count: %d\n", cycle_count);
  // Print the  output signal
  dsp16_debug_print_vect(y, SIZE - FIR_COEF_SIZE + 1);

  while(1);
}
Example #2
0
void dac_reload_callback(void)
{
	int i;

	if (current_stereo_out_buf == stereo_out_buf1)
		current_stereo_out_buf = stereo_out_buf2;
	else
		current_stereo_out_buf = stereo_out_buf1;

	generate_signal(signal1_buf, &signal1_generator);
	generate_signal(signal2_buf, &signal2_generator);

	/* In order for the FIR filter to work correctly we need to keep
	 * the last part of the previous buffer */
	for (i = 0; i < FIR_NUM_COEF; i++) {
		signal_pre_filter_buf[i] =
				signal_pre_filter_buf[BUFFER_LENGTH + i];
	}

	/* New data is put in the signal_in_buf which points behind the data
	 * kept from the previous buffer */
	dsp16_vect_add_and_sat(signal_in_buf, signal1_buf, signal2_buf,
			BUFFER_LENGTH);

	/* Run the FIR filter; the input buffer will be ... longer then the
	 * output buffer, which has normal length */
	if (active_filter > 0) {
		dsp16_filt_fir(signal_out_buf, signal_pre_filter_buf,
				BUFFER_LENGTH + FIR_NUM_COEF - 1,
				filter_coef[active_filter - 1], FIR_NUM_COEF);
	} else {
		for (i = 0; i < BUFFER_LENGTH; i++)
			signal_out_buf[i] = signal_in_buf[i];
	}

	for (i = 0; i < BUFFER_LENGTH; i++) {
		current_stereo_out_buf[i*2] = signal_out_buf[i];
		current_stereo_out_buf[i*2+1] = signal_out_buf[i];
	}

	signals_are_updated = 1;

	/* Update PDCA buffer */
	tpa6130_dac_output(current_stereo_out_buf, BUFFER_LENGTH);
}