本帖最后由 jinjing999 于 2010-5-4 09:43 编辑
我在提供例子里:
void FSMC_SRAM_WriteBuffer(u16* pBuffer, u32 WriteAddr, u32 NumHalfwordToWrite)
{
for(; NumHalfwordToWrite != 0; NumHalfwordToWrite--) /* while there is data to write */
{
/* Transfer data to the memory */
*(u16 *) (Bank1_SRAM3_ADDR + WriteAddr) = *pBuffer++;
/* Increment the address*/
WriteAddr += 2;
}
}
void FSMC_SRAM_ReadBuffer(u16* pBuffer, u32 ReadAddr, u32 NumHalfwordToRead)
{
for(; NumHalfwordToRead != 0; NumHalfwordToRead--) /* while there is data to read */
{
/* Read a half-word from the memory */
*pBuffer++ = *(vu16*) (Bank1_SRAM3_ADDR + ReadAddr);
/* Increment the address*/
ReadAddr += 2;
}
}
都是操作的16位数据,用的SARM是16位的。
如果我还用SARM的16位宽度的器件,我能操作的8位数据吗?
把函数改成以下,能操作吗?
void FSMC_SRAM_WriteBuffer(u8* pBuffer, u32 WriteAddr, u32 NumHalfwordToWrite)
{
for(; NumHalfwordToWrite != 0; NumHalfwordToWrite--) /* while there is data to write */
{
/* Transfer data to the memory */
*(u8 *) (Bank1_SRAM3_ADDR + WriteAddr) = *pBuffer++;
/* Increment the address*/
WriteAddr ++;
}
}
void FSMC_SRAM_ReadBuffer(u8* pBuffer, u32 ReadAddr, u32 NumHalfwordToRead)
{
for(; NumHalfwordToRead != 0; NumHalfwordToRead--) /* while there is data to read */
{
/* Read a half-word from the memory */
*pBuffer++ = *(u8*) (Bank1_SRAM3_ADDR + ReadAddr);
/* Increment the address*/
ReadAddr ++;
}
} |