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

Data logger (PIC to PC) with MMC/SD card
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
Dave_25152



Joined: 11 Dec 2010
Posts: 60

View user's profile Send private message

Data logger (PIC to PC) with MMC/SD card
PostPosted: Wed Dec 22, 2010 3:12 pm     Reply with quote

Hello everyone!
First of all, thank you for being able to participate and expose my doubts.

I'm about to start me in the library FAT.

I want to make a data logger, but have not got much experience, I want to go forward slowly.

For now, I just want to make the PIC I'm using (18F2550) create a file on a MMC / SD (file "test.txt").

I started the code as follows (following the example given in "ex_fat.c"):
Quote:

#include <18F2550.h>
#fuses NOWDT, HS, NOPROTECT, NOLVP, NOMCLR
#use delay (clock=4M)

#use rs232(baud=9600,UART1, errors)

#use fast_io(a)
#use fast_io(b)
#use fast_io(c)
#define MMCSD_PIN_SCL PIN_C6
#define MMCSD_PIN_SDI PIN_C5
#define MMCSD_PIN_SDO PIN_C4
#define MMCSD_PIN_SELECT PIN_C2
#include <mmcsd.c>

#include <fat.c>

void main()
{
int teste;

setup_oscillator(OSC_4MHZ);

fat_init();

mk_file(teste.txt);

}

When compiling the program shows some errors.

However I am not able to correct ....

Thank you very much for your help ;).

---------------

I apologize for the translation, but I'm Portuguese and I am using a translator ...

My thanks.

Merry Christmas
Dave_25152



Joined: 11 Dec 2010
Posts: 60

View user's profile Send private message

PostPosted: Wed Dec 22, 2010 3:34 pm     Reply with quote

I've been watching the topic link:
http://www.ccsinfo.com/forum/viewtopic.php?t=23969&postdays=0&postorder=asc&start=45

But I find it so complicated ... I'm trying to learn something about PIC alone, by choice. Then I thank you for patience:).

I need to send the pic to the SD card data collected from a sensor.
It's very simple ... I want to go ahead slowly.

For now I just want to learn how to create a file in the SD card.



Thanks;)
asmallri



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

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

Re: Data logger (PIC to PC) with MMC/SD card
PostPosted: Wed Dec 22, 2010 10:43 pm     Reply with quote

Dave_25152 wrote:

....When compiling the program shows some errors.


This is not very helpful. Are we supposed to guess the errors you are having?
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Thu Dec 23, 2010 12:13 am     Reply with quote

Quote:
mk_file(teste.txt);

Enclose string constants in quation marks.
Ttelmah



Joined: 11 Mar 2010
Posts: 19369

View user's profile Send private message

PostPosted: Thu Dec 23, 2010 3:13 am     Reply with quote

and look at what clock speeds are supported by the HS fuse.

Best Wishes
Dave_25152



Joined: 11 Dec 2010
Posts: 60

View user's profile Send private message

PostPosted: Thu Dec 23, 2010 8:30 am     Reply with quote

Friends, thanks for the answers.

The program now is the following:

Quote:

void main()
{


setup_oscillator(OSC_4MHZ);

fat_init();

mk_file("teste.txt");

}


mk_file("teste.txt" * )

The error shows that the program is: * attempt to create a pointer to a constant.


I've been doing some more tests and look at the example "ex_fat.c" and decided to make these changes.

Quote:
void main()
{

int i;

setup_oscillator(OSC_4MHZ);

i = fat_init();

mk_file("teste.txt"[i]);

}



Now it compiles, but the program will do what I want? Create a file called "teste.txt"?


Thank you.

Happy Holidays.
Dave_25152



Joined: 11 Dec 2010
Posts: 60

View user's profile Send private message

PostPosted: Thu Dec 23, 2010 3:22 pm     Reply with quote

Any ideas / suggestions?


Thanks
Ttelmah



Joined: 11 Mar 2010
Posts: 19369

View user's profile Send private message

PostPosted: Thu Dec 23, 2010 3:31 pm     Reply with quote

Code:

void main(void) {
   char filename[]="teste.txt";
   setup_oscillator(OSC_4MHZ);
   
   fat_init();
   mk_file(filename);
   //Now write something......

   while(TRUE) ;
}
Dave_25152



Joined: 11 Dec 2010
Posts: 60

View user's profile Send private message

PostPosted: Thu Dec 23, 2010 3:40 pm     Reply with quote

OK.

Thanks, I'll try.

As I said, I'm learning to work with PIC's own volition, not because I have some discipline about it ...

Once again thank you for your help and your attention!


Happy holidays.
Dave_25152



Joined: 11 Dec 2010
Posts: 60

View user's profile Send private message

PostPosted: Sat Jan 22, 2011 4:32 pm     Reply with quote

I apologize for only now coming back to this project, but I was busy during all this time ...

I've tested, the 18F2550 programmed as code below, the memory card called 3.3 V (approximately: + -0.5 V), but got no result.
As you can see, I called an LED and so could see if the program was running or not. What happens is that the LED does not turn on any time ...

Does anyone know what might be happening? How can I fix this?


Here's the code:

Code:

#include <18F2550.h>
#fuses NOWDT, XT, NOPROTECT, NOLVP, NOMCLR
#use delay (clock=4M)

//#use rs232(baud=9600, UART1)

#use fast_io(a)
#use fast_io(b)
#use fast_io(c)
#define MMCSD_PIN_SCL      PIN_C6
#define MMCSD_PIN_SDI      PIN_C5
#define MMCSD_PIN_SDO      PIN_C4
#define MMCSD_PIN_SELECT   PIN_C2
#include <mmcsd.c>

#include <fat.c>

void main(void)
{
   char filename[]="teste.txt";
   
   setup_oscillator(OSC_4MHZ);
   
   fat_init();

output_high(PIN_B0);
delay_ms(1000);
output_low(PIN_B0);

   mk_file(filename);
   {
  printf("sucesso\n");
   }

   while(TRUE) ;
   {
output_high(PIN_B0);
delay_ms(1000);
   }
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Jan 22, 2011 4:42 pm     Reply with quote

Quote:
#use fast_io(a)
#use fast_io(b)
#use fast_io(c)

You're enabling "fast_io" mode but then you don't set the TRIS. It's a
requirement for fast_io mode that you must set the TRIS.

My suggestion is: Don't use fast_io mode. Delete all the #use fast_io
statements. Let the compiler handle the TRIS. It will do it for you.
That's the default mode of the compiler.

Then it's possible that your LED will turn on.
Dave_25152



Joined: 11 Dec 2010
Posts: 60

View user's profile Send private message

PostPosted: Sat Jan 22, 2011 4:46 pm     Reply with quote

OK. Thanks for the quick response.

I'll try again and have already put a feedback ;).
Dave_25152



Joined: 11 Dec 2010
Posts: 60

View user's profile Send private message

PostPosted: Sat Jan 22, 2011 5:10 pm     Reply with quote

Unfortunately the problem remains ... the LED goes off and the empty card.
I can not imagine that it can be.

This first part of the code has been used by others (the Internet) and seems to work ...
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Jan 22, 2011 6:02 pm     Reply with quote

Quote:

while(TRUE) ;
{
output_high(PIN_B0);
delay_ms(1000);
}


This is an endless loop ! It won't progress beyond the line in bold.
Dave_25152



Joined: 11 Dec 2010
Posts: 60

View user's profile Send private message

PostPosted: Sat Jan 22, 2011 6:55 pm     Reply with quote

OK, but in the beginning, the LED should light up ... at least 1s, this does not happen: (.
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