[En-Nut-Discussion] Problem with Port E Pin 5 and Ethernet

Tom Nyström m99tomny at embassaden.liu.se
Tue Apr 15 14:44:08 CEST 2003


Hello!
 
Earlier we used Timer 3 to generate PWM signals on outputs A (Port E Pin 3)
and C (Port E Pin 5). When we decided the PWM was no longer needed and
turned Timer 3 off to use Port E Pins 3 & 5 as digital outs we encountered a
problem - the Nut locked up when executing the program.
 
After some work it was discovered that the combination of 
+ setting Port E Pin 5 as Out
+ registering/configuring an Ethernet device
+ NOT using Timer 3 
caused the problem. All other pins of Port E can be set freely as In or Out.
 
Below is an example with UART and Ethernet illustrating the problem and its
makefile. Has anyone else found this and what might be the cause?
 
Regards
Tom Nyström
 

#include <stdio.h>
#include <io.h>
#include <dev/nicrtl.h>
#include <dev/uartavr.h>
#include <sys/timer.h>
 
// Is needed if an Ethernet device is NOT registered/configured.
void bugfix(void *arg)
{
   NutEventPostAsync(arg);
}
 
int main(void)
{
  //DDRE=(1<<DDE5); // This line makes the Nut crash.
  DDRE=0xDF; // All other pins work as Out.
  u_long baud = 115200;
  
  NutRegisterDevice(&devUart0, 0, 0);
  freopen("uart0", "w", stdout);
  _ioctl(_fileno(stdout), UART_SETSPEED, &baud);
  NutSleep(200);
 
  if(NutRegisterDevice(&devEth0, 0x8300, 5)) 
    puts("Registering device failed");
 
  if(NutNetAutoConfig("eth0"))
    puts("Configuring device failed");
 
  puts("Ready\r\n");
 
  for(;;)
    {
      NutSleep(1000);
      puts("Hello world\r\n");
    }
}
 

Makefile:
 
PROJ = simple
top_srcdir = ../..
include $(top_srcdir)/app/Makedefs
SRCS =  $(PROJ).c
OBJS =  $(SRCS:.c=.o)
LIBS =  $(LIBDIR)/nutinit.o -lnutnet -lnutpro -lnutos -lnutdev -lnutcrt
TARG =  $(PROJ).bin
all: $(OBJS) $(TARG)
include $(top_srcdir)/app/Makerules



More information about the En-Nut-Discussion mailing list