mitxela / kiloboot

1kB TFTP Ethernet bootloader for ATmega328P and ENC28J60
52 stars 16 forks source link

Using ENC28J60 without INT pin #1

Closed hubsif closed 7 years ago

hubsif commented 7 years ago

Hi mitxela,

I'm looking for a TFTP bootloader for my Arduino Mega 2560 and yours looks very promising.

There's one issue though: I cannot connect the Interrupt PIN (INT) of the ENC28J60 to my microcontroller (anymore). I'm using the ethercard library in my application, which doesn't need it. But from your website it seems that this is required to check for incoming packages.

If I correctly unterstood from the ethercard library, the alternative to using the interrupt pin is to poll the EPKTCNT register. Would it be much effort to change your code to do that instead? (possibly by modifying your code at the "readPacket" label)

I would do it myself, but I'm not good in writing assembler. I'd be happy for any hints or even code snippets to get this working.

Thanks a lot! hubsif.

mitxela commented 7 years ago

This should be possible. The first two instructions of the readPacket routine are checking the pin level, so that's what needs to be replaced with code that polls the EPKTCNT register. The register is in bank 1, which means changing bank, checking the register, then changing back to bank 0 afterwards, since the rest of the routine assumes it's on bank 0.

There's currently 24 bytes left in the 1kB section, more if you shorten the filename in the request. If you expand the bootloader section to 2kB you can turn on the debug output too.

You will also need to check compatibility between the mega 2560 and the mega328p, I've not used the 2560 but it's probably very similar.

Have a go if you can, I'll take a proper look into this when I have some spare time.

mitxela commented 7 years ago

I've now edited the code to poll the EPKTCNT register so the INT pin is no longer required.

hubsif commented 7 years ago

Oh, great! Thanks a lot! Will try it as soon as I find some time.