Jump to content
    

Зависание программы в alt_tick()

Приветствую всех!

Подскажите, пожалуйста, в чем может быть беда..

 

Собрана система NIOS:

post-71932-1439361080_thumb.png

 

При запуске программы в режиме отладке при пошаговом выполнении выполняется только alt_sys_init();, после чего курсор пропадает, при нажатии на паузу появляется в alt_tick(), в которой при пошаговом выполнении из нее не выходит.

 

Вылетает на второй строчке main:

int main()
{
    alt_sys_init();
    IOWR_ALTERA_AVALON_PIO_DATA(PIO_OUT_BASE, 0);
    Delay(0xFFFF);
    IOWR_ALTERA_AVALON_PIO_DATA(PIO_OUT_BASE, 1);
...
...

 

Что я делаю не так / куда копать?

Share this post


Link to post
Share on other sites

Что за функция

Delay(0xFFFF);

?

Смотрите, что делается в функции alt_tick(). Есть подозрение, что у вас таймер не до конца настроен.

Share this post


Link to post
Share on other sites

void Delay(int _d)
{
    volatile int i = 0;
    for(i =0; i < _d; i++);
}

 

Но он до нее не доходит.

 

В alt_tick ходит внутри цикла:

/* process the registered callbacks */

  while (alarm != (alt_alarm*) &alt_alarm_list)
  {
    next = (alt_alarm*) alarm->llist.next;

    /* 
     * Upon the tick-counter rolling over it is safe to clear the 
     * roll-over flag; once the flag is cleared this (or subsequnt)
     * tick events are enabled to generate an alarm event. 
     */
    if ((alarm->rollover) && (_alt_nticks == 0))
    {
      alarm->rollover = 0;
    }
    
    /* if the alarm period has expired, make the callback */    
    if ((alarm->time <= _alt_nticks) && (alarm->rollover == 0))
    {
      next_callback = alarm->callback (alarm->context);

      /* deactivate the alarm if the return value is zero */

      if (next_callback == 0)
      {
        alt_alarm_stop (alarm);
      }
      else
      {
        alarm->time += next_callback;
        
        /* 
         * If the desired alarm time causes a roll-over, set the rollover
         * flag. This will prevent the subsequent tick event from causing
         * an alarm too early.
         */
        if(alarm->time < _alt_nticks)
        {
          alarm->rollover = 1;
        }
      }
    }
    alarm = next;
  }

 

При этом next все на один адрес указывает.

 

Никогда раньше такой проблемы не был до этого...

А как нужно настраивать таймер?

Share this post


Link to post
Share on other sites

При похожей проблеме помогло удаление из main() вызовов 

alt_irq_init((void*)0);
alt_sys_init();

т.к. они уже вызываются в alt_main().

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...