打印

STR912读写M25P16错误

[复制链接]
2488|1
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
yuguohe|  楼主 | 2007-9-4 12:14 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
大家好,我使用STR912不能读写M26P16,下面是我的初始化过程,
在读M25P16产品ID时,就死在读第二个字节的地方,第一个字节
读出的为0xff是不对的,请大家帮助分析一下,谢谢! 




 /* Enable the __SSP0 Clock */
  SCU_APBPeriphClockConfig(__SSP0 ,ENABLE);
  SCU_APBPeriphReset(__SSP0,ENABLE); 


  // SSP0 pins Config 
  //Gonfigure SSP0_CLK, SSP0_MOSI, SSP0_nSS pins 
  GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput;
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_7;
  GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ;
  GPIO_InitStructure.GPIO_IPConnected = GPIO_IPConnected_Disable;
  GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt2    ;
  GPIO_Init (GPIO5, &GPIO_InitStructure);

  //Gonfigure SSP0_MISO pin GPIO5.6
  GPIO_InitStructure.GPIO_Direction = GPIO_PinInput;
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;
  GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ;
  GPIO_InitStructure.GPIO_IPConnected = GPIO_IPConnected_Enable;
  GPIO_InitStructure.GPIO_Alternate = GPIO_InputAlt1  ;
  GPIO_Init (GPIO5, &GPIO_InitStructure);
 
  SSP_DeInit(SSP0);
  SSP_InitStructure.SSP_FrameFormat = SSP_FrameFormat_Motorola;
  SSP_InitStructure.SSP_Mode = SSP_Mode_Master;
  SSP_InitStructure.SSP_CPOL = SSP_CPOL_High;
  SSP_InitStructure.SSP_CPHA = SSP_CPHA_2Edge;
  SSP_InitStructure.SSP_DataSize = SSP_DataSize_8b;
  SSP_InitStructure.SSP_ClockRate = 2;
  SSP_InitStructure.SSP_ClockPrescaler = 2;
  SSP_Init(SSP0, &SSP_InitStructure);

  /* SSP0 enable */
  SSP_Cmd(SSP0, ENABLE); 

 
  //Read M25P16 Identification
  SSP_SendData(SSP0, 0x9f);
  while(SSP_GetFlagStatus(SSP0, SSP_FLAG_TxFifoEmpty) == RESET);
  
  while(SSP_GetFlagStatus(SSP0, SSP_FLAG_RxFifoNotEmpty) == RESET);
  SSP_Buf[0] = SSP_ReceiveData(SSP0);
  while(SSP_GetFlagStatus(SSP0, SSP_FLAG_RxFifoNotEmpty) == RESET);  //程序停在这里
  SSP_Buf[1] = SSP_ReceiveData(SSP0);
  while(SSP_GetFlagStatus(SSP0, SSP_FLAG_RxFifoNotEmpty) == RESET);
  SSP_Buf[2] = SSP_ReceiveData(SSP0);
沙发
yuguohe|  楼主 | 2007-9-7 12:32 | 只看该作者

谢谢STF

谢谢STF,让我试一试再说。

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

3

主题

4

帖子

0

粉丝