Sam3x8e Adc Timer trigger mode for 1us

Discussion around product based on ARM Cortex M3 core.

Moderators: nferre, ncollot

pravin0103bsc
Posts: 22
Joined: Tue Dec 17, 2013 6:36 am

Sam3x8e Adc Timer trigger mode for 1us

Mon Jun 02, 2014 10:43 am

hi,

 Any can help me in configuring  Adc running in timer trigger mode (1us trigger time)
 i already have sample code which works with 1hz(1sec).. how to reconfigure timer to 1us trigger please kindly show me the idea in the below code

 

Code: Select all

static void configure_time_trigger(void)
{
	uint32_t ul_div = 0;
	uint32_t ul_tc_clks = 0;
	uint32_t ul_sysclk = sysclk_get_cpu_hz();




	/* Enable peripheral clock. */
	pmc_enable_periph_clk(ID_TC0);




	/* TIOA configuration */
	gpio_configure_pin(PIN_TC0_TIOA0, PIN_TC0_TIOA0_FLAGS);




	/* Configure TC for a 1Hz frequency and trigger on RC compare. */
	tc_find_mck_divisor(1, ul_sysclk, &ul_div, &ul_tc_clks, ul_sysclk);
	tc_init(TC0, 0, ul_tc_clks | TC_CMR_CPCTRG | TC_CMR_WAVE |
			TC_CMR_ACPA_CLEAR | TC_CMR_ACPC_SET);
	TC0->TC_CHANNEL[0].TC_RA = (ul_sysclk / ul_div) / 2;
	TC0->TC_CHANNEL[0].TC_RC = (ul_sysclk / ul_div) / 1;




	/* Start the Timer. */
	tc_start(TC0, 0);
	/* Set TIOA0 trigger. */
#if SAM3S || SAM3N || SAM3XA || SAM4S
	adc_configure_trigger(ADC, ADC_TRIG_TIO_CH_0, 0);
#elif SAM3U
#ifdef ADC_12B
	adc12b_configure_trigger(ADC12B, ADC12B_TRIG_TIO_CH_0);
#else
	adc_configure_trigger(ADC, ADC_TRIG_TIO_CH_0);
#endif
#endif
}

Thanks
Pravin

Return to “SAM3 Cortex-M3 MCU”

Who is online

Users browsing this forum: Google [Bot] and 1 guest