[应用相关] sd卡读写 出错

[复制链接]
3377|3
 楼主| jackbao 发表于 2008-4-23 10:57 | 显示全部楼层 |阅读模式
int main(void)
{
#ifdef DEBUG
  debug();
#endif
 for(i=0; i<1024; i++)
 { if(i<10)
  Tx_Buffer = 10;
 else
  Tx_Buffer = 1; 
 }
  /* System clocks configuration ---------------------------------------------*/
  RCC_Configuration();

  /* NVIC configuration ------------------------------------------------------*/
  NVIC_Configuration();

  /* GPIO configuration ------------------------------------------------------*/
  GPIO_Configuration();

  /* Initialize the SPI FLASH driver -----------------------------------------*/
   MSD_Init();
  

 
  /* Write Tx_Buffer data to SPI FLASH memory */
FLASH_ID = MSD_WriteBlock(Tx_Buffer, Memory_Offset, 512); 
if(!FLASH_ID)      //是不是写成功
  {
    /* OK: Turn on led connected to PC6 */
   GPIO_WriteBit(GPIOC, GPIO_Pin_6, Bit_SET);
   GPIO_WriteBit(GPIOC, GPIO_Pin_7, Bit_SET);
   GPIO_WriteBit(GPIOC, GPIO_Pin_8, Bit_SET);
  };


  /* Read data from SPI FLASH memory */
    Memory_Offset = 0;
   //读
 FLASH_ID1 =  MSD_ReadBlock(Rx_Buffer, Memory_Offset, 512); 


  /* Check the corectness of written dada */
 j = Buffercmp(Tx_Buffer, Rx_Buffer,10);

 if(!j==0)//FLASH_ID1 == 0)//TransferStatus1) //读写是不是一样
  {
    /* OK: Turn on led connected to PC6 */
   GPIO_WriteBit(GPIOC, GPIO_Pin_6, Bit_RESET);
   GPIO_WriteBit(GPIOC, GPIO_Pin_7, Bit_SET);
   GPIO_WriteBit(GPIOC, GPIO_Pin_8, Bit_SET);
  };
     
  while (1)
  {}
}
为什么读写返回都是正确的,可是读写的内容 为什么不一样
 楼主| jackbao 发表于 2008-4-23 14:46 | 显示全部楼层

知道原因了

数组问题
linghu886 发表于 2008-4-23 15:15 | 显示全部楼层

SD卡文件系统!!!

你们的SD卡例程中
提供 FAT16文件系统的吗?
Lxueqiang 发表于 2008-4-23 16:55 | 显示全部楼层

我也对SD卡的感兴趣!

更注重U盘的读取!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

92

主题

260

帖子

0

粉丝
快速回复 在线客服 返回列表 返回顶部