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

6678 emif16 16位访问的问题

您好,

6678 emif16 接16位的FLASH,对于DSP端程序来说,对FLASH操作的偏移地址是不是应该作乘2的操作?

谢谢?

Brighton Feng:

不过多少位,软件都是一样的。

但不同位宽时,硬件连线不一样。在16位宽的情况下,管脚和逻辑字节地址的对应关系如下:

EMIFA23->A1

EMIFA0->A2

EMIFA1->A3

EMIFA2->A4

……

注意16位宽时,逻辑字节地址A0不存在。

jack liu_first:

回复 Brighton Feng:

Brighton Feng ,

您好,我看    【开发例程共享】Keystone1 软件开发包 K1_STK_1010.zip中的EMIF例程,里面有关于nor flash部分是16位访问,其中的程序 对flash读写命令其偏移地址作了乘2的操作,读写数据时,地址增量为+2,等价于偏移地址作了乘2的操作。而实事上这样读写flash才没有问题?

谢谢!

Brighton Feng:

回复 jack liu_first:

没明白你的意思,能把相关代码贴出来吗?

jack liu_first:

回复 Brighton Feng:

您好,

以下是 例程的部分相关代码

#define FLASH_BUS_WIDTH_1_BYTE 1#define FLASH_BUS_WIDTH_2_BYTES 2

static void NOR_flashWriteCmd (NOR_InfoHandle hNorInfo, Uint32 blkAddr, Uint32 offset, Uint32 cmd){ Uint32 addr= blkAddr + offset*hNorInfo->busWidth; if (FLASH_BUS_WIDTH_1_BYTE==hNorInfo->busWidth) *(Uint8 *)addr = (Uint8)cmd; else /*FLASH_BUS_WIDTH_2_BYTES*/ *(Uint16 *)addr = (Uint16)cmd;}

// NOR_WriteBytesUint32 NOR_writeBytes( NOR_InfoHandle hNorInfo, Uint32 writeAddress, Uint32 numBytes, Uint32 readAddress){ Int32 i; Uint32 retval = E_PASS;

if(FLASH_BUS_WIDTH_2_BYTES == hNorInfo->busWidth) { if (writeAddress & 0x00000001) { puts("address is not aligned to 2-byte boundary"); return E_FAIL; }

if (numBytes & 0x00000001) { puts("number of bytes is not even"); return E_FAIL; } }

while (numBytes > 0) { if( (numBytes < hNorInfo->bufferSize) || (writeAddress & (hNorInfo->bufferSize-1) )) { if ((*Flash_Write)(hNorInfo, writeAddress, NOR_flashReadData(hNorInfo,readAddress,0) ) != E_PASS) { puts("Normal write failed."); retval = E_FAIL; } else { numBytes -= hNorInfo->busWidth; writeAddress += hNorInfo->busWidth; readAddress += hNorInfo->busWidth; } } else { // Try to use buffered writes if((*Flash_BufferWrite)(hNorInfo, writeAddress, (volatile Uint8 *)readAddress, hNorInfo->bufferSize) == E_PASS) { numBytes -= hNorInfo->bufferSize; writeAddress += hNorInfo->bufferSize; readAddress += hNorInfo->bufferSize; } else { puts("Buffered write failed. Trying normal write"); // Try normal writes as a backup for(i = 0; i<hNorInfo->bufferSize; i+= hNorInfo->busWidth) { if ((*Flash_Write)(hNorInfo, writeAddress, NOR_flashReadData(hNorInfo,readAddress,0) ) != E_PASS) { puts("Normal write also failed"); retval = E_FAIL; break; } else { numBytes -= hNorInfo->busWidth; writeAddress += hNorInfo->busWidth; readAddress += hNorInfo->busWidth; } } } }

// Output status info on the write operation if (retval == E_PASS) { /*print progress*/ if ( (0==(writeAddress & 0xFFFFF)) || (numBytes == 0) ) { printf("NOR Write OK through 0x%x\n", writeAddress); } } else { puts( "NOR Write Failed…Aborting!"); return E_FAIL; } } return retval;}

谢谢!

赞(0)
未经允许不得转载:TI中文支持网 » 6678 emif16 16位访问的问题
分享到: 更多 (0)