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.

C6678 多核读写EMIF16接口问题



在调试C6678时遇到一个问题。
C6678通过EMIF16接口与FPGA通信。C6678的多个核都有可能通过EMIF16接口给FPGA发送数据。使用了硬件信号量来保证同一时刻只有一个核访问EMIF。
C6678向FPGA写EMIF数据函数实例如下,每个核向FPGA写数据的函数都一样:
void Emif16Write(unsigned int *data,unsigned int len)
{
while((CSL_semAcquireDirect(3)) == 0);//use 3 hardware semaphore
for(unsigned int i = 0; i < len; i++)
{
*((unsigned int*)0x74000000) = *data++;
}
CSL_semReleaseSemaphore(3);
}

遇到的问题是,从FPGA采到的数据来看,不同的核发送的数据有穿插,举例如下:
如果Core1发送5个数据1,2,3,4,5给FPGA,Core2发送3个数,6,7,8给FPGA,如果Core1先发,Core2后发,则FPGA收到的数据应该是1,2,3,4,5,6,7,8。但实际上FPGA收到的
数据可能是1,2,3,6,7,8,4,5
不知道有没有大神遇到过类似的问题,希望不吝赐教啊~

  • 会不会是有写缓冲?加一个MFENCE操作看看: 

     #include <c6x.h>

    void Emif16Write(unsigned int *data,unsigned int len)
    {
    while((CSL_semAcquireDirect(3)) == 0);//use 3 hardware semaphore
    for(unsigned int i = 0; i < len; i++)
    {
    *((unsigned int*)0x74000000) = *data++;
    }
     _mfence();  //force all memory operation complete

    CSL_semReleaseSemaphore(3);
    }