This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

MMC read write in RTX

Hi,
I am using RTX kernel to read write to MMC the program works fine with normal operation ,but when I use the same code with RTX kernel it does not creat any file infact no information from the MMC is get like File system etc ,is there any new method to use MMC card with MMC any specific routenes for file creation


#include "91x_lib.h"
#include<stdlib.h>
#include <string.h>
#include <stdio.h>
#include "mmc.h"
#include "fat.h"

#ifndef FALSE
#define FALSE 0
#define TRUE 1
#endif

int main(void)
{
        unsigned char SPI_Buffer[512];
        unsigned char data[50]="hello world941\n";
        unsigned int x = 0, y = 0;
        char fname[20];
        unsigned char MMCPRESENCE = 0;
        unsigned char z = FALSE;
//      char *header = (char *)malloc(14);
//      char *infoheader = (char *)malloc(40);
        File_Handler *file_handle;
        file_handle = (File_Handler*)calloc(1,sizeof(File_Handler));
        SCU_Configuration();
        UART_0_GPIO_5_INIT();
        UART0_INIT();
        //SCU_Configuration();                  //Enabling peripheral clock for SSP0 and GPIO2(SSP0 in port 2)
        GPIO_Configuration();           // configuring SSP0 pins in port2
        init_SSP0();
//      createheader(header,116,104);
///     createinfoheader(infoheader,116,104);
        MMCPRESENCE = init_MMC();
        printf("MMCPRESENCE %x \n\r",MMCPRESENCE);
        printf("Logging data to MMC\n\r");
        Read_Disk_Info(SPI_Buffer,file_handle);
        Display_Disk_Info(file_handle);
//      Display_Disk_Info(file_handle);
        printf("opening file\n\r");
        sprintf(fname,"DATA.TXT");
        z=File_Open(fname,SPI_Buffer,file_handle);
        printf("z: %x  \n\r",z);
        //while(1)
        //{
                if(z==TRUE)
                {
                        printf("writing \n\r");
                        Write_File(file_handle,data,strlen(data),SPI_Buffer);
                        printf("written\n\r");
                }
        //}
        File_close(file_handle);
        printf("file closed \n\r");
}


above code works fine without RTX but no file created in RTX kernel

thankd

Parents
  • There should be no difference when using RTX or not using RTX. In your case, you have most likely a wrong system configuration for RTX version. Check the stack and the heap sizes. You also need to protect your MMC low layer with mutexes. Interrupting one MMC transaction and starting a new from another task will cause a MMC not functioning.

    Of course if you have Use microlib enabled in your RTX version, will also not work. The Microlib does not support any file IO except STDIN, STOUT and STDERR.

    Franc

Reply
  • There should be no difference when using RTX or not using RTX. In your case, you have most likely a wrong system configuration for RTX version. Check the stack and the heap sizes. You also need to protect your MMC low layer with mutexes. Interrupting one MMC transaction and starting a new from another task will cause a MMC not functioning.

    Of course if you have Use microlib enabled in your RTX version, will also not work. The Microlib does not support any file IO except STDIN, STOUT and STDERR.

    Franc

Children
  • presently I am using a single task in which no other task is called even then MMC is not responding I call every function in main

    
    
    
    #include <RTL.h>
    #include <91x_lib.H>
    #include "LCD.h"
    #include "RT_Agent.h"                   /* Real-Time Agent definitions       */
    #include <stdio.h>
    #include "mmc.h"
    #include "fat.h"
    /* id1, id2, id3, id4 will contain task identifications at run-time */
    OS_TID id1, id2, id3, id4,id5;
    OS_MUT mutex1;
    
    
     /*----------------------------------------------------------------------------
     *        Main: Initialize and start RTX Kernel
     *---------------------------------------------------------------------------*/
    int main (void) {
      //os_sys_init (task1);
         unsigned char SPI_Buffer[512];
            unsigned char data[50]="hello world941\n";
            unsigned int x = 0, y = 0;
            char fname[20];
            unsigned char MMCPRESENCE = 0;
            unsigned char z = FALSE;
    //      char *header = (char *)malloc(14);
    //      char *infoheader = (char *)malloc(40);
    
    
            File_Handler *file_handle;
            file_handle = (File_Handler*)calloc(1,sizeof(File_Handler));
            SCU_Configuration();
            UART_0_GPIO_5_INIT();
            UART0_INIT();
             printf("hi");
    //      UART_0_GPIO_5_INIT();
    //      UART0_INIT();
            //SCU_Configuration();                  //Enabling peripheral clock for SSP0 and GPIO2(SSP0 in port 2)
            os_mut_init (mutex1);
            GPIO_Configuration();           // configuring SSP0 pins in port2
            init_SSP0();
    //      createheader(header,116,104);
    ///     createinfoheader(infoheader,116,104);
            MMCPRESENCE = init_MMC();
            printf("MMCPRESENCE %x \n\r",MMCPRESENCE);
    //      printf("Logging data to MMC\n\r");
            Read_Disk_Info(SPI_Buffer,file_handle);
            Display_Disk_Info(file_handle);
            Display_Disk_Info(file_handle);
            printf("opening file\n\r");
            sprintf(fname,"DATA.TXT");
            z=File_Open(fname,SPI_Buffer,file_handle);
            printf("z: %x  \n\r",z);
            //while(1)
            //{
                    if(z==TRUE)
                    {
                            printf("writing \n\r");
                            Write_File(file_handle,data,strlen(data),SPI_Buffer);
                            printf("written\n\r");
                    }
            //}
            File_close(file_handle);
            printf("file closed \n\r");
            os_mut_release (mutex1);
    
    }
    
    /*----------------------------------------------------------------------------
     * end of file
     *---------------------------------------------------------------------------*/
    

    even then its not working

  • Is not any of the functions returning any results back to help you figuring out the problem?

    Not even test code should ignore looking at result codes/sizes.

  • I think you are write

    my kernel is microlib version so how can I proceed to read write to a MMC card my code using normal file I/O routenes is there any way to read write to MMC with RTX