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.

Highest bytes can't be read of DDR2 memory on DM8148

Hi,

 I'm using 128MB DDR2 memory on our custom board. The highest bytes are using for status counter and I read them to check the status. The counters are 32bits long and started from 0x87FFFFE0.

  When the first time I read the counters, an exception error would occur. Here's my code;

#define CORE_COUNTER_NUMBER (6)

#define COUNTER_BASE_ADDRESS            (0x87FFFFE0)

    UINT32 *pPt[CORE_COUNTER_NUMBER];
    UINT32 ulIndex;

    for (ulIndex=0; ulIndex<CORE_COUNTER_NUMBER; ulIndex++)
    {
        pPt[ulIndex]=(UINT32 *)COUNTER_BASE_ADDRESS+ulIndex;
    }

        sprintf(Msg, "DSP Counter: 0X%08X,\t  VIDEO-M3 Counter: 0x%08X\r\n", *pPt[0], *pPt[1]);

... ...

  The exception would occur at sprintf. But writing to those bytes are okay.

  If I start to read from 0x87FFFFC0, there's no such problem.

  The problem is strange and anyone has idea on that? Thanks.

 

    Eric




  • Eric,

    Could you try with this?

        UINT32 Pt[CORE_COUNTER_NUMBER];
        UINT32 ulIndex;

        for (ulIndex=0; ulIndex<CORE_COUNTER_NUMBER; ulIndex++)
        {
            Pt[ulIndex]=(UINT32 *)(COUNTER_BASE_ADDRESS+ulIndex);
        }

            sprintf(Msg, "DSP Counter: 0X%08X,\t  VIDEO-M3 Counter: 0x%08X\r\n", Pt[0], Pt[1]);

    ... ...

    BR,

    Viet

  • Hi Viet,

     Sorry for reply late.

    This line "Pt[ulIndex]=(UINT32 *)(COUNTER_BASE_ADDRESS+ulIndex);" would cause type cast error, so I modified it as "Pt[ulIndex]=COUNTER_BASE_ADDRESS+ulIndex*4;". sprintf could be executed without exception, but it just print the address instead of the counter values.

    If I modified the line of sprintf as "sprintf(Msg, "DSP Counter: 0X%08X,\t  VIDEO-M3 Counter: 0x%08X\r\n", *(UINT32 *)Pt[0], *(UINT32 *)Pt[1]);". Exception still occurred.

     

    Regards,

        Eric

  • More information.

    If I added those lines before sprintf when the first time I called the API. Exception never occurred.

     

        UINT32 ulTemp1, ulTemp2;


     

            ulTemp1=0x87FFFFC0;
            while (0x87FFFFFF>ulTemp1)
            {
                ulTemp2=*(UINT32 *)ulTemp1;
                ulTemp1+=4;
            }

            sprintf.......

  • Eric,

    Could you check with C manual?  I think there are some problem in the pointer.

    BR,

    Viet

  • Hi Viet,

       I try to use UINT16 * type to read data, and it works. Is that possible relative to the DDR bus (16 bits)?

     

    Regards,

        Eric

  • It's unusual to use an array of pointers to sequential elements in another array. Usually you would just reference the array directly. The array of pointers would be useful if the location of your counters are not contiguous and scattered throughout memory. Example below.

    #define CORE_COUNTER_NUMBER (6)
    #define COUNTER_BASE_ADDRESS (0x87FFFFE0)
    UINT32 *counter = (UINT32*)COUNTER_BASE_ADDRESS;
    int i;
    UINT32 temp;
    //Init memory to zero
    for(i=0; i<CORE_COUNTER_NUMBER; i++)
      counter[i] = 0;
    //Verify memory
    for(i=0; i<CORE_COUNTER_NUMBER; i++)
    { temp = counter[i];
      if(temp != 0)
      {
        sprintf(Msg, "[%p]=0X%08X expected 0\r\n", &counter[i], temp);
        break;
      }
    }
    sprintf(Msg, "DSP Counter: 0X%08X,\t  VIDEO-M3 Counter: 0x%08X\r\n", counter[0], counter[1]);

    The 16 bit vs 32 bit access should not matter if the HW is setup correctly. The processor should automatically do two 16 bit fetches for a 32 bit integer. Most processors like their data to be aligned, ie 16 bit to even addresses, 32 bit to quad addresses. Maybe double check the DDR configuration. It'll need to be told that it is 16 bit. I am not familar with the DM8148 so I cannot advise to any detail.

  • Hi Norman,

       Exception still occurred when applying your code.

       It successes only when I use UINT16 pointer, and I think data are aligned when I use 16 bits or 32 bits. I'll double check the DDR relative settings. Thank for your reply.

     

    Regards,

        Eric