Page 1 of 1

SAML21 External Interrupt Speed

Posted: Wed Dec 07, 2016 6:29 pm
by Valueduser
Hi All,

I'm sending a 25kHz square wave to a SAML21J18B chip (Saml21 Xplained pro board). I have external interrupts set to trigger on the rising edge and my ISR is advancing a counter on each received clock. The problem is, this only is working a very slow speeds. When I try bumping things up towards my 25kHz target, the ISR is not triggering correctly.

I am using ASF v. 3.31. I thought that It may be an issue with the EIC Controller Clock source so I added some code to change the clock source, but it still isn't working. Any Suggestion as to what may be happening here would be greatly appreciated. Posted below are snippets of my code:

Code: Select all

void configure_extint_channel(void)
{
	struct extint_chan_conf config_extint_chan;
	extint_chan_get_config_defaults(&config_extint_chan);
	config_extint_chan.gpio_pin           = PIN_PA03A_EIC_EXTINT3;
	config_extint_chan.gpio_pin_mux       = PINMUX_PA03A_EIC_EXTINT3;
	config_extint_chan.gpio_pin_pull      = EXTINT_PULL_UP;
	config_extint_chan.detection_criteria = EXTINT_DETECT_RISING;
	extint_chan_set_config(3, &config_extint_chan);
}

void configure_extint_callbacks(void)
{
	extint_register_callback(extint_detection_callback,3,EXTINT_CALLBACK_TYPE_DETECT);
	extint_chan_enable_callback(3,EXTINT_CALLBACK_TYPE_DETECT);
}
void extint_detection_callback(void)
{
	bit_count++;
}
void configure_gclock_generator(void)
{
	struct system_gclk_gen_config gclock_gen_conf;
	system_gclk_gen_get_config_defaults(&gclock_gen_conf);
	gclock_gen_conf.source_clock    = SYSTEM_CLOCK_SOURCE_OSC16M;
	gclock_gen_conf.division_factor = 2;
	system_gclk_gen_set_config(GCLK_GENERATOR_1, &gclock_gen_conf);
	system_gclk_gen_enable(GCLK_GENERATOR_1);
}
void configure_gclock_channel(void)
{
	struct system_gclk_chan_config gclk_chan_conf;
	system_gclk_chan_get_config_defaults(&gclk_chan_conf);
	gclk_chan_conf.source_generator = GCLK_GENERATOR_1;
	system_gclk_chan_set_config(EIC_GCLK_ID, &gclk_chan_conf);
	system_gclk_chan_enable(EIC_GCLK_ID);
}
int main(void)
{
	/* Initialize the SAM system */
	system_init();
        configure_gclock_generator();
	configure_gclock_channel();
	configure_extint_channel();
	configure_extint_callbacks();
      
        while(1){}
}