ETHERNET LIBRARY WITH WEB SERVER EXAMPLE FOR PIC18F97J60 FAM

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

ETHERNET LIBRARY WITH WEB SERVER EXAMPLE FOR PIC18F97J60 FAM

#1 Post by yo2lio » 06 May 2007 12:07

Hello all,

I finished in this weekend BETA version of Eth_V2 library with WEB SERVER example for PIC18F97J60 family MCU.

Author of this project : Medrea Florin Andrei - YO2LIO -
Thanks to Mikroelektronika team and all forum users.

Web Server example : (No TCP STACK, No fragmentation available at this moment).

Initial IP Address : 192.168.1.253.
HTTP port respond : 80.

//192.168.1.253/ (web page1)
//192.168.1.253/p (web page2)

User Functions and Procedures:

Code: Select all

- Procedure Eth_SetParameters;
  // Set your IP, Mac, Mask ... etc... here.

- Procedure Eth_Init;
  // Init MCU Ethernet.

- Procedure Eth_Reset;
  // Reset MCU Ethernet.

- Procedure Eth_DoPacket;
  // Process incoming packets.

- Function Eth_UserTCP(var dest_ip_addr_T : array[4] of byte; var source_port_T, dest_port_T, len_T : word) : word;
  // This function is called by library. Put your TCP response for WEB server parameters here. See example.


- Function Eth_UserUDP(var dest_ip_addr_U : array[4] of byte; var dest_port_U, source_port_U, len_U : word) : word;
  // This function is called by library. Put your UDP response here. See example. ( ECHO example )

- Procedure Eth_PutByte(value : byte);
  // Put one byte in ETH memory.

- Function Eth_GetByte : byte;
  // Get one byte from ETH memory.

- Function CopyFlashToEthMem_CP(start_Flash_address : longint): word;
  // Copy Const from flash to Eth Memory and return length of Const data.
  // Const data must be defined as STRING. (and must be zero terminated)
  // Ex. len := CopyFlashToEthMem_CP(@httpHeader);

- Function CopyRamToEthMem_CP(var s : array[255] of byte): word;
  // Copy var data to Eth Memory and return length of var data.
  // Var data must be defined as ARRAY. (and must be zero terminated)
  // Ex. len := CopyRamToEthMem_CP('data data data');

- Function Eth_SendARP(var ip_dest : Array[4] of Byte) : Boolean;
  // Get ARP request. Return True if Mac exist.
  // Return dest. mac address in var dest_mac : array[6] of bytes;.
  // Return dest. ip address in var dest_ip_addr : array[4] of byte;.
  // Ex. bol := Eth_SendARP(user_ip_addr);
  // First function search in ArpCache (size of 9) ...

- Procedure SendUDP(dest_port_S, source_port_S, len_data : word; var data_udp : array[1472] of byte);
  // Send UDP mesage. Max 1472 bytes.
  // Ex. If Eth_SendARP(user_ip_addr) then SendUDP(dest_port, eth_port, 10, 'Test Test ');

- Procedure Eth_SendPing(SlotState : boolean; PingSlot : Byte);
  // Have 8 Slots available 0 .. 7 and PingCache size of 8.
  // Ex. Eth_SendPing(Eth_SendARP(user_ip_addr),0); Send Ping at user_ip_addr and put result in Slot 0.

  // PingCache format :
  // PingCache[Slot].IpP : array[4] of byte;
  // PingCache[Slot].MacP : array[6] of byte;
  // PingCache[Slot].Time : word;
  // PingCache[Slot].TTL : byte.
Advance Functions and Procedures:

Code: Select all

(AddrPacket is address of received packet, TXSTART is start address of transmited packet)

- Procedure CopyEthMemToRam(start_eth_address, dest_ram_address, length_w : word);
  // Ex. CopyEthMemToRam(AddrPacket+6,@dest_mac_addr,6);

- Procedure CopyRamToEthMem(start_ram_address, dest_eth_address, length_w : word);
  // Ex. CopyRamToEthMem(@eth_mac,TXSTART+22,6);

- Procedure CopyFlashToEthMem(start_Flash_address : longint; dest_eth_address, length_w : word);
  // Ex. CopyFlashToEthMem(@httpHeader,TXSTART+54,30);

- Procedure CopyEthMemToEthMem(start_eth_address, dest_eth_address, length_w : word; where : byte);
  // where = 0 copy from Eth RxBuf to Eth TxBuf;
  // where = 1 copy from Eth TxBuf to Eth TxBuf
  // Ex. CopyEthMemToEthMem(AddrPacket+38,TXSTART+28,4,0);

- Procedure WriteToEthMem(dest_eth_address : word; value : byte);
  // Ex. WriteToEthMem(TXSTART+12,$08);

- Function ReadFromEthMem(start_eth_address : word) : byte;
  // Ex. data := ReadFromEthMem(AddrPacket+38);

- Function EthMemCompareWithRam(start_eth_address, start_ram_address, length_w : word) : boolean;
  // Ex. bol := EthMemCompareWithRam(AddrPacket+30,@eth_ip_addr,4);

- Function EthMemCompareWithFlash(start_eth_address : word; start_Flash_address : longint; length_w : word) : boolean;
  // Ex. bol := EthMemCompareWithFlash(AddrPacket+54, @httpHeader, 30);

- Function Eth_Cksum(start_eth_address, length_w : word) : word;
  // Ex. cksum_ip := Eth_Cksum(TXSTART+14,20);

- Procedure Eth_WritePHYReg(register_address : byte; data : word);
  // Write to PHY registers;

- Procedure Eth_SetLedConfig(NewConfig: word);
  // Set Eth Led configuration. See datasheet for more detail.

- Function Eth_ReadPacket : word;
  // Read packet and return TYPE OF SERVICE.

- Procedure Eth_Send(length_w : word);
  // Send packet from Tx buffer.
You can download the code from here: http://www.microelemente.ro/Eth_V2.zip

Good luck !

Best regards Florin Medrea.

Teo
Posts: 20
Joined: 01 Jun 2006 09:21
Location: Bucuresti

#2 Post by Teo » 06 May 2007 18:59

TNX!! Multumesc!!

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

#3 Post by yo2lio » 12 May 2007 17:17

ETH V2 parameters.

Response time for ICMP :

Image

Response time for WEB :

Image

Best regards, Florin Medrea.
Last edited by yo2lio on 23 Aug 2007 06:20, edited 3 times in total.

Storic
Posts: 393
Joined: 01 Oct 2004 00:20
Location: Australia (S.A.)

#4 Post by Storic » 13 May 2007 04:45

Hi,
I went to try the code sample and well I did not have the PIC18F97J60 device library, I will try when the library becomes available. ( or Mikroe could send me the PIC18F97J60 driver if available)

Andrew

piort
Posts: 1379
Joined: 28 Dec 2005 16:42
Location: Laval,Québec,Canada,Earth... :-)
Contact:

#5 Post by piort » 13 May 2007 05:51

you can have the file there...
http://www.mikroe.com/forum/viewtopic.php?t=9771


happy coding :-)

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

#6 Post by yo2lio » 13 May 2007 09:03

Hello

You can download definition files for all device family (PIC18F66j60, PIC18F66J65, PIC18F67J60, PIC18F86j60, PIC18F86J65, PIC18F87J60, PIC18F96j60, PIC18F96J65, PIC18F97J60) here : http://www.mikroe.com/forum/viewtopic.php?t=8966

BootLoader software, for this family, with full source code you can download here : http://www.mikroe.com/forum/viewtopic.php?t=9771

BootLoader V3, smaller and faster, you can download here : http://www.mikroe.com/forum/viewtopic.php?t=11259

Eth_V2 library is for all device family and is tested on PIC18F67J60 MCU.

Best regards, Florin Medrea.
Last edited by yo2lio on 22 Aug 2007 16:38, edited 1 time in total.

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

#7 Post by yo2lio » 16 May 2007 20:00

Hello all,

Eth_V2 library has updated !! :D

Minor BUG in TCP routine FIXED.

Good luck !

Best regards, Florin Medrea.

Storic
Posts: 393
Joined: 01 Oct 2004 00:20
Location: Australia (S.A.)

#8 Post by Storic » 16 May 2007 23:20

I now have the def file for the P18F97J60, :)

now I get "Linker error: NOT ENOUGH ROM" :(

Andrew

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

#9 Post by yo2lio » 17 May 2007 06:19

Hi Storic,

Please tell me more details. What MCU are selected ?

I work with this definitions files and Eth_V2 library and is OK.

In bootloader software I use special definitions files with some modifications. See readme file.

Best regards, Florin Medrea.

Storic
Posts: 393
Joined: 01 Oct 2004 00:20
Location: Australia (S.A.)

#10 Post by Storic » 17 May 2007 11:00

sorry :oops:

it turned out I had an incorrect/corrupt def file. I re-downloaded the P18f97j60 def file and re-installed, re-compiled and all worked OK, the error I was getting was all compiles ok, it was when the compiler was proccessing the ROM. however all OK now

Thanks for your responce

Andrew

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

On-Line Demo

#11 Post by yo2lio » 17 May 2007 15:37

You can see an on-line demo of this library here: http://www.mikroe.com/forum/viewtopic.php?p=51695

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

#12 Post by yo2lio » 15 Aug 2007 19:15

New release are available : Ethernet library V3.1 and example for LV18FJ board.

History : V3.1

Ethernet library version V3.1, MCU family PIC18F97J60 ( PIC18F87J60, LV18FJ board ).

Added :

Code: Select all

- Function Send_Ping(var ip_address : IpHeader) : word;
  // Send ping at specified ip_address and return response time.
  // Ex. PingTimeResponse := Send_Ping(user_ip_address);
 
- Function Send_UDP(var ip_address : IpHeader; dest_port_S, source_port_S, len_data : word; var data_udp : array[1472] of byte) : boolean;
  // Send UDP mesage, max 1472 bytes, at specified ip_address and return true if success.
  // Ex. Success := Send_UDP(user_ip_addr, 10001, 9999, 10, 'data data ');
 
- Function Send_ARP(var ip_address : IpHeader; var mac_address : MacHeader) : boolean;
  // Get MAC for specified ip_address, put result in mac_address variable and return true if success.
  // Ex. Success := Send_ARP(user_ip_addr,reply_mac_addr);
 
- Procedure Firewall(ICMP, TCP, UDP : boolean);
  // Default all false, allow all type of packets.
  // If ICMP = true, ignore ICMP request. Ex. Firewall(true, false, false);
  // If TCP = true, ignore TCP packets. Ex. Firewall(false, true, false);
  // If UDP = true, ignore UDP packets. Ex. Firewall(false, false, true);
 
- Procedure EraseARPCache;
  // Erase ARP cache table.

- Procedure CounterTask;
  // Increments all counters used by library in ARP, ICMP, TCP, UDP routine.
  // This procedure must be called at 1ms in interrupt routine.
 
- Fixed small BUG in ARP routine.

Aditional procedures :
   
- Function Str2Byte(var byte_in : string[3]) : byte;

- Function Str2Word(var word_in : string[5]) : word;
   
- Procedure Byte2Hex(data_hex : byte; var hex : string[2]);

- Function Hex2Byte(var hex : string[2]) : byte;

- Procedure Ip2Str(var user_ip_addr : IpHeader; var str_out : string[15]);

- Procedure Mac2Str(var mac_address : MacHeader; var str_out : string[12]);

- Procedure Str2Ip(var str_in : string[15]; var user_ip_addr : IpHeader);

- Procedure Str2Mac(var str_in : string[12]; var mac_address : MacHeader);
You have ARP, ICMP, UDP, TCP, Mini Web Server examples, designed for LV18FJ board.

You can download this examples from : http://www.microelemente.ro/MikroPascal ... amples.zip

Enjoy !!!
Last edited by yo2lio on 27 Jan 2008 21:27, edited 2 times 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:

Ethernet library V3.2 and example for LV18FJ board

#13 Post by yo2lio » 19 Aug 2007 23:49

Coming soon : Ethernet library V3.2 and example for LV18FJ board

This library is SMALLER and FASTER.
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:

#14 Post by yo2lio » 21 Aug 2007 20:52

Ethernet library V 3.2 MCU family PIC18F97J60

Major changes !!! Some parts from V3.2 library is written in ASM and use indirect addressing and DMA.
Library is 10% smaller and faster.

Added few routine in "aditional_string_lib":

Code: Select all

- Function Str2Byte(var byte_in : string[3]) : byte;
   
- Function Str2Word(var word_in : string[5]) : word;

- Procedure Byte2Hex(data_hex : byte; var hex : string[2]);

- Function Hex2Byte(var hex : string[2]) : byte;

- Procedure Ip2Str(var user_ip_addr : IpHeader; var str_out : string[15]);

- Procedure Mac2Str(var mac_address : MacHeader; var str_out : string[12]);

- Procedure Str2Ip(var str_in : string[15]; var user_ip_addr : IpHeader);

- Procedure Str2Mac(var str_in : string[12]; var mac_address : MacHeader);

Added 2 advance procedures :

Code: Select all

- Procedure CopyEthMemToRam_Inv(start_eth_address, dest_ram_address, length_w : word);
  // Ex. CopyEthMemToRam(AddrPacket+6,@data_dWord,4);

- Procedure CopyRamToEthMem_Inv(start_ram_address, dest_eth_address, length_w : word);
  // Ex. CopyRamToEthMem(@data_dWord,TXSTART+22,4);

You have ARP, ICMP, UDP, TCP, Mini Web Server examples, designed for LV18FJ board.

Image

Parameters :

ARP response time : 317 us
ICMP response time, packet size 32 bytes : 330 us
ICMP response time, packet size 1472 bytes : 3.2 ms
TCP connection response time : 620 us

UDP ECHO response time, method Eth_PutByte(Eth_GetByte), packet size 1442 bytes : 9.7 ms
Bandwidth : 1.3 Mbits/s UP/DOWN
Image

UDP ECHO response time, method CopyEthMemToEthMem(AddrPacket+42, TXSTART+42, len_U, 0), packet size 1442 bytes : 3.4 ms
Bandwidth : 3.0 Mbits/s UP/DOWN
Image

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

UDP BootLoader V3 , smaller and faster, you can download here : http://www.mikroe.com/forum/viewtopic.php?t=11259
Last edited by yo2lio on 27 Jan 2008 21:28, 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

Donald Shimoda
Posts: 553
Joined: 27 Feb 2006 17:00
Location: Argentina
Contact:

#15 Post by Donald Shimoda » 12 Sep 2007 18:48

Then theres some version for enc38j60 library?

TIA
Donald Shimoda.

Post Reply

Return to “mikroPascal General”