|
|
View previous topic :: View next topic |
Author |
Message |
a3ka2000
Joined: 26 Feb 2010 Posts: 11
|
help with CCS TCP/IP stack tutorial |
Posted: Sun Mar 07, 2010 11:14 pm |
|
|
Dear friends,
I want to use CCS version of TCP/IP stack from Microchip. Now I'm using a new prototype board of my own with simply involves dsPIC30F6014 and stand alone ethernet controller ECN28J60. The circuit is attached below:
I again followed ethernet development exercise book (tutorial) from CCS, starting from MAC address, i.e. with filename "ex7a.c". The code is following the tutorial, and can be seen below:
Code: |
#include "ccstcpip.h"
void MACDisplayHeader(MAC_ADDR *mac, int8 type) {
int8 i;
printf("\r\nMAC: ");
for (i=0;i<6;i++) {
printf("%X", mac->v[i]);
if (i!=5)
putc(':');
}
printf(" ANAN:0x08%X ",type);
if (type==MAC_IP)
printf("[IP]");
else if (type==MAC_ARP)
printf("[ARP]");
}
void main(void) {
MAC_ADDR mac;
int8 type, i = 0;
printf("\r\n\nCCS TCP/IP TUTORIAL 7A\r\n");
output_high(PIN_D7);
MACInit();
while(i<5) {
if (MACGetHeader(&mac, &type)) {
if (type!=MAC_UNKNOWN) {
MACDisplayHeader(&mac, type);
}
}
i++;
}
} |
This is the ccstcpip header code
Code: | #define STACK_USE_CCS_PICENS 1
#define STACK_USE_CCS_PICNET 0
#define STACK_USE_CCS_PICEEC 0 //TODO
#if STACK_USE_CCS_PICENS
#define STACK_USE_MCPENC 1
#endif
#if STACK_USE_CCS_PICEEC
#define STACK_USE_MCPINC 1
#endif
#if STACK_USE_CCS_PICENS
#include <30F6014A.h>
#use delay(clock = 10000000, xtal) //define clock freq and type
#use rs232(baud = 9600, xmit = PIN_F3, rcv = PIN_F2)
#define (icd = true) //allow icd debugging?
#else
#error You need to define your custom hardware
#endif
#include "drivers/stacktsk.c" //include Microchip TCP/IP Stack
void MACAddrInit(void) {
MY_MAC_BYTE1=1;
MY_MAC_BYTE2=2;
MY_MAC_BYTE3=3;
MY_MAC_BYTE4=4;
MY_MAC_BYTE5=5;
MY_MAC_BYTE6=6;
}
void IPAddrInit(void) {
//IP address of this unit
MY_IP_BYTE1=192;
MY_IP_BYTE2=168;
MY_IP_BYTE3=100;
MY_IP_BYTE4=7;
//network gateway
MY_GATE_BYTE1=192;
MY_GATE_BYTE2=168;
MY_GATE_BYTE3=100;
MY_GATE_BYTE4=1;
//subnet mask
MY_MASK_BYTE1=255;
MY_MASK_BYTE2=255;
MY_MASK_BYTE3=255;
MY_MASK_BYTE4=0;
}
char ExampleIPDatagram[] = {
0x45, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00,
0x64, 0x11, 0x2A, 0x9D, 0x0A, 0x0B, 0x0C, 0x0D,
0x0A, 0x0B, 0x0C, 0x0E
};
char ExampleUDPPacket[] = {
0x04, 0x00, 0x04, 0x01, 0x00, 0x08, 0x00, 0x00,
0x01, 0x02, 0x03, 0x04
};
|
After I compiled and programmed using PCD 4.057 (no error!), I connect the board to the network switch and from there to the PC using straight cables. After I reset the board, there's no answer at all to the HyperTerminal!! Only "CCS TCP/IP TUTORIAL 7A" and one LED lit up by output_high command!! :(
There is something wrong with the ethernet/SPI interface? I probably misunderstood the code wrongly. Which variable to define my board MAC address?
thank you
warm wishes |
|
|
dezso
Joined: 04 Mar 2010 Posts: 102
|
|
Posted: Mon Mar 08, 2010 10:02 am |
|
|
Code: | void MACAddrInit(void) {
MY_MAC_BYTE1=1;
MY_MAC_BYTE2=2;
MY_MAC_BYTE3=3;
MY_MAC_BYTE4=4;
MY_MAC_BYTE5=5;
MY_MAC_BYTE6=6;
} |
your mac here is 01:02:03:04:05:06
I believe this is a valid mac address.
most are look like this 00:23:AF:3C:F2:01
http://en.wikipedia.org/wiki/MAC_address
Your gateway is the same as your TCP/IP setting on your PC/Router gateway address ? 192.168.100.1 this again not the default for any router, 192.168.1.1 are the most common.
I have used ETH to RS232 module but newer compiled any code for my own TCP/IP device.
Hope you can get this working, I'm interested hows its goes, have a few 2860 chip here, maybe I can follow your development. |
|
|
a3ka2000
Joined: 26 Feb 2010 Posts: 11
|
|
Posted: Mon Mar 08, 2010 8:49 pm |
|
|
dezso wrote: | Code: | void MACAddrInit(void) {
MY_MAC_BYTE1=1;
MY_MAC_BYTE2=2;
MY_MAC_BYTE3=3;
MY_MAC_BYTE4=4;
MY_MAC_BYTE5=5;
MY_MAC_BYTE6=6;
} |
your mac here is 01:02:03:04:05:06
I believe this is a valid mac address.
most are look like this 00:23:AF:3C:F2:01
http://en.wikipedia.org/wiki/MAC_address
Your gateway is the same as your TCP/IP setting on your PC/Router gateway address ? 192.168.100.1 this again not the default for any router, 192.168.1.1 are the most common.
I have used ETH to RS232 module but newer compiled any code for my own TCP/IP device.
Hope you can get this working, I'm interested hows its goes, have a few 2860 chip here, maybe I can follow your development. |
Hmm... The address actually follow the example (tutorial). By right, it should be working fine. |
|
|
dezso
Joined: 04 Mar 2010 Posts: 102
|
|
Posted: Mon Mar 08, 2010 10:45 pm |
|
|
If your gateway address is 192.168.1.1 than you have to set your ccstcpip header code to use this gateway !
I'm not expert on TCP/IP, but almost sure if your gateway is set to 192.168.100.1 then your code will be trying to send the request to the wrong address. Not sure if I making it clear or not, just change your gateway in your code for the same one as in your PC TCP/IP setting.
If the hardware is right and the rest of the code functions the way it's supposed to be it should work.
Quote: |
I connect the board to the network switch and from there to the PC using straight cables
|
You got the link/activity light "on" on your switch ?
Check your PC TCP/IP setting "ipconfig"
Code: |
IPv4 Address. . . . . . . . . . . : 192.168.1.2
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.1.1
|
|
|
|
monsters_inc
Joined: 18 Jan 2010 Posts: 14
|
|
Posted: Wed Mar 10, 2010 1:55 pm |
|
|
Hi. When I use mac 01:02:03:04:05:06 with "ex_st_webserver.c" and dhcp enabled it can't get IP. When I change mac to 00:02:03:04:05:06 dhcp works fine. |
|
|
dezso
Joined: 04 Mar 2010 Posts: 102
|
|
Posted: Wed Mar 10, 2010 9:26 pm |
|
|
Quote: | If the least significant bit of the most significant byte is set to a 0, the packet is meant to reach only one receiving NIC. This is called unicast. If the least significant bit of the most significant byte is set to a 1, the packet is meant to be sent only once but still reach several NICs. This is called multicast |
From wiki
|
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
|
|
Posted: Thu Mar 11, 2010 11:19 pm |
|
|
monsters_inc wrote: | Hi. When I use mac 01:02:03:04:05:06 with "ex_st_webserver.c" and dhcp enabled it can't get IP. When I change mac to 00:02:03:04:05:06 dhcp works fine. |
Either MAC should work fine.
I've used a wide variety of MAC addy's to play around or even assign a constant DHCP address..
Look on your DHCP server or with wireshark to see why.
-Ben _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
a3ka2000
Joined: 26 Feb 2010 Posts: 11
|
|
Posted: Sun Mar 14, 2010 7:26 pm |
|
|
Hmm... talking about my original problem, I found the root-cause to be the SPI hardware function. I'm using SPI-2 port (pin G6, G7, G8 for dsPIC30F6014).
Apparently when I used setup_spi2 and spi_read2, etc., it didn't show any pulse activities. If I change back to SPI-1 port, I shows activities. Not sure why? I don't find any conflict on the codes.
I will continue to the next tutorial.... Let's see how.
thanks |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|