Cannot get SD Card to work in user created Task
Cannot get SD Card to work in user created Task
I am running the standard EFFS-HTTP example that has a function ReadWriteTest() that writes and reads for SD card. This works fine in the UserMain. When I use the same function in a user task it gives an error.
The code in the UserMain includes:
....
OSChangePrio( uCFG_PRIO );
f_enterFS();
OSChangePrio( MAIN_PRIO );
.....
ReadWriteTest();
.....
OSTaskCreate( uCFG_Task, NULL, ( void * ) &uCFGTaskStack[uCFG_TASK_STK_SIZE], ( void * ) uCFGTaskStack, uCFG_PRIO );
The code in the otehr taks is simply:
void uCFG_Task( void *pdata ){
ReadWriteTest();
.......
With this last code I get the error:
**** Error in f_open(TestFile.txt) duing task (51)
I have also tried using the code
F_FILE* fp = f_open("image.bmp", "w+" );
but this also results in an error with the fp returning 0.
Surely I am doing something very simple that is wrong.
Thanks for any help
Regards
Lachlan
The code in the UserMain includes:
....
OSChangePrio( uCFG_PRIO );
f_enterFS();
OSChangePrio( MAIN_PRIO );
.....
ReadWriteTest();
.....
OSTaskCreate( uCFG_Task, NULL, ( void * ) &uCFGTaskStack[uCFG_TASK_STK_SIZE], ( void * ) uCFGTaskStack, uCFG_PRIO );
The code in the otehr taks is simply:
void uCFG_Task( void *pdata ){
ReadWriteTest();
.......
With this last code I get the error:
**** Error in f_open(TestFile.txt) duing task (51)
I have also tried using the code
F_FILE* fp = f_open("image.bmp", "w+" );
but this also results in an error with the fp returning 0.
Surely I am doing something very simple that is wrong.
Thanks for any help
Regards
Lachlan
Re: Cannot get SD Card to work in user created Task
are you doing what the comments say to do ?
/* The following call to f_enterFS() must be called in every task that accesses
the file system. This must only be called once in each task and must be done before
any other file system functions are used. Up to 10 tasks can be assigned to use
the file system. Any task may also be removed from accessing the file system with a
call to the function f_releaseFS(). */
/* The following call to f_enterFS() must be called in every task that accesses
the file system. This must only be called once in each task and must be done before
any other file system functions are used. Up to 10 tasks can be assigned to use
the file system. Any task may also be removed from accessing the file system with a
call to the function f_releaseFS(). */
Re: Cannot get SD Card to work in user created Task
Isnt that what i have done when I used the code:
OSChangePrio( uCFG_PRIO );
f_enterFS();
OSChangePrio( uCFG_PRIO );
f_enterFS();
Re: Cannot get SD Card to work in user created Task
How familiar are you with rtos tasks? Are you sure it isn't an issue in which you created non blocking tasks and your user task isn't running?
Re: Cannot get SD Card to work in user created Task
My user task is running fine.
If the task was not running, the function would not be called and no error would result.
If I comment out the function, then the rest of the code executes perfectly.
If the task was not running, the function would not be called and no error would result.
If I comment out the function, then the rest of the code executes perfectly.
Re: Cannot get SD Card to work in user created Task
Lachlanp wrote:Isnt that what i have done when I used the code:
OSChangePrio( uCFG_PRIO );
f_enterFS();
but the code you posted shows this:
Code: Select all
The code in the otehr taks is simply:
void uCFG_Task( void *pdata ){
ReadWriteTest();
You are just not showing enough of your code for us to help.
Re: Cannot get SD Card to work in user created Task
I showed this in my original post. I copied the way the example did it and used the f_enterFS() in the UserMain like it is done for HTTP and FTP Tasks.
Here is the code again as I originally posted but with other code. This is in UserMain:
/* The following call to f_enterFS() must be called in every task that accesses
the file system. This must only be called once in each task and must be done before
any other file system functions are used. Up to 10 tasks can be assigned to use
the file system. Any task may also be removed from accessing the file system with a
call to the function f_releaseFS(). */
f_enterFS(); // enter the File System from the Program
OSChangePrio( FTP_PRIO );
f_enterFS(); // Enter the file system for the FTP task
OSChangePrio( HTTP_PRIO );
f_enterFS(); // Enter the file system for the uCFG task
OSChangePrio( uCFG_PRIO );
f_enterFS(); // Enter the file system for the HTTP task
OSChangePrio( MAIN_PRIO ); // change back to this task's prio
I have also tried putting the f_enterFS() function in the task itself as shown below but fp always returns 0:
void uCFG_Task( void *pdata ){
f_enterFS(); // Enter the file system for the uCFG task
F_FILE* fp = f_open("image.bmp", "w+" );
The SD card works fine for HTTP and FTP, and as I am doing the identical procedure for my tyask, I cannot see why it does not like my task.
I appreciate all your help.
Regards
Lachlan
Here is the code again as I originally posted but with other code. This is in UserMain:
/* The following call to f_enterFS() must be called in every task that accesses
the file system. This must only be called once in each task and must be done before
any other file system functions are used. Up to 10 tasks can be assigned to use
the file system. Any task may also be removed from accessing the file system with a
call to the function f_releaseFS(). */
f_enterFS(); // enter the File System from the Program
OSChangePrio( FTP_PRIO );
f_enterFS(); // Enter the file system for the FTP task
OSChangePrio( HTTP_PRIO );
f_enterFS(); // Enter the file system for the uCFG task
OSChangePrio( uCFG_PRIO );
f_enterFS(); // Enter the file system for the HTTP task
OSChangePrio( MAIN_PRIO ); // change back to this task's prio
I have also tried putting the f_enterFS() function in the task itself as shown below but fp always returns 0:
void uCFG_Task( void *pdata ){
f_enterFS(); // Enter the file system for the uCFG task
F_FILE* fp = f_open("image.bmp", "w+" );
The SD card works fine for HTTP and FTP, and as I am doing the identical procedure for my tyask, I cannot see why it does not like my task.
I appreciate all your help.
Regards
Lachlan
Re: Cannot get SD Card to work in user created Task
I don't think you're understanding what seulater is telling you. I don't know anything about this, but he is saying you have to call f_enterFS(), in your new task. You call in it UserMain which means UserMain can use the SD card. He is saying you have to use it your new task. so...becomes
Code: Select all
void uCFG_Task( void *pdata ){
ReadWriteTest();
...
Code: Select all
void uCFG_Task( void *pdata ){
f_enterFS();
ReadWriteTest();
...
Re: Cannot get SD Card to work in user created Task
I tried the example you provided in the first instance and it did not work. Therfore I tried doing what the sample code does by setting the task priority and executing the f_enterFS(). I understand from the example code that the HTTP and the FTP task do not call f_enterFS() directly and that I have to do it from UserMain by first changing the task priority to the priority of the task I want connected, then execute the function, then change the priority back to the UserMain priority. If this is not correct I accept that, although I wonder why they do it in teh sample code.
The example that 'tod' and 'seulater' provided I have tried a number of times and it does not work.
Regards
Lachlan
The example that 'tod' and 'seulater' provided I have tried a number of times and it does not work.
Regards
Lachlan
Re: Cannot get SD Card to work in user created Task
The priority of the tasks in this example has nothing to do with getting access to the SD card.