Beispiel #1
0
void vInitialiseTimerForIntQueueTest( void )
{
	/* Enable the TC clocks. */
	pmc_enable_peripheral( ID_TC0 );
	pmc_enable_peripheral( ID_TC1 );

	/* Configure TC0 channel 0 for a tmrTIMER_0_FREQUENCY frequency and trigger
	on RC compare. */
	tc_trigger_on_freq( TC0, tmrTC0_CHANNEL_0, tmrTIMER_0_FREQUENCY );
	TC0->TC_CHANNEL[ tmrTC0_CHANNEL_0 ].TC_IER = TC_IER_CPCS;

	/* Configure TC0 channel 1 for a tmrTIMER_1_FREQUENCY frequency and trigger
	on RC compare. */
	tc_trigger_on_freq( TC0, tmrTC0_CHANNEL_1, tmrTIMER_1_FREQUENCY );
	TC0->TC_CHANNEL[ tmrTC0_CHANNEL_1 ].TC_IER = TC_IER_CPCS;

	/* Configure TC1 channel 0 tmrTIMER_2_FREQUENCY frequency and trigger on
	RC compare. */
	tc_trigger_on_freq( TC1, tmrTC1_CHANNEL_0, tmrTIMER_2_FREQUENCY );
	TC1->TC_CHANNEL[ tmrTC1_CHANNEL_0 ].TC_IER = TC_IER_CPCS;

	/* Enable interrupts and start the timers. */
	aic_configure( ID_TC0, tmrLOWER_PRIORITY );
	aic_set_source_vector( ID_TC0, prvTC0_Handler );
	aic_configure( ID_TC1, tmrHIGHER_PRIORITY );
	aic_set_source_vector( ID_TC1, prvTC1_Handler );
	aic_enable( ID_TC0 );
	aic_enable( ID_TC1 );
	tc_start( TC0, tmrTC0_CHANNEL_0 );
	tc_start( TC0, tmrTC0_CHANNEL_1 );
	tc_start( TC1, tmrTC1_CHANNEL_0 );
}
Beispiel #2
0
/**
 *  Configure Timer Counter 0 to generate an interrupt every 250ms.
 */
static void _configure_tc(void)
{
	/** Enable peripheral clock. */
	pmc_enable_peripheral(ID_TC0);

	/* Put the source vector */
	aic_set_source_vector(ID_TC0, _tc_handler);

	/** Configure TC for a 50Hz frequency and trigger on RC compare. */
	tc_trigger_on_freq(TC0, TC_CHANNEL, TC_FREQ);

	/* Configure and enable interrupt on RC compare */
	tc_enable_it(TC0, TC_CHANNEL, TC_IER_CPCS);
	aic_enable(ID_TC0);
}