Altera_Forum
Honored Contributor
12 years agoprinciple of acquisition f=10MHz signal with nios software
Hi,
i'm working on nios and i would like to acquire a signal that f=10MHz. I've a clock turning on 100MHz. I've tried many ways such as getting signal from main function. But the frequency that main function is called is not more than 300kHz. The other way was using an interruption with timer. But i can't understand the principle of timer, because it just interrupts main function while the counter reaches 0. So main function will not detect it because of it's frequency which is slower than timer's.
int main(){
IOWR_ALTERA_AVALON_TIMER_PERIODL(TIMER_0_BASE, 0xa); --100MHz/10MHz=10=0xa
IOWR_ALTERA_AVALON_TIMER_PERIODH(TIMER_0_BASE, 0);
//set RUN, set CONTuous, set ITO
IOWR_ALTERA_AVALON_TIMER_CONTROL(TIMER_0_BASE, 7);
//register the interrupt (and turn it on)
alt_irq_register(TIMER_0_IRQ, (volatile int*)&flag, timer_isr);
while(){
}
}
static int timer_isr(volatile int* context, alt_u32 id){ --i've changed static void to static int to be able to write outport
IOWR_ALTERA_AVALON_TIMER_STATUS(TIMER_0_BASE, 0); //reset TO flag
*context = *context + 1 ;
IOWR_ALTERA_AVALON_PIO_DATA(PIO_OUT_BASE, context);
}
So i need your help and ideas. Thanks