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.

CC1312R: Flash内容无法改写

Part Number: CC1312R

Hi,TIs

在读写flash的时候遇到一些问题,我设定了固定地址在flash范围内,所以简化了flashwrite的逻辑,缺少了判断,但是我决定没什么影响。

我在读flash的时候没问题,写的时候,初始时flash内容为FF的时候可以写进去,但是改写数据的时候就不行了。代码如下:

static void FlashWrite(uint8_t *pWriteBuffer, uint32_t Address, uint32_t Count)
{
    uint32_t pageStartAddr;
    /* Calculate the start address of the destination page */
    pageStartAddr = (uint32_t)Address - ((uint32_t)Address % FLASH_PAGE_SIZE);

    /* Disable flash cache */
    VIMSModeSet(VIMS_BASE, VIMS_MODE_DISABLED);
    while (VIMSModeGet(VIMS_BASE) != VIMS_MODE_DISABLED);

    /* Erase the whole page */
    FlashSectorErase((uint32_t)pageStartAddr);

    /* Write back from the scratch buffer */
    FlashProgram(pWriteBuffer, Address, Count);

    /* Re-enable flash cache */
    VIMSModeSet(VIMS_BASE, VIMS_MODE_ENABLED);
}
void store_CT_ID(uint8_t ct_id)
{
    FlashWrite(&ct_id,CT_INFO_BASE+CT_ID_OFFSET,1);
}

void store_CT_RF_freq(uint32_t ct_freq)
{
    uint8_t temp[4]={0};
    uint8_t i;
    for(i =0;i<4;i++)
    {
        temp[i] = (uint8_t)((ct_freq>>(8*i)) & 0xFF);
    }
    FlashWrite(temp,CT_INFO_BASE+CT_RF_FREQ_OFFSET,4);
}

/* Page size is 4KiB on the CC13xx/CC26xx */
#define FLASH_PAGE_SIZE 0x1000

#define CT_INFO_BASE 0x10000
#define CT_ID_OFFSET 0x1004
#define CT_RF_FREQ_OFFSET 0x2004
#define CT_RF_DBM_OFFSET 0x3004

flash地址以上。

麻烦TI帮忙看下flashwrite函数中有无问题,擦除的时候为什么没有擦除掉?