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

RL_ARM MMC--->SPI Problem

Hello, All
I am using rl-arm , have problem when using mmc in RTX-OS in a task .
when i debuge with j-link i see MMC task was be in hard loop in SPI_SAM7X.c in below line

-------------------------------SPI_SAM7X.c-------------------------------------
static BOOL SendBuf (U8 *buf, U32 sz) { /* Send buffer to SPI interface. */ U32 i;

for (i = 0; i < sz; i++) { AT91C_BASE_SPI0->SPI_TDR = buf[i]; /* Wait if Tx FIFO is full. */ while (!(AT91C_BASE_SPI0->SPI_SR & AT91C_SPI_TDRE)); AT91C_BASE_SPI0->SPI_RDR; }
hard loop-----> while (!(AT91C_BASE_SPI0->SPI_SR & AT91C_SPI_RDRF));//os_tsk_pass(); AT91C_BASE_SPI0->SPI_RDR; return (__TRUE);
} -------------------------------------------------------------------------------

and task program is in below:

__task void phaseB (void) {
char count,errorflag;
os_dly_wait(200);
count = 3;
while (finit(NULL) != 0) { os_dly_wait(2); if (!(count--)) { errorflag = 1; break;

}
} if (errorflag==1)debug_send("MMC Error\n");
while(1){
os_dly_wait(100);
debug_send("MMC Task\n");

}

}

Please help meeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
King regard
Amir

Parents
  • Here is my main Program:

    i say you when MMC isnt plug then dont have problem and all sub program is passed, dont have heavy loop .
    ======================================================

    #include <RTL.h>
    #include <AT91SAM7X256.H>               /* AT91SAM7X256 definitions          */
    #include <AT91SAM7X-EK.h>
    #include <stdio.h>                    /* standard I/O .h-file                */
    #include <ctype.h>                    /* character functions                 */
    #include <string.h>                   /* string and memory functions         */
    #include "File_Config.h"
    #include "SD_File.h"
    
    //================mmc
    
    OS_TID t_phaseA;
    OS_TID t_phaseB;
    OS_TID t_buzz;
    OS_TID t_debug_wr;
    U8 waiting=20;
    #define BEEP1 os_evt_set (0x0001, t_buzz)
    char debug_write,debug_buffer[30];
    
    void debug_send(char *string_input)
      {
        strcpy(debug_buffer,string_input);
            os_evt_set (0x0002, t_debug_wr);
      }
    /*----------------------------------------------------------------------------
     *        Task 1 'phaseA': Phase A output
     *---------------------------------------------------------------------------*/
    __task void phaseA (void) {
    
    // char bufer_ser[100];
    
      for (;;) {
        //os_evt_wait_and (0x0001, 0xffff);    /* wait for an event flag 0x0001    */
        *AT91C_PIOB_CODR = AT91B_LED1;
        os_dly_wait (5);              /* call common signal function      */
        *AT91C_PIOB_SODR = AT91B_LED1;
            os_dly_wait (50);
            debug_send("Blink Task\n");
    
      }
    }
    /*----------------------------------------------------------------------------
     *        Task 2 'phaseB': PhaseB output
     *---------------------------------------------------------------------------*/
    __task void phaseB (void) {
    char count,errorflag;
    os_dly_wait(20);
    count = 3;
    while (finit(NULL) != 0)  {
       os_dly_wait(2);
      if (!(count--))  {
        errorflag = 1;
        break;
    
      }
    }
    if (errorflag==1)debug_send("MMC Error\n");
    while(1){
    os_dly_wait(100);
    debug_send("MMC Task\n");
    
    }
    
    }
    
    /*----------------------------------------------------------------------------
     *        Task 1 'phaseA': Phase A output
     *---------------------------------------------------------------------------*/
    __task void buzz (void) {
      for (;;) {
              os_evt_wait_and (0x0001, 0xffff);    /* wait for an event flag 0x0001    */
                  *AT91C_PIOB_CODR =  (1<<18);
                      os_dly_wait (3);
                      *AT91C_PIOB_SODR =  (1<<18);
      }
    }
    //===============================================
    __task void debug_wr (void) {
     int num_byte;
      for (;;) {
                   os_evt_wait_and (0x0002, 0xffff);
                               num_byte =strlen(debug_buffer);
                               ser_Write (&debug_buffer[0], &num_byte);
    
      }
    }
    /*----------------------------------------------------------------------------
     *        Task 5 'init': Initialize
     *---------------------------------------------------------------------------*/
    __task void init (void) {
    
    
      *AT91C_PMC_PCER = (1 << AT91C_ID_PIOB);/* Enable Clock for PIO             */
      *AT91C_PMC_PCER = (1 << AT91C_ID_PIOA);/* Enable Clock for PIO             */
    
      *AT91C_PIOB_PER  = AT91B_LED_MASK;     /* Enable PIO for LED1..4           */
      *AT91C_PIOB_OER  = AT91B_LED_MASK;     /* LED1..4 are Outputs              */
      *AT91C_PIOB_SODR = AT91B_LED_MASK;     /* Turn off LED's ("1")             */
      *AT91C_PIOB_PER  |= (1<<18);
      *AT91C_PIOB_OER  |= (1<<18);
      t_phaseA = os_tsk_create (phaseA, 0);  /* start task phaseA                */
      t_phaseB = os_tsk_create (phaseB,0);
      t_buzz = os_tsk_create (buzz, 0);
      t_debug_wr = os_tsk_create (debug_wr, 0);
      //os_evt_set (0x0001, t_phaseA);         /* send signal event to task phaseA */
    //============== Serial 0
      ser_OpenPort ();
      ser_InitPort (115200,
                    8,
                    0,
                    0);
    
    //=============== mmc
    //spi_init( );
      //CDC_DepInEmpty  = 1;
      os_evt_set (0x0001, t_buzz);
      os_tsk_delete_self ();
    }
    int main(void)
      {
      int  retv25;
      int asdf;
            os_sys_init (init);
    
    
            while(1)
            {
    
            }
    
      }
    
    

Reply
  • Here is my main Program:

    i say you when MMC isnt plug then dont have problem and all sub program is passed, dont have heavy loop .
    ======================================================

    #include <RTL.h>
    #include <AT91SAM7X256.H>               /* AT91SAM7X256 definitions          */
    #include <AT91SAM7X-EK.h>
    #include <stdio.h>                    /* standard I/O .h-file                */
    #include <ctype.h>                    /* character functions                 */
    #include <string.h>                   /* string and memory functions         */
    #include "File_Config.h"
    #include "SD_File.h"
    
    //================mmc
    
    OS_TID t_phaseA;
    OS_TID t_phaseB;
    OS_TID t_buzz;
    OS_TID t_debug_wr;
    U8 waiting=20;
    #define BEEP1 os_evt_set (0x0001, t_buzz)
    char debug_write,debug_buffer[30];
    
    void debug_send(char *string_input)
      {
        strcpy(debug_buffer,string_input);
            os_evt_set (0x0002, t_debug_wr);
      }
    /*----------------------------------------------------------------------------
     *        Task 1 'phaseA': Phase A output
     *---------------------------------------------------------------------------*/
    __task void phaseA (void) {
    
    // char bufer_ser[100];
    
      for (;;) {
        //os_evt_wait_and (0x0001, 0xffff);    /* wait for an event flag 0x0001    */
        *AT91C_PIOB_CODR = AT91B_LED1;
        os_dly_wait (5);              /* call common signal function      */
        *AT91C_PIOB_SODR = AT91B_LED1;
            os_dly_wait (50);
            debug_send("Blink Task\n");
    
      }
    }
    /*----------------------------------------------------------------------------
     *        Task 2 'phaseB': PhaseB output
     *---------------------------------------------------------------------------*/
    __task void phaseB (void) {
    char count,errorflag;
    os_dly_wait(20);
    count = 3;
    while (finit(NULL) != 0)  {
       os_dly_wait(2);
      if (!(count--))  {
        errorflag = 1;
        break;
    
      }
    }
    if (errorflag==1)debug_send("MMC Error\n");
    while(1){
    os_dly_wait(100);
    debug_send("MMC Task\n");
    
    }
    
    }
    
    /*----------------------------------------------------------------------------
     *        Task 1 'phaseA': Phase A output
     *---------------------------------------------------------------------------*/
    __task void buzz (void) {
      for (;;) {
              os_evt_wait_and (0x0001, 0xffff);    /* wait for an event flag 0x0001    */
                  *AT91C_PIOB_CODR =  (1<<18);
                      os_dly_wait (3);
                      *AT91C_PIOB_SODR =  (1<<18);
      }
    }
    //===============================================
    __task void debug_wr (void) {
     int num_byte;
      for (;;) {
                   os_evt_wait_and (0x0002, 0xffff);
                               num_byte =strlen(debug_buffer);
                               ser_Write (&debug_buffer[0], &num_byte);
    
      }
    }
    /*----------------------------------------------------------------------------
     *        Task 5 'init': Initialize
     *---------------------------------------------------------------------------*/
    __task void init (void) {
    
    
      *AT91C_PMC_PCER = (1 << AT91C_ID_PIOB);/* Enable Clock for PIO             */
      *AT91C_PMC_PCER = (1 << AT91C_ID_PIOA);/* Enable Clock for PIO             */
    
      *AT91C_PIOB_PER  = AT91B_LED_MASK;     /* Enable PIO for LED1..4           */
      *AT91C_PIOB_OER  = AT91B_LED_MASK;     /* LED1..4 are Outputs              */
      *AT91C_PIOB_SODR = AT91B_LED_MASK;     /* Turn off LED's ("1")             */
      *AT91C_PIOB_PER  |= (1<<18);
      *AT91C_PIOB_OER  |= (1<<18);
      t_phaseA = os_tsk_create (phaseA, 0);  /* start task phaseA                */
      t_phaseB = os_tsk_create (phaseB,0);
      t_buzz = os_tsk_create (buzz, 0);
      t_debug_wr = os_tsk_create (debug_wr, 0);
      //os_evt_set (0x0001, t_phaseA);         /* send signal event to task phaseA */
    //============== Serial 0
      ser_OpenPort ();
      ser_InitPort (115200,
                    8,
                    0,
                    0);
    
    //=============== mmc
    //spi_init( );
      //CDC_DepInEmpty  = 1;
      os_evt_set (0x0001, t_buzz);
      os_tsk_delete_self ();
    }
    int main(void)
      {
      int  retv25;
      int asdf;
            os_sys_init (init);
    
    
            while(1)
            {
    
            }
    
      }
    
    

Children