CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

ENC28J60 + PIC18F4620 + UDP ..help..
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
lam
Guest







ENC28J60 + PIC18F4620 + UDP ..help..
PostPosted: Thu Dec 24, 2009 8:28 am     Reply with quote

I try to run ENC28J60 and send UDP packets.
My code is based on some examples from PIC CCS Stack.
Code:

#define STACK_USE_ICMP  1
#define STACK_USE_ARP   1
#define STACK_USE_UDP   1
#define UDP_SOURCE_PORT 1024
#define UDP_DESTINATION_PORT  1025
#define UDP_NUM_LISTEN_SOCKETS   2
#define MAX_SOCKETS                     6
#define MAX_UDP_SOCKETS                 4

#include<ccstcpip.h>

int8 tx_socket;
static NODE_INFO remote;


void main(void){
...

   remote.IPAddr.v[0]=200;
                 remote.IPAddr.v[1]=100;
                  remote.IPAddr.v[2]=100;
                    remote.IPAddr.v[3]=110;

...
for(;;){
 tx_socket=UDPOpen(1000, &remote,1000);
UDPPut("00010002000300040005000600070008");
UDPFlush();
UDPClose(tx_socket);
delay_ms(1000);
}

However its not working... it seems the ENC28J60 is not initialized (leds are not blinkin).

Little help will be gr8.
bkamen



Joined: 07 Jan 2004
Posts: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Thu Dec 24, 2009 5:48 pm     Reply with quote

There's a lot that isn't initialized.

You need a local IP number/netmask and optionally gateway (if you intend on passing the packet across subnets).

You need to init the 28J60 and then either set up your DHCP based IP or set it statically and then check to make sure you're not missing anything else.

Unless you left off a lot of code, there's more going on than you've posted.

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
Guest








PostPosted: Thu Dec 24, 2009 6:41 pm     Reply with quote

Correct me if im wrong...

i set

#define STACK_USE_CCS_PICENS 1 //CCS PICENS (Embedded Ethernet) development kit. 18F4620 + ENC28J60

cuz my board is using ENC28J60 and same PIC18F6420 with the standard SPI interface (hopefuly same PINs and same hardware interface is on development kit).

In the examples of CCS Stack there is no other additional initializations.
Isint it maked somehow 'inside' this twisted code by seting PICENS 1 ?

If not .. how to do it? Where to search for examples or guides?
bkamen



Joined: 07 Jan 2004
Posts: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Thu Dec 24, 2009 6:48 pm     Reply with quote

Anonymous wrote:


#define STACK_USE_CCS_PICENS 1 //CCS PICENS (Embedded Ethernet) development kit. 18F4620 + ENC28J60

cuz my board is using ENC28J60 and same PIC18F6420 with the standard SPI interface (hopefuly same PINs and same hardware interface is on development kit).

In the examples of CCS Stack there is no other additional initializations.
Isint it maked somehow 'inside' this twisted code by seting PICENS 1 ?

If not .. how to do it? Where to search for examples or guides?


I have a feeling there's more involved.

Have you even mentioned that you "hope" your PCB and the PICENS are the same. You haven't verified this!?!?

Also, have you looked at the file: ex_st_udp.c in the CCS TCP/IP Examples Source Directory? It shows a lot more going on than you've provided.

Try using THAT example code modified (and eventually stripped) to your needs.

-Ben

p.s. Do you have a book that explains the ISO Protocol stack? How about any books on TCP/IP? I'm asking since it's simply prudent to ask.
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
kaizer
Guest







PostPosted: Wed Jan 27, 2010 2:58 am     Reply with quote

Hi guys, I was able to have the latest CCS C stack for tcp/ip.

I already got a working ethernet module using mikroC compiler, but I would like to port it in ccs c since it does have lots of functions that I can do here.

Can you show me some sample initialization codes for this?

I do only want to use enc28j60 with tcp, udp, and http and a user defined IP (hard coded).

Hope that there's someone who could help me with this.

I have tried to compile it based on the samples I saw included in the stack, but unfortunately it does have a lot of error.

Thanks.
bkamen



Joined: 07 Jan 2004
Posts: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Wed Jan 27, 2010 10:25 am     Reply with quote

those examples work --- once you get the project set up for your target.

I got the sample CCS code working on an PICDEM.net2 with just the right #defines and no additional changes (except writing a new LCD module).

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
kaizer
Guest







PostPosted: Wed Jan 27, 2010 7:48 pm     Reply with quote

bkamen wrote:
those examples work --- once you get the project set up for your target.

I got the sample CCS code working on an PICDEM.net2 with just the right #defines and no additional changes (except writing a new LCD module).

-Ben


Yeah, I figured it out right after I posted my message above=)

Could you help me on how to initialize variables like this?
Code:

MY_IP_BYTE1
MY_IP_BYTE2
MY_IP_BYTE3
MY_IP_BYTE4

Got an error

Expecting (

But when I include it on a prototype function, there was no error reported. But I can seem ping the device when initialize it.

I've got to check the other settings=)
kaizer
Guest







PostPosted: Wed Jan 27, 2010 7:49 pm     Reply with quote

And also I don't have any development boards. I made it my own..=)

Based on datasheet=)
kaizer
Guest







PostPosted: Wed Jan 27, 2010 8:43 pm     Reply with quote

Hi,

I have noticed that both MAC.C and ENC28J60.c
have the MACInit() function... and they have different initialization within.

Do you think? It might conflict? They don't have any pre-conditions.

thanks
bkamen



Joined: 07 Jan 2004
Posts: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Wed Jan 27, 2010 11:02 pm     Reply with quote

If you look closely at mac.c it's not written for the enc28j60.

They are exclusive.

Look at stacktsk.c and all the includes.

Look at ex_st_webserver.c

I started there.

After adding my own "dev board" defines, I compiled and went.

I was using the Microchip PICDEM.net2 which then got converted to my own custom spun PCB with an 18F97j60. All using the same code at first and then getting extra junk stripped down and then my own stuff added.

Start with ex_st_webserver.c

It's pretty straightforward -- but it's a lot of reading to understand what goes on.

You can also look at the microchip pdf that explains all the function calls.. but you'll want to look at the code to familiarize yourself anyway.

This is definitely not a "get it done in an hour" project.

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
lejm
Guest







PostPosted: Tue Feb 02, 2010 5:00 am     Reply with quote

This example suxx bigtime. I made own driver for ENC and own Stack for UDP transmission. ;x

thx anyway Smile
bkamen



Joined: 07 Jan 2004
Posts: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Tue Feb 02, 2010 3:11 pm     Reply with quote

NO problem.

I only meant it as an example of how to get started.

I used it to get something compiled for the PICDEM.net2, and then ripped out all the stuff I didn't need in a separate project.

So.. as long as you're moving forward...

Kewl.

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
kaizer
Guest







PostPosted: Thu Feb 04, 2010 3:13 am     Reply with quote

lejm wrote:
This example suxx bigtime. I made own driver for ENC and own Stack for UDP transmission. ;x

thx anyway Smile


that's nice, hope that i could make one too..


still i cant ping my assigned IP...

hmmm
bkamen



Joined: 07 Jan 2004
Posts: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Thu Feb 04, 2010 11:05 am     Reply with quote

That's ICMP, did you include that?

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
kaizer
Guest







PostPosted: Sun Feb 28, 2010 9:22 pm     Reply with quote

bkamen wrote:
That's ICMP, did you include that?

-Ben


yes, but still no luck...

hmm what should i do Razz
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
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