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

How to use simultaneously TCPIP stack and SD card?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
stoyanoff



Joined: 20 Jul 2011
Posts: 375

View user's profile Send private message

How to use simultaneously TCPIP stack and SD card?
PostPosted: Mon Oct 01, 2012 6:15 am     Reply with quote

Hi, everyone! I have CCS Complier v4.134, TCP IP stack v30_November_06 and the mdd package. So I want to create a program which is using both - TCPIP and SD card. So I tried with one of the examples in the tcpip stack - ex7a.c
So I just added the ex_mdd_common.h:
Code:

#define ALLOW_GET_DISK_PROPERTIES   //used by 'info' command
#include "ccstcpip.h"
#include "ex_mdd_common.h"


I`ve made some changes to the ex_mdd_common.h. I stopped the device settings in this file:
Code:

#if defined(HW_CCS_3V_ETHERNET)
   // ccs 3.3v ethernet development kit, with sd connector.
   // other hardware definitions made in hardwareprofile.h
   
//   #include <18f66j60.h>

//   #fuses HS
//   #fuses NOXINST
//   #fuses NOWDT


And again the complier throws an error - you can not change the device type so far in the code and it`s pointing to the file p18Cxxx.h.

I have suspicions this row in the ex_mdd_common.h

#include "filesystem\p18cxxx.h" //C18 to PCH compatibility

makes the problems, but I`m not sure I have to stop it because it`s some kind of compatibility.

Can someone post an example how to do the job?
Thanks!
temtronic



Joined: 01 Jul 2010
Posts: 9196
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon Oct 01, 2012 6:36 am     Reply with quote

The error may not be in that header file...but it is in some code before where the error message appears, so you have to look at ALL the code before the error( it can be several lines before...)

on another point, have you got tcpip working by itself ? Then , do you have the SD program working by itself? When both work without the other, then 'merge' the code into one program.

This way you KNOW they work and any errors are due to the 'merging' code.

divide and conqueor !

hth
jay
stoyanoff



Joined: 20 Jul 2011
Posts: 375

View user's profile Send private message

PostPosted: Mon Oct 01, 2012 6:46 am     Reply with quote

The TCPIP stack and the mdd stack works fine separately. So I tried to put them into 1 program but I have to remove the second device declaration and because in my code the mdd header is second I removed there the device options. This is the only one change I made. Now the p18Cxxx.h include returns an error I suppose!
Do you have an example for mix adjustments???
stoyanoff



Joined: 20 Jul 2011
Posts: 375

View user's profile Send private message

PostPosted: Thu Oct 04, 2012 10:42 pm     Reply with quote

Does anyone know how to adjust the both stacks??
Ttelmah



Joined: 11 Mar 2010
Posts: 19431

View user's profile Send private message

PostPosted: Fri Oct 05, 2012 4:47 am     Reply with quote

Step back a bit.

Anything beginning with 'ex', is likely to be an _example_, or part of an example, which itself then calls the driver. It is only the driver that you should load if using this with your own code.
So (for instance), ex_fat.c, loads the two drivers, mmcsd.c (low level driver for an mmc card), and then fat.c (which gives the higher level fat access).
Draw a little diagram. Start with the example file. Then show below this what drivers it loads, and the order these are loaded. Then look at the example, and see what order calls are made in (and read the notes in the drivers), so you have the fact that fat_init needs to be called before you start accessing the card.
Then make your main file, and include just the drivers in the order needed, and initialise the devices as needed.
You seem to be trying to 'hybridise' two examples, rather than using them as examples of how to use the drivers.

Best Wishes
stoyanoff



Joined: 20 Jul 2011
Posts: 375

View user's profile Send private message

PostPosted: Fri Oct 05, 2012 6:12 am     Reply with quote

Look! I took one of the tcpip example files - ex7a.c. It has only this include file:

Code:
#include "ccstcpip.h"

And this example works fine. So I added the include file for the sd card
Code:

#include "ccstcpip.h" //this is the standard include
#include "ex_mdd_common.h"  // I added this which should allow me to use
the SD functions

The both headers have device directives do I stopped them in the second one
//ex_mdd_common.h
But when I tried to compile it I received an error!
You cannot change the device type so far in the code 18Fcxxx.c
I`m using 18F67J60 microcontroller. This include is for mdd header and it comes after include <18F67J60>.

This is the problem I just want to know what else I have to change. The problem is not in the way I`m using the both stack but in their work together.
This 2 include files load the 2 stacks:
#include "ccstcpip.h"
#include "ex_mdd_common.h"
and they work just fine separately.
What do I suppose to do???
Douglas Kennedy



Joined: 07 Sep 2003
Posts: 755
Location: Florida

View user's profile Send private message AIM Address

PostPosted: Fri Oct 05, 2012 11:08 am     Reply with quote

The device is specified by ex. #device PIC18F2685.
Maybe a search of all of your code for #device will help you find a second, third or more #device declaration that if present are the source of your issue. If there is only one #device then remember this is a very fast compiler so it needs to know very very earlier on ( preferably on the first line the compiler encounters) the specific PIC device so that it can eliminate initiation code for other devices. Make sure the include usually xxxxx.h where xxxx is ex PIC18F2685.h is the first include the compiler sees and that only comment lines should proceed this include in your main code file.
stoyanoff



Joined: 20 Jul 2011
Posts: 375

View user's profile Send private message

PostPosted: Wed Oct 10, 2012 1:24 am     Reply with quote

I did it! The problem was the both tcpip and the mdd stacks are uncompatible, so I had to change a lot in them. I think CCS team have to work some more in this area.
Best regards!
RF_Developer



Joined: 07 Feb 2011
Posts: 839

View user's profile Send private message

PostPosted: Wed Oct 10, 2012 4:06 am     Reply with quote

The CCS TCP/IP stack is a port of an rather old version of the Microchip stack. Its by far the most complex "driver" that CCS make available. They do not appear to have a common driver format or design strategy, and such drivers are intended as starting points for us developers to develop our own code. CCS have never declared any intention to make drivers "compatible" with each other, nor do they appear to have any means to do so.

Yes, CCS *could* do some more work on this, but this sort of thing, i.e. developing our apps from their *sample* and *example* code, is what WE should be doing. I feel its unfair to berate CCS for this, its not their "fault". Its embedded development. Yes, it would be lovely if all the drivers worked together, and heck, why not make them fully plug and play, and hardware absracted too. Great! But that totally misses the point of small scale embedded development.

RF Developer.
stoyanoff



Joined: 20 Jul 2011
Posts: 375

View user's profile Send private message

PostPosted: Wed Oct 10, 2012 4:41 am     Reply with quote

May be the problem has a simple solution: just write a good self documenting code. The main problem of your examples is that the variables they use have same names. So if you use something like:
Code:

unsigned int32 mddBuffer
//not just unsigned int32 Buffer

everything would be perfect.
Best regards!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
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