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.

c6701 flash program problem

Hello,

I use c6701, I want to write some data into the flash, but only the low 16 bit data is wrote into the flash, and the high 16 bit data can't be wrote into the flash, the high 16 bit data is still FFFF. My flash is Am29LV160B, which is configured as 16 bit word mode, my flash write command is:

#define FLASH_BASE 0x01400000  

void flash_write(unsigned int* pSRC, unsigned int* pDST, int size)
{
int i = 0, j = 0;

printf("flash burn start...\n");

for(i = 0; i < size / 4; i++)
{
j = 0;
*(unsigned int *)(FLASH_BASE+(0x555<<2)) = 0x00aa;
*(unsigned int *)(FLASH_BASE+(0x2aa<<2)) = 0x0055;
*(unsigned int *)(FLASH_BASE+(0x555<<2)) = 0x00a0;

*pDST = *pSRC;
delay(100);
while(*pDST != *pSRC)
{
*pDST = *pSRC;
delay(100);
j++;
if(j > 100)
{
printf("flash write error!\n");
}
}
pDST++;
pSRC++;
}

printf("flash burn over!\n");
}

Can anyone tell me why the high 16 bit data is FFFF? 

Best Regards,

Si

  • Si,

    With your EMIF configured to be 16 bits wide, when you write a 32-bit value (unsigned int is 32-bits wide) the EMIF will convert that to two 16-bit wide writes. This may not be what your Flash device is expecting. I have not read the spec for your Flash device, but you can determine from it whether this will work (two successive 16-bit writes) or whether you need to convert your data writes to 16-bit values.

    You can check the C Compiler User's Guide to find the size of the various data types, but it is likely that short and unsigned short will be 16-bit data types, so you can create new pointers using 16-bit data types and write just 16 bits at a time.

    Also, you may want to verify if the write code values (0xaa 0x55 0xa0) need to be written before each data write or only once at the beginning of the write operation. I am not sure about that, so please double check about the right way to do this. These values should also be written using 16-bit data types.

    Please let us know if this helps or if you still have issues with the writing.

    Regards,
    RandyP
  • Hi Cheng,
    In addition to Randy suggestion, can you please change the flash value through CCS memory browser window ?
    What is your flash device and CS no ?
    Did you correctly interfaced the flash ?

    Please refer to the following user guide.

    www.ti.com/.../spra568a.pdf
  • Hi,

    I have referred to the user guide which you suggest, my flash devie is AMD's Am29LV160B is likely to the user guide spra568a.pdf, my flash is in CE1.

    you said "change the flash value through CCS memory browser window". I think before changing the flash value,  some flash write command must to be written  into it, just through ccs memory browser window, its value can't be written into it.

    flash program command:

    I followed Randy’s suggestion, but can't write high 16bit data into flash. I modify my flash wirte function like this:

    void flash_write(unsigned int* pSRC, unsigned int* pDST, int size)
    {
    int i = 0, j = 0;
    unsigned short *pSrc = (unsigned short*)pSRC;
    unsigned short *pDst = (unsigned short*)pDST;

    printf("flash burn start...\n");

    for(i = 0; i < size/2; i++)
    {
    //word mode
    *(unsigned int *)(FLASH_BASE+(0x555<<2)) = 0x00aa;
    *(unsigned int *)(FLASH_BASE+(0x2aa<<2)) = 0x0055;
    *(unsigned int *)(FLASH_BASE+(0x555<<2)) = 0x00a0; 

    *pDst++= *pSrc++;
    *pDst = *pSrc;

    delay(1000);
    if(*pDst != *pSrc)
    {

    delay(100);
    j++;
    if(j > 100)
    {
    printf("!!!!!!!!!!!!flash write error!!!!!!!!!!!!!!!!\n");
    return;
    }
    continue;
    }
    j = 0;
    pDst++;
    pSrc++;
    }
    printf("flash burn over!\n");
    }

    the  flash  memory

    spra568a.pdf use a similar  flash with me, the write  function is:

    /********************************************************************************/
    /* program_flash: Routine to program FLASH AM29LV800 */
    /* Inputs: */
    /* flash_ptr : Address of the FLASH */
    /* source_ptr : Address of the array containing the code to program */
    /* length : Length to be programmed */
    /* */
    /********************************************************************************/
    void program_flash(short * source_ptr, int * flash_ptr, int length)
    {
    int i;
    /* Control addresses are left shifted so that */
    /* they appear correctly on the EMIF’s EA[19:2] */
    /* Byte address << 2 == Word Address */
    int * ctrl_addr1 = (int *) ((int)flash_ptr + (0x555 << 2));
    int * ctrl_addr2 = (int *) ((int)flash_ptr + (0x2aa << 2));;
    for (i = 0; i < length; i++){
    * ctrl_addr1 = 0x00aa;
    * ctrl_addr2 = 0x0055;
    * ctrl_addr1 = 0x00a0;
    * flash_ptr++ = * source_ptr++;
    }
    }

    Here I have a question, why the flash_ptr is short type, while the flash_ptr is  int type,  this will lead the flash memory data can't be successive.

    Best Regards,

    Si

  • the emif flash connection is:

    please help me check  if anywhere is not correct! Thanks.

    Bets Regards,

    Si

  • Hello Si,

    I do not find any issue in your schematics design. We will analyse further and update you.

    Regards,
    Senthil
  • Hi everyone,

    I am so sorry I made a mistake, when I configure the CE register, I config the flash as 32-bit-wide asynchronous interface which should be 16-bit-wide ROM (CE1 only), I modify it, and it test ok.

    Best Regards,

    Si

  • Hello Si,

    Thanks for the update.

    Regards,
    Senthil