ENC28J60 Library V3.3 full source code

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

#31 Post by yo2lio » 05 Feb 2008 14:07

guyfoc wrote:i see also a new line '#DEFINE HARD_CKSUM in the .pbas
suppose it must be with comment '
I have two routine for checksum. First use DMA from ENC28J60 and second make checksum software.

So from ENC28j60 erata :

Code: Select all

15. Module: DMA

If the DMA module is operated in Checksum mode (ECON1.CSUMEN, DMAST = 1) at any time while a packet is currently being received from the Ethernet (ESTAT.RXBUSY = 1), the packet being received will be aborted.

The packet abort will cause the Receive Error Interrupt Flag (EIR.RXERIF) to be set, the interrupt will occur (if enabled) and the Buffer Error Status bit (ESTAT.BUFER) also will become set. The packet will be permanently lost. 

Work around
 
Do not use the DMA module to perform checksum calculations. Instead, perform checksums in software.

This problem does not affect the DMA copy operation (ECON1.CSUMEN = 0). 
This BUG not persist in PIC18F97J60.
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

guyfoc
Posts: 297
Joined: 09 Sep 2005 11:34
Location: belgium

#32 Post by guyfoc » 05 Feb 2008 14:22

thanks for clarify
for info:
i test again with the lib2.pbas in the place of the lib2.mcl
not ok always the same msg
i do not see where is located this function in the lib2.pbas
things we are knowing are always easy

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

#33 Post by yo2lio » 05 Feb 2008 14:48

guyfoc wrote:thanks for clarify
for info:
i test again with the lib2.pbas in the place of the lib2.mcl
not ok always the same msg
i do not see where is located this function in the lib2.pbas
You can not replace lib2.mcl with lib2.pbas. Must replace lib1 and lib2.

Anyway , all my library was developed in MikroPascal. Source code in MikroPascal will be updated periodically . You must use *.mcl file generated by MikroPascal from ARP folder (for example).

Source code from ENC_V3_3_Source folder is just for your info.
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

guyfoc
Posts: 297
Joined: 09 Sep 2005 11:34
Location: belgium

#34 Post by guyfoc » 05 Feb 2008 16:41

ok thanks again for info s :D
will take care of that
i make some cleanup in my prog to save place...and seems working well
things we are knowing are always easy

guyfoc
Posts: 297
Joined: 09 Sep 2005 11:34
Location: belgium

#35 Post by guyfoc » 07 Feb 2008 08:29

i try a 18F4680 in the place off the 4520 to have more rom and works ok
good job florin :D
( rem i see also when doing this change that the line cmcon=7 had disapear from my prog ( d.3 no more working)from more days... it was working for the 4520 ..without but...chance probably... :twisted: )
things we are knowing are always easy

sergio_r
Posts: 7
Joined: 25 Jan 2008 18:08
Location: Ukraine

#36 Post by sergio_r » 07 Feb 2008 22:32

All greetings!
That is necessary what to use ENC28J60 Library with PIC18f452 or PIC18F4620, any example does not work for me from MikroBasic_ENC_V3_3_Examples.
Beforehand thanks! :(

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

#37 Post by yo2lio » 08 Feb 2008 06:59

sergio_r wrote:That is necessary what to use ENC28J60 Library with PIC18f452 or PIC18F4620, any example does not work for me from MikroBasic_ENC_V3_3_Examples.
What hardware you use ?

Please put a piece of code here ...
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

guyfoc
Posts: 297
Joined: 09 Sep 2005 11:34
Location: belgium

#38 Post by guyfoc » 08 Feb 2008 09:34

i test the udp_send ( do not forget to put your ip and port s...)
it is easy to understand and was working for me
give the ex of the pgm you use and your config
does your hardware works ok with the MB lib ?
things we are knowing are always easy

sergio_r
Posts: 7
Joined: 25 Jan 2008 18:08
Location: Ukraine

#39 Post by sergio_r » 08 Feb 2008 10:01

I do not use development Board for the Microchip.
I have made a payment for PIC18F452 (PIC18F4620) + ENC28J60.
Connections:
PIC ----------------------- ENC
C0 ------------------------ RESET
C1 ------------------------ CS
C2 ------ 74HCT125 ---- INT
C3 ------------------------ SCK
C4 ----- 74HCT125 ----- SO
C5 ------------------------ SI
C7 ------ 74HCT125 ----- WOL
Quartz resonator PIC-10Mhz(HS w/Pll ON). Used your examples UDP_Echo

Code: Select all

'Ethernet library V3.3 and example for ENC28J60.

' ARP, ICMP, UDP, NTP, TCP, HTTP

' Author of this project : Florin Andrei Medrea
' Copyright (c) 2008 - YO2LIO - All Rights Reserved
' 29-Jan-2008

' Receive UDP packet and return to sender
' You have a small prog for windows ( UDP Echo ) for test this program '

' Attention !!!! This program uses TMR1 or TMR2 interrupt at 1 ms !!!!!!!!!
'  User can select between TMR1 and TMR2 interrupt '

'#DEFINE TMR1_Interrupt
#DEFINE TMR2_Interrupt

include "mb_aditional_string_util" ' Don't touch this lines !!!!!
include "lib1_ENC28J60_V3_3"
include "enc_lib_user"
include "lib2_ENC28J60_V3_3"

#IFDEF TMR1_Interrupt
sub procedure interrupt ' with TMR1 timer
  if PIR1.TMR1IF = 1 then      ' 1 ms TMR1 Q=40 MHz
    PIR1.TMR1IF=0
    TMR1L = 0x1E
    TMR1H = 0xFB
    CounterTask  ' must called at 1ms
  end if
end sub

Sub Procedure Init ' with TMR1 timer interrupt
  ClrWdt
'  WDTCON = 1
  TMR1L = 0x1E
  TMR1H = 0xFB               ' 1 ms TMR1 Q=40 MHz prescaler 8
  PIE1 = %00000001
  T1CON = %10110001          ' prescaler 8 16 bit mod
  INTCON = %11000000         ' intrerupere TMR1 la 1 ms
End Sub
#ENDIF

#IFDEF TMR2_Interrupt
sub procedure interrupt ' with TMR2 timer
  if TestBit(PIR1,TMR2IF) = 1 then      ' 1 ms TMR2 Q=40 MHz
    PIR1.TMR2IF=0
    CounterTask  ' must called at 1ms
  end if
end sub

Sub Procedure Init ' with TMR2 timer interrupt
  ClrWdt
'  WDTCON = 1
  PIE1 = %00000010
  PR2 = 250
  T2CON = %01001001          ' prescaler 4, poscaler 10
  TMR2 = 0
  T2CON.TMR2ON = 1           ' start TMR2
  INTCON = %11000000         ' intrerupere TMR2 la 1 ms
End Sub
#ENDIF

Sub Procedure Eth_SetParameters   ' set your parameters here
  Str2Ip("192.168.1.253",eth_ip_addr)
  Str2Ip("192.168.1.1",eth_gateway)
  Str2Ip("255.255.255.0",eth_mask)
  Str2Mac("0004A3008080",eth_mac)

  eth_port = 10001
  dest_port = 10001
end sub

main:
  'CMCON = CMCON or $07                 ' turn off comparators
  ADCON1 = $0F                         ' all pins digital
  'MEMCON.EBDIS = 1                     ' disable external memory bus
  Init
  TRISA.5 = 0 ' for PIC18F4520, PIC18F2520 ...
  nop
  PORTA.5 = 0
  'TRISD.7 = 0 ' for PIC18F8722
  'nop
  'PORTD.7 = 0
  'TRISF.7 = 0 ' for PIC18F8722
  'nop
  'PORTF.7 = 0
  Spi_Init_Advanced(MASTER_OSC_DIV4, DATA_SAMPLE_MIDDLE, CLK_IDLE_LOW, LOW_2_HIGH)
  Eth_SetParameters
  Eth_Init_(PORTC, 1, 0)'(ENC_Port, CS, Reset)
'  Firewall(true,false,false)
  Wait_For_Lan
  while true
      Eth_DoPacket ' process incoming packets
  wend
end.
I only start to master Ethernet and consequently....

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

#40 Post by yo2lio » 08 Feb 2008 14:01

Are the Mikroe examples working on your hardware ?
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

sergio_r
Posts: 7
Joined: 25 Jan 2008 18:08
Location: Ukraine

#41 Post by sergio_r » 08 Feb 2008 14:16

Yes, other examples Mikroe work fine.
Has now decided to try to study Ethernet, but here difficulties...

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

#42 Post by yo2lio » 08 Feb 2008 14:54

Please tell me , what not work at this example ? Do you get a ping ?
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

sergio_r
Posts: 7
Joined: 25 Jan 2008 18:08
Location: Ukraine

#43 Post by sergio_r » 08 Feb 2008 17:09

No, I do not receive the answer on ping 192.168.1.253 and there is no reception of the data in UDP Echo Prog. :cry:

sergio_r
Posts: 7
Joined: 25 Jan 2008 18:08
Location: Ukraine

#44 Post by sergio_r » 08 Feb 2008 17:18

As I think, that at me difficulty with SPI.
At data transfer from UDP Echo Prog ENC28J60 LEDB blinks, LEDA burns.

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

#45 Post by yo2lio » 08 Feb 2008 18:03

Udp_Echo examples, tested now by me, again, and everything it's OK !!!
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 “mikroBasic General”