예제 #1
0
//! [setup]
int main(void)
{
	//! [setup_init]
	system_init();
	configure_ac();
	configure_ac_channel();
	configure_ac_callback();

	//! [setup_17]
	ac_enable(&ac_instance);
	//! [setup_17]
	//! [setup_init]

	//! [main]
	//! [main_1]
	ac_chan_trigger_single_shot(&ac_instance, AC_COMPARATOR_CHANNEL);
	//! [main_1]

	//! [main_2]
	uint8_t last_comparison = AC_CHAN_STATUS_UNKNOWN;
	//! [main_2]
	port_pin_set_output_level(LED_0_PIN, true);
	//! [main_3]
	while (true) {
	//! [main_3]
	//! [main_4]
		if (callback_status == true) {
	//! [main_4]
			//! [main_5]
			do
			{
				last_comparison = ac_chan_get_status(&ac_instance,
						AC_COMPARATOR_CHANNEL);
			} while (last_comparison & AC_CHAN_STATUS_UNKNOWN);
			//! [main_5]
			//! [main_6]
			port_pin_set_output_level(LED_0_PIN,
					(last_comparison & AC_CHAN_STATUS_NEG_ABOVE_POS));
			//! [main_6]
			//! [main_7]
			callback_status = false;
			//! [main_7]
			//! [main_8]
			ac_chan_trigger_single_shot(&ac_instance, AC_COMPARATOR_CHANNEL);
			//! [main_8]
		}
	}
	//! [main]
}
예제 #2
0
void config_ramp2c(void)
{
#if (ENABLE_FAULT_BALNKING == true)	
	configure_eic();
	configure_ac();
#endif	
	configure_tcc_ramp2c_mode();
	
#if (ENABLE_FAULT_BALNKING == true)	
	configure_evsys();	
	
	PORT->Group[0].DIRSET.reg = PORT_PA14;
	PORT->Group[0].OUTCLR.reg = PORT_PA14;
	
	TCC0->INTENSET.reg = TCC_INTFLAG_MC1;
	
	NVIC_EnableIRQ(TCC0_IRQn);
	__enable_irq();	
#endif
	
}