Trouble with SD Card tutorial
Iamretired
Posts: 56
I was able to run the first example, but not the second.
The second example requires modifications to the first.
The code below includes the changes required.
When I make the changes, I get errors.
/* SD Card Data tutorial
http://learn.parallax.com/propeller-c-simple-devices/sd-card-data
*/
#include "simpletools.h"
int DO = 22, CLK = 23, DI = 24, CS = 25;
int main(void)
{
pause(1000);
sd_mount(DO, CLK, DI, CS);
FILE* fp = fopen("test.txt", "w");
int val = 500; //1 <- add
fprintf(fp, "%d\n", val); //2 <- modify
val = -1000000; //3 <- add
fprintf(fp, "%d\n", val); //4 <- add
fclose(fp);
char s[15]; //5 <- remove
fp = fopen("test.txt", "r");
fread(s, 1, 15,fp); //6 <- remove
//fscanf(fp, "%d", &val); //7 <- add
//printf("val = %d\n", val); //9 <- add
//fscanf(fp, "%d", &val); //9 <- add
//printf("val = %d\n", val); //10 <- add
fclose(fp);
printf("First 21 chars in test.txt:\n"); //11 <- remove
printf("%s", s); //12 <- remove
printf("\n"); //13 <- remove
}
/*
With adds and modify //1 to //6 and removes //11 to //13
not done the following is displayed on terminal window.
First 21 chars in test.txt:
500
-1000000
When adds, modify and removes are done the program will
not compile.
*/
I have looked it over for keying errors and can't find any. I don't know if the code in the
tutorial works or not: I can't copy it to SimpleID to try it.
Please excuse the formatting: I tried to add spaces so that the '//#' line references would
be easier to see. Oh well.
Any ideas?
Johnmb
The second example requires modifications to the first.
The code below includes the changes required.
When I make the changes, I get errors.
/* SD Card Data tutorial
http://learn.parallax.com/propeller-c-simple-devices/sd-card-data
*/
#include "simpletools.h"
int DO = 22, CLK = 23, DI = 24, CS = 25;
int main(void)
{
pause(1000);
sd_mount(DO, CLK, DI, CS);
FILE* fp = fopen("test.txt", "w");
int val = 500; //1 <- add
fprintf(fp, "%d\n", val); //2 <- modify
val = -1000000; //3 <- add
fprintf(fp, "%d\n", val); //4 <- add
fclose(fp);
char s[15]; //5 <- remove
fp = fopen("test.txt", "r");
fread(s, 1, 15,fp); //6 <- remove
//fscanf(fp, "%d", &val); //7 <- add
//printf("val = %d\n", val); //9 <- add
//fscanf(fp, "%d", &val); //9 <- add
//printf("val = %d\n", val); //10 <- add
fclose(fp);
printf("First 21 chars in test.txt:\n"); //11 <- remove
printf("%s", s); //12 <- remove
printf("\n"); //13 <- remove
}
/*
With adds and modify //1 to //6 and removes //11 to //13
not done the following is displayed on terminal window.
First 21 chars in test.txt:
500
-1000000
When adds, modify and removes are done the program will
not compile.
*/
I have looked it over for keying errors and can't find any. I don't know if the code in the
tutorial works or not: I can't copy it to SimpleID to try it.
Please excuse the formatting: I tried to add spaces so that the '//#' line references would
be easier to see. Oh well.
Any ideas?
Johnmb
Comments
Do you see that?
BTW, To start and stop code formatting, use the word code between square brackets [ ]. To end a code snippet, use /code between square brackets.
What are the compiler errors? You can Right-Click (Control-Click on a Mac) in the compiler 'Build Status' area to select and copy the error log. You may need to click on the Hammer icon near the bottom of the editor to see the Status view.
That will help in debugging what's wrong.
Thanks,
dgately
#include "simpletools.h"
int DO = 22, CLK = 23, DI = 24, CS = 25;
int main(void)
{
pause(1000);
sd_mount(DO, CLK, DI, CS);
The error message ( typed ) is:
region 'hub' overflowed by 868 bytes
Done. Build Failed!
Your program is too big for the memory model selected in the project.
Andy
The compiler options are '32bit Double' and '-stdc99'
The Linker options are 'Mathlib' and '-lsimpletools'
Johnmb