[En-Nut-Discussion] Need help: interrupt resets device.

Dmitry Beklemishev dbeklemishev at csa.kz
Wed Apr 4 07:05:07 CEST 2007


Good day!

I have Ethernut 2.1 board and Nut/OS v.4.2.1.

The problem is that INTERRUPT3 resets device when occurs. The code is below.

 

static void irqhandler(void *arg)

{

// Reset occurs even with empty handler

}

 

int main(void)

{

  TCPSOCKET *sock;

  FILE *stream;

  u_long baud = 115200;

  #if defined(USE_EEPROM)

  static u_char _data;

  #endif

  #if defined(USE_EEPROM)

  NutNvMemLoad(EEPROMADDR,&_data,1);

  setout(_data);

  #endif

 

  ADCInit();

  ADCSetPrescale(ADC_PRESCALE_DIV64);     

//  ADCSetRef(AVCC); 

  ADCSetRef(INTERNAL_256); 

  ADCSetMode(SINGLE_CONVERSION); 

 

  NutRegisterDevice(&DEV_DEBUG, 0, 0);

  NutRegisterDevice(&DEV_ETHER, 0x8300, 5);

 

  freopen(DEV_DEBUG_NAME, "w", stdout);

  _ioctl(_fileno(stdout), UART_SETSPEED, &baud);

 

  NutNetLoadConfig(DEV_ETHER_NAME);

  NutNetIfConfig(DEV_ETHER_NAME, confnet.cdn_mac, confnet.cdn_ip_addr,
confnet.cdn_ip_mask);

 

  NutWatchDogStart(WDTIMER,0);

  NutThreadCreate("WDThread", WDThread, 0, 512);

 

  NutRegisterIrqHandler(&sig_INTERRUPT3, irqhandler, 0);

  NutIrqSetPriority(&sig_INTERRUPT3, 0);

  NutIrqEnable(&sig_INTERRUPT3);

 

  for (;;) 

  {

    if ((sock = NutTcpCreateSocket()) != 0) 

    {

      if (NutTcpAccept(sock, INPORT) == 0) 

      {

        if ((stream = _fdopen((int) sock, "r+b")) != 0) 

        {

          ProcessRequests(stream);

          fclose(stream);

        } else puts("Assigning a stream failed");

      }

      NutTcpCloseSocket(sock);

    }

  }

}

 

Compiler used is avr-gcc.

 

Can anybody help me?

Sincerely yours,

Dmitry.

 




More information about the En-Nut-Discussion mailing list