Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
13 years ago

Using 2 timers ?

We are trying to use 2 interval timer (200ms and 500ms) on a nios 2 processor. One is configure as a system clock timer and its work fine., but the second don’t work.

The declaration on the nios is (for the two interval timer) :

alt_irq_enable(TIMER_500M_IRQ

IOWR(TIMER_500M_IRQ, 1, 3);

alt_irq_register( TIMER_500M_IRQ, null, TIMER500M_IRQ);

The interrupt function look like that :

static void TIMER500M_IRQ(void* context, alt_u32 id)

{

IOWR(TIMER_500M_BASE, 0, 0);

//code

}

Does anyone have a solution a this problem ?

Thanks in advance.

12 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    We need to quickly finish our project (with a single timer use).

    So, we will make other tests with your suggestions at the end of the next week.

    We let you informed.

    Thank you.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hello,

    We have made several tests today, and the problem was solved. In fact it was easy, we have made a mistake during addressing the register and the during of the function of the timer is longer than the period of the timer. Below a code example for other user of this forum :

    // Declaration of the timer (500ms)

    IOWR_ALTERA_AVALON_TIMER_CONTROL(TIMER_500M_BASE, 0);

    IOWR_ALTERA_AVALON_TIMER_PERIODL(TIMER_500M_BASE, 0x9680);

    IOWR_ALTERA_AVALON_TIMER_PERIODH(TIMER_500M_BASE, 0x0098);

    alt_irq_register( TIMER_500M_IRQ, null, TIMER500M_IRQ);

    IOWR_ALTERA_AVALON_TIMER_CONTROL(TIMER_500M_BASE,

    ALTERA_AVALON_TIMER_CONTROL_CONT_MSK

    | ALTERA_AVALON_TIMER_CONTROL_START_MSK

    | ALTERA_AVALON_TIMER_CONTROL_ITO_MSK);

    // Snapshot

    IOWR_ALTERA_AVALON_TIMER_SNAPL(TIMER_500M_BASE, 0x00);

    periodl=IORD_ALTERA_AVALON_TIMER_SNAPL(TIMER_500M_BASE);

    periodh=IORD_ALTERA_AVALON_TIMER_SNAPH(TIMER_500M_BASE);

    Thanks again for your help.