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 CCS Technical Support

weird behaviour of ex_fat.c example - help appreciated :)
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
xa4



Joined: 04 Jun 2008
Posts: 9

View user's profile Send private message Visit poster's website

weird behaviour of ex_fat.c example - help appreciated :)
PostPosted: Wed Jun 04, 2008 9:30 am     Reply with quote

Greetings !

I used the provided ex_fat.c example and changed a few parameters in order to fit to my configuration:

#include <18F8722.h> (my pic)

#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
(but I tested also with the default line and there are no changes)

#use delay(clock=10000000) (my oscillator on the circuit board)



It compiles without problem with PCWH compiler v4.062
The PIC is programmed without problem using MPLAB 7.6

When I open the terminal window, I see no > sign that should appear.
Each character that I type in the hyperterminal window is sent back (rs232 is working)

But when I try to send valid commands like help[return] nothing happens.

I tried to put some putc('x'); in several places but it is never displayed.
I tried to put some printf("hello"); at the beginning of the main() method but it doesn't show up in the hyperterm window...

I'm a bit lost and I don't understand what is wrong..

Could somebody provide me with some help ? I would be very grateful.


Thank you very much and best regards,
X. Righetti
crystal_lattice



Joined: 13 Jun 2006
Posts: 164

View user's profile Send private message

PostPosted: Wed Jun 04, 2008 9:40 am     Reply with quote

is your crystal running?? your terminal might have a setting to echo each char sent so your rs232 could not be working after all, rather flash a led...
xa4



Joined: 04 Jun 2008
Posts: 9

View user's profile Send private message Visit poster's website

PostPosted: Wed Jun 04, 2008 9:46 am     Reply with quote

Dear crystal_lattice, thank's for your prompt answer !

Yes, the crystal is running for sure (and the frequency is correct).. also, I commented the line in the example where characters are echoed back and and they are not echoed anymore.. So this is not the problem...

Thank's anyway...... any other ideas ?


X. Righetti
crystal_lattice



Joined: 13 Jun 2006
Posts: 164

View user's profile Send private message

PostPosted: Wed Jun 04, 2008 9:52 am     Reply with quote

How do you send the [return], my terminal program needs the $0d sign appended eg. dir$0d maybe yours needs something aswell? I've tried the ex_fat in the past but ran into other problems - files did not update... so am busy with other fat lib..
xa4



Joined: 04 Jun 2008
Posts: 9

View user's profile Send private message Visit poster's website

PostPosted: Thu Jun 05, 2008 2:05 am     Reply with quote

Dear crystal_lattice,

I think the return carriage character is well understood as it is the only character that isn't echoed back (as specified in the code.. so it is recognized).

But this is not the source of the problem as I can't even write something with printf() nor with putc() as I wrote in my first post..

So you are using other fat libs ? Maybe you could provide with another working example ?

Thank's!
Indy



Joined: 16 May 2008
Posts: 24

View user's profile Send private message

PostPosted: Thu Jun 05, 2008 7:56 am     Reply with quote

Quote:
I tried to put some printf("hello"); at the beginning of the main() method but it doesn't show up in the hyperterm window...
If you can't get this to work than it has no use to start debugging the other functions. I suggest you start from scratch with a simple "hello world" application to proof your hardware is OK.

Can you post the #fuses line of your ex_fat.c?

Hyperterminal has given me a lot of problems. I suggest you use an alternative, for example the freeware Br@y++ Terminal. It's a single executable and doesn't require installation.

Why are you using MPLAB 7.6? As I remember it right this wasn't the most stable version. Current version 8.1 is free for download from the Microchip website.
xa4



Joined: 04 Jun 2008
Posts: 9

View user's profile Send private message Visit poster's website

PostPosted: Thu Jun 05, 2008 8:43 am     Reply with quote

Dear Indy,

I don't know what happened, I rebooted my computer and everything (almost) works like a charm !!

I could create files and dirs but I couldn't write to the files or access the dirs.. so I used the format function from the hyperterm to format it. For the moment I tried the values 2^16 and 2^17 ie. I typed "format 65536" and "format 131072" (It is a 1gig microSD) and now I can access the dirs, append and read the files !!! Everything works great !! But....

But when I put it into my computer, I see nothing at all.. And when I format it from my computer (fat16) and I put it back into my circuit, it can still see the dirs and files I created earlier.. Idem if I put some file/folder on the SD card from my PC, I can't see them in the hyperterm window.

So I have one card, but it seams like I have two partition.. one that is seen by the computer, and one that is seen by my cicruit board.. and they are completely independent !!

Does somebody have a solution to see on my PC the files that have been created by the PIC ? (hopefully an easier solution than writing an application to download the content of the card via rs232 and save it to the computer)


Anyway, thank's a lot for your advices, I will download now the latest version of mplab and the terminal application you suggested..


here is the listing of my code, for reference:

code removed due to copyright issues...... sorry


Last edited by xa4 on Thu Jun 05, 2008 9:25 am; edited 1 time in total
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Thu Jun 05, 2008 9:24 am     Reply with quote

Code:
//// This source code may only be used by licensed users of the CCS  ////
//// C compiler.  This source code may only be distributed to other  ////
//// licensed users of the CCS C compiler.  No other use,            ////
//// reproduction or distribution is permitted without written       ////
//// permission.
This is a forum open to the whole world (and search engines). Can you edit your post and remove the code?

I had a quick glance at your code and don't spot the modifications you made, this is another reason to only post your modified functions.

Quote:
Does somebody have a solution to see on my PC the files that have been created by the PIC ?
http://www.ccsinfo.com/forum/viewtopic.php?t=34850
xa4



Joined: 04 Jun 2008
Posts: 9

View user's profile Send private message Visit poster's website

PostPosted: Thu Jun 05, 2008 9:27 am     Reply with quote

Dear ckielstra,

I removed the code.. sorry about that..

Is it possible to store the files (or format the card) in such a way that I don't need to use apps like WINHEX or DISKEDIT to view the content of the SD/MMC ?

thank's
Indy



Joined: 16 May 2008
Posts: 24

View user's profile Send private message

PostPosted: Thu Jun 05, 2008 9:44 am     Reply with quote

Quote:
I don't know what happened, I rebooted my computer and everything (almost) works like a charm !!
Sounds like my typical Hyperterm problem. The program seems to work like a charm but (partial) data is missing. You start to blame everything except the terminal program until you find out the problem is solved after a reboot. To avoid this waste of time use one of the many other terminal programs like the mentioned Bray Terminal or CCS's SIOW.exe.

About the formatting problems, read the text in fat.c on the format function:
Code:
////  NOTE: Windows thinks the filesystem is RAW.                    ////
////  NOTE: This may be a little buggy.                              ////
Doesn't give me a good feeling...

Beware that for speed optimization the mmcsd.c driver does buffer data read from the card. Try removing the power from your PIC to see if this removes the old directory structure (performing just a reset does not clear the RAM).

Use the tools mentioned in the link by Ckielstra for reading the actual card contents on the PC. You can even use these tools to hard erase the card by writing zero data to the first 100 blocks.
Indy



Joined: 16 May 2008
Posts: 24

View user's profile Send private message

PostPosted: Thu Jun 05, 2008 9:46 am     Reply with quote

Quote:
Is it possible to store the files (or format the card) in such a way that I don't need to use apps like WINHEX or DISKEDIT to view the content of the SD/MMC ?
That's what FAT16 or FAT32 is supposed for. I recommend FAT16 for cards <2Gb as the available libraries for this are better tested.
Format the card in Windows.
Indy



Joined: 16 May 2008
Posts: 24

View user's profile Send private message

PostPosted: Thu Jun 05, 2008 9:53 am     Reply with quote

I just see the CCS code defaults to FAT32 but I remember reading somewhere the FAT16 is more stable. In FAT.c change to FAT16:
Code:
/// Define your FAT type here ///
//#define FAT16
#define FAT32
xa4



Joined: 04 Jun 2008
Posts: 9

View user's profile Send private message Visit poster's website

PostPosted: Fri Jun 06, 2008 7:02 am     Reply with quote

Indy wrote:
I just see the CCS code defaults to FAT32 but I remember reading somewhere the FAT16 is more stable. In FAT.c change to FAT16:
Code:
/// Define your FAT type here ///
//#define FAT16
#define FAT32


Dear Indy, thank you very much for your help,

In the header of the fat.c code, it is written:
Code:

//// This library supports FAT16 and FAT32, but not both at the same ////
//// time (this is a compile option, see options below).  It is      ////
//// recommended to use FAT32, FAT32 also has been tested more.      ////


Anyway.. I tried to switch to FAT16, but a compilation error tells me that Next_Free_Cluster is an undefined identifier..
There was a mistake (I think) in the file fat.c at line 1342.. I had to replace Next_Free_Cluster by Next_Free_Clust. It seems that the lib hasn't been fully tested..

Apparently, I need the full version of winhex to write to the SD.. and I wasn't able to open the disk with DiskEdit.. So I used a freeware called HxD.

I tried to format the SD under windows in FAT 16 and changed the program to FAT16, but under windows, I still can't see the files and folders created by the PIC on the SD. Same operations for FAT32 and same results.. the files and folders are there but I can only see them with a disk editor application.

Any advices ? maybe another FAT lib ?

Thank's!
Indy



Joined: 16 May 2008
Posts: 24

View user's profile Send private message

PostPosted: Fri Jun 06, 2008 8:14 am     Reply with quote

I remember reading one of the two file systems was better tested. I thought this was FAT16 but you found the original text and it turns out I was wrong and FAT32 is the one being better tested.

I never used a FAT system on the PIC processor so can't point you to a good working library. Try searching this forum.
asmallri



Joined: 12 Aug 2004
Posts: 1634
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Fri Jun 06, 2008 11:34 am     Reply with quote

xa4 wrote:
maybe another FAT lib ?


You might want to check out my file system driver. It concurrently supports FAT12, FAT16 and FAT32. FAT16 and FAT32 have been extensively tested. I generally recommend FAT16 for the PIC because it requires less run time overhead.
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
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