cc1310 FlashEfuseReadRow(readbuf,0x0001F000);读出来的数据总是0
bool
FlashEfuseReadRow(uint32_t *pui32EfuseData, uint32_t ui32RowAddress)
{
bool bStatus;
//
// Make sure the clock for the efuse is enabled
//
HWREG(FLASH_BASE + FLASH_O_CFG) &= ~FLASH_CFG_DIS_EFUSECLK;
//
// Set timing for EFUSE read operations.
//
HWREG(FLASH_BASE + FLASH_O_EFUSEREAD) |= ((5 << FLASH_EFUSEREAD_READCLOCK_S) &
FLASH_EFUSEREAD_READCLOCK_M);
//
// Clear status register.
//
HWREG(FLASH_BASE + FLASH_O_EFUSEERROR) = 0;
//
// Select the FuseROM block 0. 0x00000000;
//
HWREG(FLASH_BASE + FLASH_O_EFUSEADDR) = 0x00000000;
//
// Start the read operation.
//
HWREG(FLASH_BASE + FLASH_O_EFUSE) =
(DUMPWORD_INSTR << FLASH_EFUSE_INSTRUCTION_S) |
(ui32RowAddress & FLASH_EFUSE_DUMPWORD_M);
//
// Wait for operation to finish.
//
while(!(HWREG(FLASH_BASE + FLASH_O_EFUSEERROR) & FLASH_EFUSEERROR_DONE))
{
}
//
// Check if error reported.
//
if(HWREG(FLASH_BASE + FLASH_O_EFUSEERROR) & FLASH_EFUSEERROR_CODE_M)
{
//
// Set error status.
//
bStatus = 1;
//
// Clear data.
//
*pui32EfuseData = 0;
}
else
{
//
// Set ok status.
//
bStatus = 0;
//
// No error. Get data from data register.
//
*pui32EfuseData = HWREG(FLASH_BASE + FLASH_O_DATALOWER);
}
//
// Disable the efuse clock to conserve power禁用efuse时钟以节省功耗
//
HWREG(FLASH_BASE + FLASH_O_CFG) |= FLASH_CFG_DIS_EFUSECLK;
//
// Return the data.
//
return(bStatus);
}
试下常用方式读取:声明一个指针指向所需的flash地址,然后使用memcpy()将数据复制到缓冲区。
这是我的代码,供大家参考!
void FlashRead(uint8_t *pui8DataBuffer, uint32_t ui32Address, uint32_t ui32Count) {// 读取的数据存储 读取的起始地址 读取数据的长度
uint32_t *pb;// 创建一个指针
pb = (uint32_t *)ui32Address;// 把地址给指针
memcpy( pui8DataBuffer, pb, ui32Count);// 读取数据
}