TI中文支持网
TI专业的中文技术问题搜集分享网站

MSP430F2418: 关于information memory里面存的数据读不出来的问题

Part Number:MSP430F2418

{uint16_t ip1=0xFFFF,ip2=0xFFFF,ip3=0xFFFF,ip4=0xFFFF;
	uint16_t port =0xFFFF;char *Flash_ptr = (char *)0x1000;FCTL3 = FWKEY;
//FCTL1 = FWKEY + WRT;printf("读取ip设置\r\n");ip1 |= *Flash_ptr++;ip1 |= (*Flash_ptr++)<<8;ip2 |= *Flash_ptr++;ip2 |= (*Flash_ptr++)<<8;ip3 |= *Flash_ptr++;ip3 |= (*Flash_ptr++)<<8;ip4 |= *Flash_ptr++;ip4 |= (*Flash_ptr++)<<8;port |= *Flash_ptr++;port |= (*Flash_ptr++)<<8;
//FCTL1 = FWKEY;FCTL3 = FWKEY + LOCK;printf("ip = %d.%d.%d.%d:%d\r\n", ip1, ip2, ip3, ip4, port);if(ip1 == 0xFFFF || ip2 == 0xFFFF || ip3 == 0xFFFF || ip4 == 0xFFFF || port == 0xFFFF){printf("ip未设置,使用默认ip\r\n");SaveRemoteSettingToFlash(112,74,200,49,9527);return false;}sprintf(server_ip, "%d.%d.%d.%d", ip1, ip2, ip3,ip4);sprintf(server_port, "%d", port);return true;

代码如上,读存在segD中的ip数据,如果没有读到的话就把默认的ip写进去再读一次

现在数据可以写入segD,但是读不出来,是不能够通过这样直接访问地址的方法来读取数据吗?

请问该怎么做才能将information memory中的数据读取出来呢?

Susan Yang:

user6616820 说:现在数据可以写入segD,但是读不出来

segD的话,使用CCS内的memory browser能读出来吗?

您现在是printf不能打印?

,

user6616820:

您好,刚才我是用的iar进行仿真,现在我把代码一直到CCS上,结果也一样,您看一下截图

CCS内的memory browser能读出来

,

Susan Yang:

读写flash的话,请您参考下面的代码

/*************************************************************************/
/** OnChip flash memory**/
/*************************************************************************/
static UINT8 *CpuFlash= (UINT8*)0x1040;//Use Segment C at 0x01040
static const UINT16 CpuFlashLimit= 64;//64 bytes of CPU flashstatic void DevCpuFlashWrite(int DoErase, UINT16 Addr, const UINT8 *pSrc, UINT16 ByteCt) {if(Addr<CpuFlashLimit) {ByteCt= min(ByteCt,CpuFlashLimit-Addr);FCTL2= FWKEY|FSSEL1|FN1;//SMCLK/3FCTL3= FWKEY;//Clear LOCKif(DoErase) {DevWatchdogReset();//This may take a while...//Do not attempt to single-step through this block...FCTL1= FWKEY|ERASE;CpuFlash[Addr]= 0xFF;//Initiate erasewhile(FCTL3 & BUSY);//Wait until erase is complete}DevWatchdogReset();//This may take a while...FCTL3= FWKEY;//Clear LOCKFCTL1= FWKEY|WRT;//Write enable//For some reason block writes did not work, triggering an//access violation after the first byte. Individual writes//work, but are slower (raises and lowers the eeprom voltage//for each byte)while(ByteCt--) {while((FCTL3 & BUSY));//Wait until previous write completesCpuFlash[Addr++]= *pSrc++;}FCTL1= FWKEY;//Disable write, block writeFCTL3= FWKEY|LOCK;//Set LOCK}
}//Read is provided to keep the actual address hidden from the caller.
static void DevCpuFlashRead(UINT16 Addr, UINT8 *pDst, UINT16 ByteCt) {if(Addr<CpuFlashLimit) {ByteCt= min(ByteCt,CpuFlashLimit-Addr);while(ByteCt--) {*pDst++= CpuFlash[Addr++];}}
}

赞(0)
未经允许不得转载:TI中文支持网 » MSP430F2418: 关于information memory里面存的数据读不出来的问题
分享到: 更多 (0)