OpenEdv-开源电子网

 找回密码
 立即注册
正点原子全套STM32/Linux/FPGA开发资料,上千讲STM32视频教程免费下载...
查看: 3213|回复: 3

写eeprom的问题

[复制链接]

8

主题

136

帖子

0

精华

中级会员

Rank: 3Rank: 3

积分
428
金钱
428
注册时间
2015-4-24
在线时间
85 小时
发表于 2016-6-24 13:29:27 | 显示全部楼层 |阅读模式
最近在用stm32f2做控制器,有一段控制EEprom的程序是别人写的,现在遇到问题了,求助各位大神,谢谢
正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

8

主题

136

帖子

0

精华

中级会员

Rank: 3Rank: 3

积分
428
金钱
428
注册时间
2015-4-24
在线时间
85 小时
 楼主| 发表于 2016-6-24 13:41:13 | 显示全部楼层
本帖最后由 bruellyyang 于 2016-6-27 16:45 编辑

这个是编译中遇到的问题,请大神指导下,谢谢
5.jpg
回复 支持 反对

使用道具 举报

8

主题

136

帖子

0

精华

中级会员

Rank: 3Rank: 3

积分
428
金钱
428
注册时间
2015-4-24
在线时间
85 小时
 楼主| 发表于 2016-6-27 16:44:03 | 显示全部楼层
void Write_25LC128(char* pbuffer)
{
  uint8_t index = 0, index1 = 0, index2 = 0, r2, r3, r4, r5;

  uint32_t Write_Address;
  uint32_t r0[6], r1[6];

  s32 DCOE, ACOE_Integer, ACOE_Decimal, ACOE_Index;
  float f0_Real, f1_Real, temp;
  char string0[10], string1[10];
  for(index = 0; index < 6; index++)
   {
     if(*pbuffer <= 57)
       r0[index] = (*pbuffer++ - 48) & 0x0000000F;
     else
       r0[index] = (*pbuffer++ - 55) & 0x0000000F;
   }
  Write_Address = (r0[0] << 20)|(r0[1] << 16)|(r0[2] << 12)|(r0[3] << 8)|(r0[4] << 4)|r0[5];
  pbuffer++;
  if(strcmp(Buffer[2],"AD")==0)  
   {
     for(index = 0; index < 6; index++)
      {
        if(*pbuffer <= 57)
          r1[index] = (*pbuffer++ - 48) & 0x0000000F;
        else
          r1[index] = (*pbuffer++ - 55) & 0x0000000F;
      }
     r2 = (uint8_t)((r1[0] << 4) | r1[1]);
     r3 = (uint8_t)((r1[2] << 4) | r1[3]);
     r4 = (uint8_t)((r1[4] << 4) | r1[5]);
     uint8_t AD_Buffer[3] = {r2, r3, r4};
     LC128_HOLD_HIGH();
     LC128_WriteBuffer(AD_Buffer, Write_Address, AD_BufferSize);
   }
  else if(strcmp(Buffer[2],"DCOE")==0)
   {
     while(*pbuffer != '\0')
      {
        string0[index1] = *pbuffer;
        pbuffer++;
        index1++;
      }
     string0[index1] = '\0';
  
     DCOE = atoi(string0);
     r5 = (uint8_t)(DCOE & 0x000000FF);
     uint8_t DCOE_Buffer[1] = {r5};
     LC128_HOLD_HIGH();
     LC128_WriteBuffer(DCOE_Buffer, Write_Address, DCOE_BufferSize);
   }
  else
   {
     while((*pbuffer != 'e') & (*pbuffer != 'E'))
      {
        string0[index1] = *pbuffer;
        pbuffer++;
        index1++;
      }
     string0[index1] = '\0';
     pbuffer++;
  
     while(*pbuffer != '\0')
      {
        string1[index2] = *pbuffer;
        pbuffer++;
        index2++;
      }
     string1[index2] = '\0';
  
     f0_Real = atof(string0);  //&frac12;&laquo;×&Ouml;·&ucirc;&acute;&reg;×&ordf;&Icirc;&ordf;&Euml;&laquo;&frac34;&laquo;&para;&Egrave;()
     f1_Real = atof(string1);
     ACOE_Integer = (s32)f0_Real;
     temp = (float)((f0_Real - ACOE_Integer) * 10000);
     ACOE_Decimal = (s32)temp;
     ACOE_Index = (s32)f1_Real;
  
     r2 = (uint8_t)(ACOE_Integer & 0x000000FF);
     r3 = (uint8_t)((ACOE_Decimal & 0x0000FF00) >> 8);
     r4 = (uint8_t)(ACOE_Decimal & 0x000000FF);
     r5 = (uint8_t)(ACOE_Index & 0x000000FF);
     uint8_t ABCOE_Buffer[ABCOE_BufferSize] = {r2, r3, r4, r5};
     LC128_HOLD_HIGH();
     LC128_WriteBuffer(ABCOE_Buffer, Write_Address, ABCOE_BufferSize);
   }
}
回复 支持 反对

使用道具 举报

8

主题

136

帖子

0

精华

中级会员

Rank: 3Rank: 3

积分
428
金钱
428
注册时间
2015-4-24
在线时间
85 小时
 楼主| 发表于 2016-6-27 16:44:44 | 显示全部楼层
错误是图5所示的,请问该怎么改
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则



关闭

原子哥极力推荐上一条 /2 下一条

正点原子公众号

QQ|手机版|OpenEdv-开源电子网 ( 粤ICP备12000418号-1 )

GMT+8, 2025-6-10 18:35

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

快速回复 返回顶部 返回列表