Problem Pinging The Serial Ethernet Card

Post your requests and ideas on the future development of mikroBasic.
Post Reply
Author
Message
TheViper
Posts: 6
Joined: 17 Nov 2006 02:03

Problem Pinging The Serial Ethernet Card

#1 Post by TheViper » 17 Nov 2006 02:24

Greetings All,

By searching through the forum, I have bee able to solve a lot of my problems with my serial ethernet card. (ie: download latest MB, etc.)

I do have a problem pinging that I cant find by searching the forums.

Because there's not a lot of documentation, I've made some assumptions about the setup. I'm using an EasyPic3 board. The jumper cable is connected to PORTC on the EP3 board and into CN1 port on the ethernet card.

First, when I was attempting to use the ping example in the EP3 ethernet samples, I got a link error:

linker error: _spi_ethernet_userudp: label not found

I dont get this error if I use the EP4 Ping sample. I've also used the SetIP_MACAddress example in the EP3 folder and simply added the SPI_Ethernet_doPacket(), which basically makes the program identical to the ping example, and it links fine. So I got around this linker error, but I'm still not sure why its occuring.

Ok, so once I did this and set my IP address on the card, I compiled and burned the program in. After this occurs, the LEDA light comes on. I take this as a good sign. I assume this means that my cable from the EP3 to the Serial Ethernet Card is correct.

I have an ethernet cable going from the card to a linksys network hub. I have a laptop pc that is also plugged into this hub. Both ports on the hub are lit after the program is burned in. Again, I take this as a good sign.

So I try to ping the address I set the Serial Card to. It times out, but I do see LEDB blink as the ping goes out.

So my question is, do I need to add anything to this program for it to respond back to the ping? The only line of code I have now is the code thats in the ping example, which is SPI_Ethernet_doPacket(). Do I need some other code for it to respond to a ping request, or should this be all I need.

Thanks in advance. And here's a copy of the code. Its basically the SetIP_MACAddress program with the one additional dopacket line.




program enc_ethernet

include "enc_eth"
include "enc_utils" ' this is where you should write implementation for UDP and HTTP

'{***********************************
' * RAM variables
' *}
dim myMacAddr as byte[6] ' my MAC address
myIpAddr as byte[4] ' my IP address

main:

ADCON1 = 0x0F ' turn off ADC convertors
CMCON = 0x07 ' turn off comparators

myMacAddr[0] = 0x00
myMacAddr[1] = 0x14
myMacAddr[2] = 0xA5
myMacAddr[3] = 0x76
myMacAddr[4] = 0x19
myMacAddr[5] = 0x3F

myIpAddr[0] = 10
myIpAddr[1] = 0
myIpAddr[2] = 0
myIpAddr[3] = 2

'*
'* starts ENC28J60 with :
'* reset bit on RC0
'* CS bit on RC1
'* my MAC & IP address
'* full duplex
'*

SPI_init()
SPI_Ethernet_Init(PORTC, 0, PORTC, 1, myMacAddr, myIpAddr, SPI_Ethernet_FULLDUPLEX)
while true ' do forever
SPI_Ethernet_doPacket() ' process incoming Ethernet packets

wend
end.

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

Re: Problem Pinging The Serial Ethernet Card

#2 Post by srdjan » 17 Nov 2006 11:33

Hi,
First of all, you should place these kind of posts onto mikroBasic General forum and not here. It's not such a big deal, but helps avoiding confusions.
TheViper wrote:Greetings All,
First, when I was attempting to use the ping example in the EP3 ethernet samples, I got a link error:

linker error: _spi_ethernet_userudp: label not found

I dont get this error if I use the EP4 Ping sample. I've also used the SetIP_MACAddress example in the EP3 folder and simply added the SPI_Ethernet_doPacket(), which basically makes the program identical to the ping example, and it links fine. So I got around this linker error, but I'm still not sure why its occuring.
I have compiled and tried the EP3 ping example and it works.
Check project paths (Tools->Options->Search Paths) and clear all wrong ones.
TheViper wrote: Ok, so once I did this and set my IP address on the card, I compiled and burned the program in. After this occurs, the LEDA light comes on. I take this as a good sign. I assume this means that my cable from the EP3 to the Serial Ethernet Card is correct.

I have an ethernet cable going from the card to a linksys network hub. I have a laptop pc that is also plugged into this hub. Both ports on the hub are lit after the program is burned in. Again, I take this as a good sign.

So I try to ping the address I set the Serial Card to. It times out, but I do see LEDB blink as the ping goes out.

So my question is, do I need to add anything to this program for it to respond back to the ping? The only line of code I have now is the code thats in the ping example, which is SPI_Ethernet_doPacket(). Do I need some other code for it to respond to a ping request, or should this be all I need.
The code is OK, there is nothing to be added.
You should check your oscillator clock and configuration words settings.
Also, could it be that your laptop's subnet mask setting is not appropriate for IP set in the serial ethernet board.
Try using some ethernet analyzer program (Ethereal...) to snif packets on the network and see wether pic reply's to ping request or not.
If it does then it is probably IP address/subnet mask settings that are causing the problem.

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

Re: Problem Pinging The Serial Ethernet Card

#3 Post by srdjan » 17 Nov 2006 11:45

TheViper wrote:The jumper cable is connected to PORTC on the EP3 board and into CN1 port on the ethernet card.
I have just spotted one more thing that could be crucial for your problem.
The jumper cable should be connected to CN3 (SPI-PIC) port on the serial ethernet board side. According to the board that I have here (HW.Rew 2.20) CN1 port is for dsPIC mcus.
However, if that is the case, I do not know how you board got initialized at all.

TheViper
Posts: 6
Joined: 17 Nov 2006 02:03

Re: Problem Pinging The Serial Ethernet Card

#4 Post by TheViper » 17 Nov 2006 15:50

srdjan wrote:
TheViper wrote:The jumper cable is connected to PORTC on the EP3 board and into CN1 port on the ethernet card.
I have just spotted one more thing that could be crucial for your problem.
The jumper cable should be connected to CN3 (SPI-PIC) port on the serial ethernet board side. According to the board that I have here (HW.Rew 2.20) CN1 port is for dsPIC mcus.
However, if that is the case, I do not know how you board got initialized at all.
Thanks, I'm gonna try CN3 later today and see if that does it.

Also, I thought I had posted this in the general forum. Dont know how I got it here, but I surprise myself sometimes. :)

TheViper
Posts: 6
Joined: 17 Nov 2006 02:03

#5 Post by TheViper » 17 Nov 2006 22:29

Connecting to CN3 solved the problem. Thanks!

Post Reply

Return to “mikroBasic Wish List”