Fastest Arduino DUE timer interrupts?
so found code on here utilizing due's timers create interrupt. after messing around see how fast can due flip portd values, switching high low on 1 pin @ 680.0 nanoseconds. wondering if there faster way this?
i have attached code , pasted below. apologize in advance if didn't provide enough information , simple copy , paste of code below. first post.
void setup() {
// put setup code here, run once:
pinmode(14, output);
pinmode(9, output);
reg_piod_ower = 0x0060;
starttimer(tc1,0,tc3_irqn, 100000);
}
void tc3_handler(){
tc_getstatus(tc1, 0);
reg_piod_odsr = reg_piod_odsr ^ 0x00000010;
}
void loop() {
}
void starttimer(tc *tc, uint32_t channel, irqn_type irq, uint32_t frequency){
//enable or disable write protect of pmc registers.
pmc_set_writeprotect(false);
//enable specified peripheral clock.
pmc_enable_periph_clk((uint32_t)irq);
tc_configure(tc, channel,tc_cmr_wave|tc_cmr_wavsel_updown_rc|tc_cmr_tcclks_timer_clock1);//|tc_cmr_cpcstop);
uint32_t rc = 1;//variant_mck/128/frequency;
tc_setra(tc, channel, rc);
tc_setrc(tc, channel, rc);
tc_start(tc, channel);
tc->tc_channel[channel].tc_ier = tc_ier_cpcs;
tc->tc_channel[channel].tc_idr = ~tc_ier_cpcs;
nvic_enableirq(irq);
}
i have attached code , pasted below. apologize in advance if didn't provide enough information , simple copy , paste of code below. first post.
void setup() {
// put setup code here, run once:
pinmode(14, output);
pinmode(9, output);
reg_piod_ower = 0x0060;
starttimer(tc1,0,tc3_irqn, 100000);
}
void tc3_handler(){
tc_getstatus(tc1, 0);
reg_piod_odsr = reg_piod_odsr ^ 0x00000010;
}
void loop() {
}
void starttimer(tc *tc, uint32_t channel, irqn_type irq, uint32_t frequency){
//enable or disable write protect of pmc registers.
pmc_set_writeprotect(false);
//enable specified peripheral clock.
pmc_enable_periph_clk((uint32_t)irq);
tc_configure(tc, channel,tc_cmr_wave|tc_cmr_wavsel_updown_rc|tc_cmr_tcclks_timer_clock1);//|tc_cmr_cpcstop);
uint32_t rc = 1;//variant_mck/128/frequency;
tc_setra(tc, channel, rc);
tc_setrc(tc, channel, rc);
tc_start(tc, channel);
tc->tc_channel[channel].tc_ier = tc_ier_cpcs;
tc->tc_channel[channel].tc_idr = ~tc_ier_cpcs;
nvic_enableirq(irq);
}
that sounds entirely plausible, given overhead of calling interrupt routine.
what trying do?
what trying do?
Arduino Forum > Products > Arduino Due (Moderator: fabioc84) > Fastest Arduino DUE timer interrupts?
arduino
Comments
Post a Comment