Пример #1
0
int main(void)
{
	const usart_serial_options_t usart_serial_options = {
		.baudrate   = CONF_TEST_BAUDRATE,
		.charlength = CONF_TEST_CHARLENGTH,
		.paritytype = CONF_TEST_PARITY,
		.stopbits   = CONF_TEST_STOPBITS,
	};
	uint16_t volts_values[3][NB_VALUE];
	int16_t volt_output;
	uint8_t i;

	/* Usual initializations */
	board_init();
	sysclk_init();
	sleepmgr_init();
	irq_initialize_vectors();
	cpu_irq_enable();
	stdio_serial_init(CONF_TEST_USART, &usart_serial_options);

	printf("\x0C\n\r-- ADC Calibration and averaging example");
	printf("  (Compiled: %s %s)\n\r", __DATE__, __TIME__);

	/* ADC and DAC initializations */
	main_dac_init();
	main_adc_init();

	/* Conversions without averaging and without corrections */
	main_conversions(volts_values[0]);
	/* Enable averaging */
	main_adc_averaging();
	/* Conversions with averaging and without corrections */
	main_conversions(volts_values[1]);
	/* Measure and enable corrections */
	main_adc_correction();
	/* Conversions with averaging and with corrections */
	main_conversions(volts_values[2]);

	/* Display values */
	printf("| ADC input | ADC res. |  Delta  | Averaging |  Delta  | Aver.+Corr. |  Delta  |\n\r");
	volt_output = -CONV_MAX_VOLTAGE;
	for (i = 0; i < NB_VALUE; i++) {
		printf("|  %5d mV | %5d mV | %4d mV |  %5d mV | %4d mV |   %5d mV  | %4d mV |\n\r",
				volt_output,
				volts_values[0][i], volts_values[0][i] - volt_output,
				volts_values[1][i], volts_values[1][i] - volt_output,
				volts_values[2][i], volts_values[2][i] - volt_output);
		volt_output += CONV_VOLTAGE_STEP;
	}

	while (1) {
	}
}
int main(void)
{
	const usart_serial_options_t usart_serial_options = {
		.baudrate   = CONF_TEST_BAUDRATE,
		.charlength = CONF_TEST_CHARLENGTH,
		.paritytype = CONF_TEST_PARITY,
		.stopbits   = CONF_TEST_STOPBITS,
	};

	/* Usual initializations */
	board_init();
	sysclk_init();
	sleepmgr_init();
	irq_initialize_vectors();
	cpu_irq_enable();
	stdio_serial_init(CONF_TEST_USART, &usart_serial_options);

	printf("\x0C\n\r-- ADC Calibration Example");
	printf("  (Compiled: %s %s)\n\r", __DATE__, __TIME__);

	/* ADC and DAC initializations */
	main_dac_init();
	main_adc_init();

	printf("\n\rConversion samples without correction:\n\r");
	main_conversions();

	/* Measure and enable corrections */
	main_adc_correction();

	printf("Conversion samples with correction:\n\r");
	main_conversions();

	while (1) {
	}
}