ENC28J60 Ethernet Library V3.3

General discussion on mikroPascal.
Post Reply
Author
Message
yo2lio
Posts: 1878
Joined: 19 Sep 2006 12:57
Location: Romania, Arad City
Contact:

ENC28J60 Ethernet Library V3.3

#1 Post by yo2lio » 17 Jan 2008 23:23

Finally ... done library for ENC28J60 :D

This library is in test, please test this library !

Library is OPEN SOURCE and with small modifications must work on DSPIC MCU and ATMEL MCU. Of course I will make this modifications !

Project compiled for BIGPIC4 board, MCU PIC18F8722.
ENC28J60 CS pin PORTC.1
ENC28J60 RESET pin PORTC.0

Default Ip : 192.168.1.253

You can download source code from : http://www.microelemente.ro/MikroPascal ... source.zip

Live software :
http://ip-watcher.dyndns.info/
http://ip-watcher.dyndns.info/page1
Last edited by yo2lio on 04 Feb 2008 22:35, edited 1 time in total.
Best regards, Florin Andrei Medrea.

http://www.microelemente.ro/
http://www.microelemente.ro/produse-si-servicii/
http://www.microelemente.ro/custom-software/

mail : florin@microelemente.ro

yo2lio
Posts: 1878
Joined: 19 Sep 2006 12:57
Location: Romania, Arad City
Contact:

#2 Post by yo2lio » 20 Jan 2008 07:41

Library updated :!:

Redefined few constants from definition_ENC.ppas file.
Best regards, Florin Andrei Medrea.

http://www.microelemente.ro/
http://www.microelemente.ro/produse-si-servicii/
http://www.microelemente.ro/custom-software/

mail : florin@microelemente.ro

kayh
Posts: 63
Joined: 22 Apr 2005 03:12

#3 Post by kayh » 22 Jan 2008 01:24

yo2lio wrote:Library updated :!:

Redefined few constants from definition_ENC.ppas file.
Wow .. great. Just compiled it for an 18F4620 runs no problem! You are getting good at this stuff, I'm still struggeling understanding the inner workings of ethernet.

yo2lio
Posts: 1878
Joined: 19 Sep 2006 12:57
Location: Romania, Arad City
Contact:

#4 Post by yo2lio » 04 Feb 2008 22:42

Library updated !

Resolved small BUG in CopyEthMemToEthMem routine. When length of data copy was 0 or 1, MCU frozen.
This BUG was submitted by guyfoc.
Best regards, Florin Andrei Medrea.

http://www.microelemente.ro/
http://www.microelemente.ro/produse-si-servicii/
http://www.microelemente.ro/custom-software/

mail : florin@microelemente.ro

kayh
Posts: 63
Joined: 22 Apr 2005 03:12

#5 Post by kayh » 17 Feb 2008 20:49

[quote="yo2lio"]Library updated !

yo2lio, do you think it is possible to add DHCP to your library? I'm no expert in this, but it would be nice to automatically get a proper IP when connecting to an unknown switch/network.

yo2lio
Posts: 1878
Joined: 19 Sep 2006 12:57
Location: Romania, Arad City
Contact:

#6 Post by yo2lio » 17 Feb 2008 21:00

kayh wrote:yo2lio, do you think it is possible to add DHCP to your library? I'm no expert in this, but it would be nice to automatically get a proper IP when connecting to an unknown switch/network.
Yes it's possible, unfortunately I don't have time for this, now I must make some money !

Library is OPEN SOURCE , if you want you can try to implement DHCP.
Best regards, Florin Andrei Medrea.

http://www.microelemente.ro/
http://www.microelemente.ro/produse-si-servicii/
http://www.microelemente.ro/custom-software/

mail : florin@microelemente.ro

yo2lio
Posts: 1878
Joined: 19 Sep 2006 12:57
Location: Romania, Arad City
Contact:

#7 Post by yo2lio » 08 Mar 2008 15:35

Hi,

Library updated. Resolved small bug in Get_Time routine.
Renamed all ENC28J60 registers (in unit definitions_ENC).
Added 4 new procedures Eth_SetBank_0, Eth_SetBank_1, Eth_SetBank_2, Eth_SetBank_3, instead of Eth_SetBank(x).

You can download source code from : http://www.microelemente.ro/MikroPascal ... source.zip

Old files : http://www.microelemente.ro/MikroPascal ... ce_old.zip
Best regards, Florin Andrei Medrea.

http://www.microelemente.ro/
http://www.microelemente.ro/produse-si-servicii/
http://www.microelemente.ro/custom-software/

mail : florin@microelemente.ro

Georges
Posts: 171
Joined: 12 Apr 2005 08:50

Example for PIC18F8722 needed

#8 Post by Georges » 26 Jun 2008 08:20

Dear Yolio,

appreciate if you can provide a working example for PIC18F8722.

As you said the library is tested BIGPIC4 board, MCU PIC18F8722.

but I can not find the example. all the example are for 18F87J60

I need to get it working on 18F4620

Thanks

yo2lio
Posts: 1878
Joined: 19 Sep 2006 12:57
Location: Romania, Arad City
Contact:

Re: Example for PIC18F8722 needed

#9 Post by yo2lio » 26 Jun 2008 10:01

Georges wrote:Dear Yolio,

appreciate if you can provide a working example for PIC18F8722.

As you said the library is tested BIGPIC4 board, MCU PIC18F8722.

but I can not find the example. all the example are for 18F87J60

I need to get it working on 18F4620

Thanks
Hi,

Unfortunately I don't have examples in MikroPascal.

You can download examples only in MikroBasic language :
http://www.microelemente.ro/MikroBasic/ ... amples.zip

Sorry.
Best regards, Florin Andrei Medrea.

http://www.microelemente.ro/
http://www.microelemente.ro/produse-si-servicii/
http://www.microelemente.ro/custom-software/

mail : florin@microelemente.ro

Georges
Posts: 171
Joined: 12 Apr 2005 08:50

#10 Post by Georges » 26 Jun 2008 17:41

Great Library YOLIO. I converted the BASIC example Mini Web Server to mMikroPascal.

I have it runing great in PROTEUS simulator and VMWARE.
I Have a question yet : Do you have an example where I can use a web page to turn on/off a pin on porta or any other led.

The example says that only get method is implemented.

thanks.

kayh
Posts: 63
Joined: 22 Apr 2005 03:12

#11 Post by kayh » 28 Jun 2008 19:16

Georges wrote:Great Library YOLIO. I converted the BASIC example Mini Web Server to mMikroPascal.

I have it runing great in PROTEUS simulator and VMWARE.
I Have a question yet : Do you have an example where I can use a web page to turn on/off a pin on porta or any other led.

The example says that only get method is implemented.

thanks.
Look at Brunos examples, all you do is intercept a get http://URL/pin1porta (or whatever you want to call it) and then toggle the pin

Georges
Posts: 171
Joined: 12 Apr 2005 08:50

#12 Post by Georges » 03 Jul 2008 09:33

Done, Pin control is completed.

Three questions:

1- can I use POST instead of GET method. if yes how ?
2- The MCU sometimes freezes, after 2-3 hours even if left without pings or any thing else. Do you know of any special considerations?

3- what is the difference between eth_ip_addr and user_ip_addr ?

4 what will happen if I don't call countertask every 1ms. what is the role of countertask. will i loose tcp connection if I don't call it?

thanks.

yo2lio
Posts: 1878
Joined: 19 Sep 2006 12:57
Location: Romania, Arad City
Contact:

#13 Post by yo2lio » 03 Jul 2008 14:52

Georges wrote:1- can I use POST instead of GET method. if yes how ?
Yes you can. It's not so easy, you can do this only with Explores browser, you must search in packet after your parameters ....

Code: Select all

  // get 15 first bytes only of the request, the rest does not matter here
  for i := 0 to 14 do getRequest[i] := Eth_GetByte;
    
  httpMethod1 := 'Get /';
  httpMethod2 := 'Post /';
  
  if memcmp(@getRequest, @httpMethod1, 5)<>0 then goto get_meth
  else if memcmp(@getRequest, @httpMethod2, 6)<>0 then goto post_meth
  else
    begin
      result := 0 ;
      exit;
    end;
    
get_meth:

post_meth:
Georges wrote:2- The MCU sometimes freezes, after 2-3 hours even if left without pings or any thing else. Do you know of any special considerations?
I don't know why ...
Georges wrote:3- what is the difference between eth_ip_addr and user_ip_addr ?
user_ip_addr is not used by library , is used only in example, also you can use this variable in your applications, if you want
Georges wrote:4 what will happen if I don't call countertask every 1ms. what is the role of countertask. will i loose tcp connection if I don't call it?
CounterTask is used by NTP (real time clock) and by ping stack.
You can skip this if you want.
Best regards, Florin Andrei Medrea.

http://www.microelemente.ro/
http://www.microelemente.ro/produse-si-servicii/
http://www.microelemente.ro/custom-software/

mail : florin@microelemente.ro

Georges
Posts: 171
Joined: 12 Apr 2005 08:50

#14 Post by Georges » 06 Jul 2008 04:29

First, thank you.

Second:

I have integrated your code above. now the for uses the POST method. the problem now is that the form data being posted is not part of the URL anymore (good). But because of that, when the statement :for i := 0 to 20 do getRequest := Eth_GetByte; is executed, getRequest string does not include the data of the form.

May you please point me where to look for the form data in the incoming packet?

thank you

yo2lio
Posts: 1878
Joined: 19 Sep 2006 12:57
Location: Romania, Arad City
Contact:

#15 Post by yo2lio » 06 Jul 2008 08:12

Copy received packet in PIC memory :

Code: Select all

var    getRequest : string[1478];  // HTTP request buffer (max. 1478 , (1518 - 40) bytes)

...

  for i := 0 to (len_T - 1) do getRequest[i] := Eth_GetByte;
  getRequest[i] := 0;
And now search the string after your data ....
Best regards, Florin Andrei Medrea.

http://www.microelemente.ro/
http://www.microelemente.ro/produse-si-servicii/
http://www.microelemente.ro/custom-software/

mail : florin@microelemente.ro

Post Reply

Return to “mikroPascal General”