View previous topic :: View next topic |
Author |
Message |
Dave_25152
Joined: 11 Dec 2010 Posts: 60
|
Data logger (PIC to PC) with MMC/SD card |
Posted: Wed Dec 22, 2010 3:12 pm |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
Dave_25152
Joined: 11 Dec 2010 Posts: 60
|
|
Posted: Wed Dec 22, 2010 3:34 pm |
|
|
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;) |
|
![](templates/subSilver/images/spacer.gif) |
asmallri
Joined: 12 Aug 2004 Posts: 1634 Location: Perth, Australia
|
Re: Data logger (PIC to PC) with MMC/SD card |
Posted: Wed Dec 22, 2010 10:43 pm |
|
|
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!! |
|
![](templates/subSilver/images/spacer.gif) |
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Thu Dec 23, 2010 12:13 am |
|
|
Quote: | mk_file(teste.txt); |
Enclose string constants in quation marks. |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19369
|
|
Posted: Thu Dec 23, 2010 3:13 am |
|
|
and look at what clock speeds are supported by the HS fuse.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
Dave_25152
Joined: 11 Dec 2010 Posts: 60
|
|
Posted: Thu Dec 23, 2010 8:30 am |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
Dave_25152
Joined: 11 Dec 2010 Posts: 60
|
|
Posted: Thu Dec 23, 2010 3:22 pm |
|
|
Any ideas / suggestions?
Thanks |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19369
|
|
Posted: Thu Dec 23, 2010 3:31 pm |
|
|
Code: |
void main(void) {
char filename[]="teste.txt";
setup_oscillator(OSC_4MHZ);
fat_init();
mk_file(filename);
//Now write something......
while(TRUE) ;
}
|
|
|
![](templates/subSilver/images/spacer.gif) |
Dave_25152
Joined: 11 Dec 2010 Posts: 60
|
|
Posted: Thu Dec 23, 2010 3:40 pm |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
Dave_25152
Joined: 11 Dec 2010 Posts: 60
|
|
Posted: Sat Jan 22, 2011 4:32 pm |
|
|
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);
}
}
|
|
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sat Jan 22, 2011 4:42 pm |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
Dave_25152
Joined: 11 Dec 2010 Posts: 60
|
|
Posted: Sat Jan 22, 2011 4:46 pm |
|
|
OK. Thanks for the quick response.
I'll try again and have already put a feedback ;). |
|
![](templates/subSilver/images/spacer.gif) |
Dave_25152
Joined: 11 Dec 2010 Posts: 60
|
|
Posted: Sat Jan 22, 2011 5:10 pm |
|
|
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 ... |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sat Jan 22, 2011 6:02 pm |
|
|
Quote: |
while(TRUE) ;
{
output_high(PIN_B0);
delay_ms(1000);
}
|
This is an endless loop ! It won't progress beyond the line in bold. |
|
![](templates/subSilver/images/spacer.gif) |
Dave_25152
Joined: 11 Dec 2010 Posts: 60
|
|
Posted: Sat Jan 22, 2011 6:55 pm |
|
|
OK, but in the beginning, the LED should light up ... at least 1s, this does not happen: (. |
|
![](templates/subSilver/images/spacer.gif) |
|