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.

[参考译文] MSP430FR5989:无法将数据写入 FRAM 中的地址0x10000

Guru**** 2381520 points
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/986104/msp430fr5989-failed-to-write-data-to-address-0x10000-in-fram

器件型号:MSP430FR5989

我使用 CCS 构建项目。 程序的运行空间介于0x4400和0xFFFF 之间。 我想将1100字节的数据写入0x10000的地址。 我使用函数"_data20_write_char"一次写入20个字节。 当我完成编写时、在读取 char 时使用函数"_data20_ read_char"、发现中间区域的几个字节中存在随机检查错误。 以下是我的代码:

int ota_write(unsigned long offset,const unsigned char *pdata,unsigned int size)
{
    unsigned int i=0;
    for(i=0;i<size;i++)
    {
        __data20_write_char(offset+0x10000+i,pdata[i]);
    }

    for(i=0;i<size;i++)
    {
        if(__data20_read_char(offset+0x10000+i)!=pdata[i])
        {
            DBG_LOG("CHK ERR");  //Several random byte check failures
            return -1;
        }
    }

    return 0;
}
static unsigned char test_buf[20]={0};
void test_fram()
{
    int i=0,j=0;;
 
    for(i=0;i<55;i++)
    {
        for(j=0;j<sizeof(test_buf);j++)
        {
            test_buf[j]=j;
            check+j;
        }
        if(ota_write(i*sizeof(test_buf),test_buf,sizeof(test_buf))!=0)

        {return ;}
    }


}


请帮助我分析问题所在

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    int ota_write(unsigned long offset,const unsigned char *pdata,unsigned int size)
    {
        unsigned int i=0;
        for(i=0;i<size;i++)
        {
            __data20_write_char(offset+0x10000+i,pdata[i]);
        }
    
        for(i=0;i<size;i++)
        {
            if(__data20_read_char(offset+0x10000+i)!=pdata[i])
            {
                DBG_LOG("CHK ERR");  //Several random byte check failures
                return -1;
            }
        }
    
        return 0;
    }
    static unsigned char test_buf[20]={0};
    void test_fram()
    {
        int i=0,j=0;;
     
        for(i=0;i<55;i++)
        {
            for(j=0;j<sizeof(test_buf);j++)
            {
                test_buf[j]=j;
                check+=j; //fixed
            }
            if(ota_write(i*sizeof(test_buf),test_buf,sizeof(test_buf))!=0)
    
            {return ;}
        }
    
    
    }

    已修复代码