ENC28J60 Microchip 4.13 TCP/IP porting to Firewing

Share code examples with other users

ENC28J60 Microchip 4.13 TCP/IP porting to Firewing

Postby Coccoliso » Mon Oct 27, 2014 3:04 pm

Hello,
attached the zip file containing the porting in Firewing of tcp/ip stack of Microchip version 4.13 for PIC18 and ENC28J60 under FW Swordfish Toolsuite.
To install it directly drag the zip on the IDE FW and it will create a folder under UserLibrary\MCU08\Microchip 4.13
As a reference, read the official document http://www.sfcompiler.co.uk/wiki/pmwiki.php?n=SwordfishUser.Ethernet .
Attachments
Microchip 4.13.zip
(105.05 KiB) Downloaded 807 times
User avatar
Coccoliso
 
Posts: 177
Joined: Sat Sep 27, 2014 10:02 am

Re: ENC28J60 Microchip 4.13 TCP/IP porting to Firewing

Postby David John Barker » Tue Oct 28, 2014 4:20 pm

Looks really interesting, thanks for sharing! - what board / device did you test it with?
User avatar
David John Barker
 
Posts: 491
Joined: Thu Nov 08, 2012 12:21 pm

Re: ENC28J60 Microchip 4.13 TCP/IP porting to Firewing

Postby Coccoliso » Tue Oct 28, 2014 6:58 pm

Hello David,
home made board, PIC18F4685 at 40MHz 5V , an ENC28J60 Ethernet LAN / Network Module For Arduino with 3.3v / 5V level converter.
In module ENC28J60.BAS a little modify on MACInit SUB for 40MHz clock.


Code: Select all
Public Sub MACInit()
   #ifndef FULL_DUPLEX
      #ifndef HALF_DUPLEX
         Dim Register As REG
         Dim PHYRegister As PHYREG
      #endif
   #endif         
   Dim i As Byte

   // Set up the SPI module on the PIC for communications with the ENC28J60
   ENC_CS_IO = 1
   Output(ENC_CS_IO)      // Make the Chip Select pin an output

   ENC_SCK_TRIS = 0
   ENC_SDO_TRIS = 0
   ENC_SDI_TRIS = 1

   // Set up SPI
   
   #if _clock = 20 or _clock = 10
      ENC_SPICON1 = $20    // SSPEN bit is set, SPI in master mode, FOSC/4, IDLE state is low level
   #elseif _clock = 40
      ENC_SPICON1 = $21      // SSPEN bit is set, SPI in master mode, FOSC/16, IDLE state is low level
   #else
      #error "MACInit() undefined SPI setup for clock frequency."
   #endif   
   
'   ENC_SPICON1 = $20      // SSPEN bit is set, SPI in master mode, FOSC/4, IDLE state is low level
'   ENC_SPICON1 = $21      // SSPEN bit is set, SPI in master mode, FOSC/16, IDLE state is low level
'   ENC_SPICON1 = $22      // SSPEN bit is set, SPI in master mode, FOSC/64, IDLE state is low level
 


I noticed that the compiled SF Toolsuite are slightly faster because in some cases such as the direct control of GLCD I was forced to reduce the clock speed .. an example that the KS0108 with FW hangs with 40MHz clock and you do not able to have a filled rectangle if not decreasing the frequency to 32MHz. And 'certainly the optimization of compiled since the two ASM routines differ slightly in that routine where a FOR loop draws horizontal lines at a speed such as to lock the bus of the display.
User avatar
Coccoliso
 
Posts: 177
Joined: Sat Sep 27, 2014 10:02 am

Re: ENC28J60 Microchip 4.13 TCP/IP porting to Firewing

Postby Jerry Messina » Tue Oct 28, 2014 7:56 pm

You should be able to get the ENC28J60 to work with a 10MHz SPI clock (FOSC/4 mode) and a 40MHz 18F4685... that's how I used to use it.

If you run it slower than 8MHz you may have problems w/some of the errata.
Jerry Messina
 
Posts: 280
Joined: Thu Feb 14, 2013 10:16 am

Re: ENC28J60 Microchip 4.13 TCP/IP porting to Firewing

Postby Coccoliso » Tue Oct 28, 2014 10:23 pm

Hello Jerry,
in my case I think that the difference lies in level shifter 3V / 5V, I should try to bring the MCU to 3.3V and try again.
User avatar
Coccoliso
 
Posts: 177
Joined: Sat Sep 27, 2014 10:02 am


Return to Code Examples

Who is online

Users browsing this forum: No registered users and 2 guests

cron

x