Forum: Compiler & IDEs enc28j60 initialisierungsprobleme


von Stefan S. (5tefan)


Lesenswert?

Hallo Leute,

irgendwie möchte mein enc28j60 nicht anlaufen. Zum initialisieren des 
enc benutz ich die Standardroutine von Pascal Stang.

Master ist ein Atmega32. Dieser bleibt immer in der while Schleife 
hängen, in der die Bestätigung des enc kommen sollte.

Boad ist das AVR-NET IO von Atmel. Der enc funktioniert aufjedenfall, 
ich hab das komplette Board mit einem Ethersex-Image getestet.

Hat jemand eine Idee, woran es liegen könnte?

Schon einmal vielen Dank im Voraus!
1
void enc28j60Init(void)
2
{
3
  // initialize I/O
4
  ENC28J60_CONTROL_DDR |= (1<<ENC28J60_CONTROL_CS);
5
  ENC28J60_CONTROL_PORT |= (1<<ENC28J60_CONTROL_CS);
6
7
  // setup SPI I/O pins
8
  ENC28J60_SPI_PORT |= (1<<ENC28J60_SPI_SCK);  // set SCK hi
9
  ENC28J60_SPI_DDR |= (1<<ENC28J60_SPI_SCK);  // set SCK as output
10
  ENC28J60_SPI_DDR &= ~(1<<ENC28J60_SPI_MISO);  // set MISO as input
11
  ENC28J60_SPI_DDR |= (1<<ENC28J60_SPI_MOSI);  // set MOSI as output
12
  ENC28J60_SPI_DDR |= (1<<ENC28J60_SPI_SS);    // SS must be output for Master mode to work
13
  // initialize SPI interface
14
  // master mode
15
  SPCR |= (1<<MSTR);
16
17
  // switch to f/4 2X = f/2 bitrate
18
  //SPCR|= (1<<SPR0);
19
  //SPCR |= (1<<SPR1);
20
  SPSR |= (1<<SPI2X);
21
  // enable SPI
22
  SPCR |= (1<<SPE);
23
24
  // perform system reset
25
  enc28j60WriteOp(ENC28J60_SOFT_RESET, 0, ENC28J60_SOFT_RESET);
26
  // check CLKRDY bit to see if reset is complete
27
  delay_us(100000);
28
  while(!(enc28j60Read(ESTAT) & ESTAT_CLKRDY));

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.