This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

How to use C6457 EMIFA in synchronous mode?

I'm trying to communicate with FPGA through 16bits, synchronous mode EMIFA.

First, I want to read data from FPGA, but I only can read 4 continue data.

For example,

what I read:

  0x0001, 0x0002, 0x0003,0x0004,0x0006,0x0007......

but actually the data which FPGA sent to DSP is continues (0x0001, 0x0002, 0x0003,0x0004,0x0005,0x0006...)

I use logic analyser to see the SOE pin, find that, when I read data, it only can be active low in 6 cycles(R_LTNCY = 2), so I only can get 4 continues data.

Why SOE pin can't stay active low until the DSP finish read ?

Can I control SOE pin stay in low, or it only control by EDMA (I'm not sure)?

I use the code which is in C6457 csl file's EMIFA example. I change the code to 16bits, synchronous mode.

Following is a part of the code:

    Uint32                result,index, tempData,datacount,index_count=0,length;
    CSL_EmifaObj          emifaObj;
    CSL_Status            status;
    CSL_EmifaHwSetup      hwSetup ;

    CSL_EmifaMemType      asyncVal;
    CSL_EmifaMemType      syncVal;

    CSL_EmifaAsyncWait    asyncWait = CSL_EMIFA_ASYNCWAIT_DEFAULTS;

    CSL_EmifaSync           syncMem = CSL_EMIFA_SYNCCFG_DEFAULTS;

    /* Pointer that points to Sync(CE2) start area */
   
    Uint32 *pSyncData;

    Uint16 data_in;


    /* Clear local data structures */
    memset(&emifaObj, 0, sizeof(CSL_EmifaObj));
    memset(&hwSetup, 0, sizeof(CSL_EmifaHwSetup));

    /* setting for synchronous type */
    syncVal.ssel = EMIFA_MEMTYPE_SYNC;
    syncVal.async = NULL;
    syncVal.sync = &syncMem;

    /* setup the hardware parameters */
    hwSetup.asyncWait = &asyncWait;
    hwSetup.ceCfg[0] = &syncVal;
    hwSetup.ceCfg[1] = NULL;
    hwSetup.ceCfg[2] = &asyncVal;
    hwSetup.ceCfg[3] = NULL;

    printf("\tInfo: Read-Write operations of EMIFA \n");

    /* Initialize EMIFA CSL module */
    status = CSL_emifaInit(NULL);
    if (status != CSL_SOK) {
        printf("EMIFA: Initialization error.\n");
        printf("\tReason: CSL_emifaInit [status = 0x%x].\n", status);
        return;
    }
    else {
        printf("EMIFA: Module Initialized.\n");
    }

    /* Opening the EMIFA instance */
    hEmifa =  CSL_emifaOpen(&emifaObj, CSL_EMIFA, NULL, &status);
    if ((status != CSL_SOK) || (hEmifa == NULL)) {
        printf("EMIFA: Error opening the instance. [status = 0x%x, hEmifa \
                = 0x%x]\n", status, hEmifa);
        return;
    }
    else {
        printf("EMIFA: Module instance opened.\n");
    }

    /* Setting up configuration parameter using HwSetup */
    status =  CSL_emifaHwSetup(hEmifa, &hwSetup);
    if (status != CSL_SOK) {
        printf("EMIFA: Error in HW Setup.\n");
        printf("Read write operation fails\n");
        return;
    }
    else {
        printf("EMIFA: Module Hardware setup is successful.\n");
    }

    printf("\tInfo: Sync read write \n");

    /* read **valid** values into CS2 area. */

    pSyncData=(Uint32 *)EMIFA_CE2_BASE_ADDR;
   

    memcpy(data_in,pSyncData,512);


    for (index = 0; index < 256; index=index+1)
    {
            printf("data_in[%d] = %d\n",index,data_in[index]);
    }

    return ;
}

 

CSL_EMIFA_SYNCCFG_DEFAULTS:

#define CSL_EMIFA_SYNCCFG_READBYTEEN_DEFAULT    0x00
#define CSL_EMIFA_SYNCCFG_CHIPENEXT_DEFAULT     0x00
#define CSL_EMIFA_SYNCCFG_READEN_DEFAULT        0x00
#define CSL_EMIFA_SYNCCFG_WLTNCY_DEFAULT        0x00
#define CSL_EMIFA_SYNCCFG_RLTNCY_DEFAULT        0x01
#define CSL_EMIFA_SYNCCFG_SBSIZE_DEFAULT        0x01

Did I miss anything to set in synchronous mode?

  • Another question, do I have to set EDMA to read/write data from FPGA?

    sorry!! I'm a freshman about using DSP, so there is a lot of question.

    Could anyone explain more carefully?

    Thanks a lot!!!

  • Hello,

    The synchronous transfer mode for EMIF deals only with the way data is exchanged. The exchange itself (burst) may be any length between 1 and n words, depending on DSP internal scheduling : for example an EMIF request to another domain or an interrupt (if soft-managed transfer) may suspend the current burst. In your case, bursts of four 16-bit words (64-bit) are generated, probably due to the memcpy function doing 64-bit read-writes.

    SOE can't (must not) be manually controlled; however, if no use of other EMIF domains nor EDMA, you may program the whole block read through an EDMA transfer. If no wait state, no arbitration conflict,... the burst will be full size.

    If possible, a far safer option is to make the FPGA able to cope with non-continuous transfers (simple cycle-by-cycle read request through the read command signal CEn, each with your 2-cycle read latency). This would enable both accesses (software and EDMA) in all scheduling cases.

    Jakez

  • Dear Jakez,

    First, thank you for your reply.

    I still have several problems

    1. According to the code which I posted above, is there anything else I have to set to before use EMIFA? Did I miss anything??

    2. I use logic analyzer to check the waveform. When DSP read data through EMIF, the waveform of SOE just shows as describe before, but DSP can get the data from FPGA.

    When DSP write data to FPGA, the waveform of SWE can keep active low for a quit long time and the data change with EMIFA_clk (just like sync mode), but the value which FPGA received is not right. It's strange.

    thanks!!!

    Eric

     

  • Hello,

    Sorry, I don't use CSLs, so I can't confirm you the way you use these functions.

    There is only a few parameters to configure EMIF in synchronous mode, the most critical are the read and write latencies which depend on the FPGA interface. For example using a 2-cycle read latency while the FPGA expects a unique cycle may also explain sample swallows, as the DSP will ignore first sample in each burst (and symetrically for write latency).

    Jakez

  • Dear Jakez,

    First still thank you for your reply.

    I know that there are only few parameters have to set in synchronous mode, and I think I'm already do that.

    But the result still not right. For example, I change the latency to 3 or 1 cycles, but in LA, the waveform of SOE still have 2 cycles latency.

    I don't know what I miss??

    I read the data manual of C6457 (SPRS582B).

    Is the EMIFA setting related to Megamodule setting??

    In SPRS582B P80~81, seems that I have to set some registers before I use these region (CE2~CE5).

    Is that right?? and how do I set these registers??

    These problems bothered me for a long time, so is there any TI' employees can help me to solve these?

    Even you can give me a detail sample code about how to use EMIFA to transmit data. (include what I have to set in CCS5 environment)

    Thank you very very very much!!!

    Eric

  • Hello again,

    In the sprs582 pp80-81, the MARn registers need to be set to 0 for the FPGA region(s) at system init (before cache init/reset), disabling cache in non-memory CEn domains (MARn are 0 at reset, see cache in megamodule user's guide spru871k.pdf). The megamodule and the EMIFA are independant subsystems.

    Can you give the CEnCFG register value with your different settings, to check with EMIF user's guide sprugk2b.pdf ?

    Jakez

  • Dear Jakez,

    Thank you again!!!!

    the MARn registers need to be set to 0 for the FPGA region(s) at system init (before cache init/reset), disabling cache in non-memory CEn domains (MARn are 0 at reset, see cache in megamodule user's guide spru871k.pdf). The megamodule and the EMIFA are independant subsystems.

    I don't quit understand. You mean I don't have to consider about this part because megamodule and EMIFA are independent. Is that right??

    I have check the register through CCSv5 and the register is just as what I set. I have seen SPRUK2b already!!!

    Another question is how do you control the DSP??? I mean I communicate DSP by write C code through CCSv5. And you??  write asm code??

    Still thank you very much.

    Eric

     

  • Hello,

    EMIFA and megamodule are independant since they have no shared configuration bits/registers, but cacheability (the MARn in megamodule) has to be controlled for non-memory devices.

    EMIFA configuration in synchronous mode is full defined by writing to the CEnCFG register of interest. Without CSL, you may simply use something like (short way for CE2CFG):

    *(unsigned*)0x70000080 = 0x80000001 + (read_latency (1..3) << 2) + (write_latency (0..3) << 6)

    .Jakez

  • Dear Jakez,

    Could you be kindly give me a sample code about the "total setting" of using EMIFA?

    Because I'm using CSL, and use the  sample code inside, so maybe I miss something I don't know.

    Thank you!!!

    Eric

  • Hello,

    In fact the minimalist line given is the EMIFA CE2 total setting (assuming RD_BE_EN, CE_EXT, R_ENABLE are 0) :

        *(unsigned*)0x70000080 = 0x80000001 + (read_latency (1..3) << 2) + (write_latency (0..3) << 6)

    You may add (to assure MAR160 is set to 0, disabling CE2 cacheability):  

        *(unsigned*)0x01848280 = 0

    Jakez

  • dear Jakez,

    Do you mean that you can directly set registers by  *(unsigned*)0x01848280 = 0 this way?

    I will do what you told to make sure MAR160 is right.

    Another question is do I have to set Extended( or External) Memory Controller (EMC)?

    The DSP block diagram in SPRUGK2B p.8, it seems that I have to set EMC before I use EMIFA, is that right?

    It seems that the sample code which belongs to CSL6457 didn't consider about this part.

    Thank you so much, and do you know why the staff of TI still Ignored these problems?? ^^"

    Eric

     

  • Hello,

    MARn registers are usually initialized at startup, with cache. They can be modified at any time (as in the dirty example: *(unsigned*)0x01848280 = 0 for MAR160, the first 16 MBytes of EMIFA CE2). If disabling an already enabled MARn, the cache should be purged from any existing reference to it before (a priori not the case for you)..

    The Extended Memory Controller (see spru871) is a bridge internal to the megamodule, and needs no configuration by itself. It manages accesses between CPU, IDMA, peripheral registers, ressources external to megamodule (like EMIFA).

    Jakez

  • Hello Jakez

    I am new and a little bit lost could u tell me please how can i set up the project in  Code Composer  if i want to sent datas over emif interface of davince dm6437  to a RAM implemented on fpga. Which header files i need to include and is there  example source code in c?