MikroC Ethernet lib RX filters wrong ...

Discuss about beta versions of mikroC compiler.
Author
Message
yo2lio
Posts: 1878
Joined: 19 Sep 2006 12:57
Location: Romania, Arad City
Contact:

MikroC Ethernet lib RX filters wrong ...

#1 Post by yo2lio » 30 Jan 2008 12:08

Hi ... ME TEAM ?

Have you read this post ?
http://www.mikroe.com/forum/viewtopic.php?t=13169

You made, Ethernet library, in the hurry !

I don't know about ENC28J60 but for PIC18F97J60 family :

Code: Select all

MOVFF	_Ethernet_macAddr+5, MAADR1
MOVFF	_Ethernet_macAddr+4, MAADR2
MOVFF	_Ethernet_macAddr+3, MAADR3
MOVFF	_Ethernet_macAddr+2, MAADR4
MOVFF	_Ethernet_macAddr+1, MAADR5
MOVFF	_Ethernet_macAddr, MAADR6
This was also my mistake in the past ....

Corrected version :

ERXFCON = 0b10100001; // default value

MAADR1 = Ethernet_macAddr[0];
MAADR2 = Ethernet_macAddr[1];
MAADR3 = Ethernet_macAddr[2];
MAADR4 = Ethernet_macAddr[3];
MAADR5 = Ethernet_macAddr[4];
MAADR6 = Ethernet_macAddr[5];

With your library , users can not use RX FILTERS.

Anyway, please, if it possible, don't make this mistake in MikroPascal !!!!!

PS. In WW network, with real IP, when BROADCAST traffic is huge, ENC28J60 and PIC18F97J60 don't work without RX FILTERS.
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:

Re: MikroC Ethernet lib RX filters wrong ...

#2 Post by yo2lio » 30 Jan 2008 18:17

srdjan wrote:I have checked these and it seems that you are right about this. I'll do some additional tests and if we confirm this, the library will be updated. Furthermore, I will see to implement a possibility for the users to choose filters to be applied when initializing the ethernet module.
Thanks.
Beers to me ! :D
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

User avatar
srdjan
mikroElektronika team
Posts: 1552
Joined: 28 Dec 2005 12:47
Location: Serbia

Re: MikroC Ethernet lib RX filters wrong ...

#3 Post by srdjan » 30 Jan 2008 18:22

Deleted by mistake. Sorry. :-(
Hi ... ME TEAM ?

Have you read this post ?
http://www.mikroe.com/forum/viewtopic.php?t=13169

- My colleagues from tech support have missed to assign this post of yours to me.
You made, Ethernet library, in the hurry !

I don't know about ENC28J60 but for PIC18F97J60 family :

Code:
MOVFF _Ethernet_macAddr+5, MAADR1
MOVFF _Ethernet_macAddr+4, MAADR2
MOVFF _Ethernet_macAddr+3, MAADR3
MOVFF _Ethernet_macAddr+2, MAADR4
MOVFF _Ethernet_macAddr+1, MAADR5
MOVFF _Ethernet_macAddr, MAADR6


This was also my mistake in the past ....

Corrected version :

ERXFCON = 0b10100001; // default value

MAADR1 = Ethernet_macAddr[0];
MAADR2 = Ethernet_macAddr[1];
MAADR3 = Ethernet_macAddr[2];
MAADR4 = Ethernet_macAddr[3];
MAADR5 = Ethernet_macAddr[4];
MAADR6 = Ethernet_macAddr[5];

With your library , users can not use RX FILTERS.
- I have checked these and it seems that you are right about this for the enc28j60 library. The library for the internal ethernet module should work. I'll do some additional tests and if we confirm this, the library will be updated. Furthermore, I will see to implement a possibility for the users to choose filters to be applied when initializing the ethernet module.
Thanks.

bruno
Posts: 767
Joined: 10 Sep 2005 02:10
Location: Lyon, France
Contact:

#4 Post by bruno » 31 Jan 2008 09:23

Hi,

don't forget that mC ENC lib does not use the same MADDRx definitions as microchip, so the MAC addr either in registers and on wires has always been correct : you can check it with arp command from a remote host for example.

to me, RX filters work good, but if I missed something and if they don't there must be something else to check ?
did you ever get unwanted packets with different MAC addr in rec buffer ?
or nothing at all in rec buf ?
Bruno
Bored with 7-segment ? Try the [url=http://www.micro-examples.com/public/microex-navig/doc/079-touchclock.html]TouchClock[/url]

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

#5 Post by yo2lio » 31 Jan 2008 09:49

Hi Bruno,

It's possible to be correct for ENC28J60 lib, but for PIC18F97J60 is not !
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

bruno
Posts: 767
Joined: 10 Sep 2005 02:10
Location: Lyon, France
Contact:

#6 Post by bruno » 31 Jan 2008 09:57

do you mean MAC addr is not correct, or filtering is not correct ?

to me, arp and eth sniffing on LV18FJ as on your board give correct results :

Code: Select all

unsigned char   macAddr[6] = {0x00, 0x14, 0xA5, 0x76, 0x19, 0x3f} ;   // my MAC address
C:\>arp -a

Interface : 192.168.1.139 --- 0x10003
Adresse Internet Adresse physique Type
192.168.1.7 00-04-75-d3-1b-e2 dynamique
192.168.1.25 00-0b-6a-7e-88-a4 dynamique
192.168.1.129 00-18-39-1f-28-f4 dynamique
192.168.1.142 00-14-a5-76-19-3f dynamique
192.168.1.253 00-30-4f-34-cf-f5 dynamique
Bruno
Bored with 7-segment ? Try the [url=http://www.micro-examples.com/public/microex-navig/doc/079-touchclock.html]TouchClock[/url]

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

#7 Post by yo2lio » 31 Jan 2008 10:12

bruno wrote:do you mean MAC addr is not correct, or filtering is not correct ?
Filtering is not correct !

Must be :

Code: Select all

MAADR1 = Ethernet_macAddr[0];
MAADR2 = Ethernet_macAddr[1];
MAADR3 = Ethernet_macAddr[2];
MAADR4 = Ethernet_macAddr[3];
MAADR5 = Ethernet_macAddr[4];
MAADR6 = Ethernet_macAddr[5]; 
and ERXFCON = 0b10100001;

Believe me, in real network don't work without filters ....

I have now in real network ( RDS and UPC romanian providers) with real IP's , more than 50 devices with PIC18F67J60 (working 24 hours / day) !!! And without filters don't work, the broadcast traffic is huge !!!
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

bruno
Posts: 767
Joined: 10 Sep 2005 02:10
Location: Lyon, France
Contact:

#8 Post by bruno » 31 Jan 2008 15:51

:!: OK

After some tests I think I understand.

FIRST :
Florin is right : filters work only has he says

SECOND :
in library, ENC works in promiscuous mode :

Code: Select all

ERXFCON = 0x20 ;
it was set so for development purpose... and has never been changed :oops:
so it hides the problem.

THIRD :
when setting MAC address in MAADRx registers :
- the FILTERS use the MAADRx registers
- the MAC address sent over the wires does not come from MAADRx registers but from a cache. this cache is a stack of registers : any write in MAADRx pushes the new value onto the stack.
for example you can set the MAC address this way :

Code: Select all

MAADR1 = macAddr[0];
MAADR1 = macAddr[1];
MAADR1 = macAddr[2];
MAADR1 = macAddr[3];
MAADR1 = macAddr[4];
MAADR1 = macAddr[5];
with this code, the device will communicate, but filters will not work.

:twisted: twisted isn't it ?

:?: Srdjan, are you ready to ask confirmation of this to microchip :lol: :lol: :lol:


CONCLUSION :
the workaround is to add Florin's code :

Code: Select all

MAADR1 = macAddr[0] ;
MAADR2 = macAddr[1] ;
MAADR3 = macAddr[2] ;
MAADR4 = macAddr[3] ;
MAADR5 = macAddr[4] ;
MAADR6 = macAddr[5] ;
ERXFCON = 0b10100001 ;
after the Ethernet_Init() call.
Bruno
Bored with 7-segment ? Try the [url=http://www.micro-examples.com/public/microex-navig/doc/079-touchclock.html]TouchClock[/url]

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

#9 Post by yo2lio » 31 Jan 2008 15:54

Thank you Bruno ! :D
CONCLUSION :
the workaround is to add Florin's code :

Code:
MAADR1 = macAddr[0] ;
MAADR2 = macAddr[1] ;
MAADR3 = macAddr[2] ;
MAADR4 = macAddr[3] ;
MAADR5 = macAddr[4] ;
MAADR6 = macAddr[5] ;
ERXFCON = 0b10100001 ;

after the Ethernet_Init() call.
I don't know if this work without disabling and enabling Ethernet RX module.

The right choice is to put this in Ethernet_Init() routine.
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

User avatar
srdjan
mikroElektronika team
Posts: 1552
Joined: 28 Dec 2005 12:47
Location: Serbia

#10 Post by srdjan » 31 Jan 2008 16:21

Hi,
bruno wrote: :twisted: twisted isn't it ?
Spooky :shock:
bruno wrote: :?: Srdjan, are you ready to ask confirmation of this to microchip :lol: :lol: :lol:

- I'll be more than happy to do so :wink:
Last edited by srdjan on 31 Jan 2008 16:26, edited 1 time in total.

User avatar
srdjan
mikroElektronika team
Posts: 1552
Joined: 28 Dec 2005 12:47
Location: Serbia

#11 Post by srdjan » 31 Jan 2008 16:25

Hi,
yo2lio wrote: I don't know if this work without disabling and enabling Ethernet RX module.

The right choice is to put this in Ethernet_Init() routine.
I'm working on changing the init routine to receive filter configuration as we speak. My plans are to make crc filtering default and allow users to set mac broadcast, unicast and multicast filters as well as and/or filter mode.

Code: Select all

void    Spi_Ethernet_Init(unsigned char *mac, unsigned char *ip, unsigned char configFlags)

Code: Select all

configFlags:

bit         7    6   5   4   3     2     1     0
meanning  ANDOR  x   x   x  UCEN  MCEN  BCEN  DPLX
ANDOR - and/or filter mode
UCEN - Unicast filter enable
MCEN - Multicast flter enable
BCEN - Broadcast filter enable
DPLX - duplex mode
So, with, crc filter enabled by default, the current codes will be 100% compatible.
Any suggestions?
Last edited by srdjan on 31 Jan 2008 16:37, edited 1 time in total.

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

#12 Post by yo2lio » 31 Jan 2008 16:35

srdjan wrote:My plans are to make crc filtering default and allow users to set mac broadcast, unicast and multicast filters as well as and/or filter mode.
Hmmm ....

I don't know if users understand Ethernet filters !

So, my opinion : CRC, UCEN, BROADCAST default and possibility to change this if users want. Anyway this is Microchip default setting (POR)
ERXFCON = 0b10100001
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

bruno
Posts: 767
Joined: 10 Sep 2005 02:10
Location: Lyon, France
Contact:

#13 Post by bruno » 31 Jan 2008 16:42

srdjan wrote:I'm working on changing the init routine to receive filter configuration as we speak. My plans are to make crc filtering default and allow users to set mac broadcast, unicast and multicast filters as well as and/or filter mode. Any suggestions?
Yes, promiscuous mode will be useful too :mrgreen:

Do you plan to deal with pattern matching, magic packet filtering and hash table too ?
AND/OR modes will already need a lot of support :?

I suggest :
CRC on/off
unicast on/off
multicast on/off
brodcast on/off
in OR mode
and advanced packet filtering is handled directly by user
Bruno
Bored with 7-segment ? Try the [url=http://www.micro-examples.com/public/microex-navig/doc/079-touchclock.html]TouchClock[/url]

User avatar
srdjan
mikroElektronika team
Posts: 1552
Joined: 28 Dec 2005 12:47
Location: Serbia

#14 Post by srdjan » 31 Jan 2008 16:46

yo2lio wrote:
srdjan wrote:My plans are to make crc filtering default and allow users to set mac broadcast, unicast and multicast filters as well as and/or filter mode.
Hmmm ....

I don't know if users understand Ethernet filters !

So, my opinion : CRC, UCEN, BROADCAST default and possibility to change this if users want. Anyway this is Microchip default setting (POR)
ERXFCON = 0b10100001
Well, I can not enable those filters and allow user to change them in the same time in init routine. It will have to be, either let users take care of filters or set them by default.

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

#15 Post by yo2lio » 31 Jan 2008 16:47

Hei ...... Who edit my message !!!!! :evil: :evil: :evil: :evil: :evil:
Well, I can not enable those filters and allow user to change them in the same time in init routine. It will have to be, either let users take care of filters or set them by default.
I don't say that !! :shock:
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 “mikroC Beta testing”