发 帖  

小白求助mlx90614器件地址改写

8606 单片机
2017-4-15 20:25:54   评论 分享淘帖 邀请回答 举报
10个回答
2017-4-15 21:03:25 评论

举报

2017-4-15 22:15:51 评论

举报

2017-4-16 18:36:14 评论

举报

2017-9-29 11:22:38 评论

举报

2018-4-3 14:42:57 评论

举报

2018-10-6 08:42:13 评论

举报

2018-10-6 11:22:14 评论

举报

2019-1-16 19:14:02 2 评论

举报

2 条评论
  • 2019-4-5 21:04

    void EEPROM_WRITE(uchar slave_addW, uchar cmdW, uchar DataL, uchar DataH)   
    {   
       
         uchar Pecreg;                  //Calculated PEC byte storage   
         uchar SLA;   
         uchar arr1[6];                 //Buffer for the transmitted bytes   
         uchar error_timer = 0;   
       
         SLA=(slave_addW<<1);   
            
         arr1[5] = 0;   
         arr1[4] = SLA;   
         arr1[3] = cmdW;   
         arr1[2] = DataL;   
         arr1[1] = DataH;   
         arr1[0] = 0;   
            
         Pecreg = PEC_Calculation(arr1);   
            
         start();   
         SendByte(SLA);   
                
         SendByte(cmdW);   
               
         SendByte(DataL);   
               
               
         SendByte(DataH);   
                
         SendByte(Pecreg);   
                
                   
         stop();     
       
    }   


    uchar  PEC_Calculation(uchar  pec[])   
    {   
        uchar  crc[6];   
        uchar  BitPosition=47;   
        uchar  shift,i,j,temp;   
       
        do   
        {   
            /*Load pattern value 0x000000000107*/   
             
            crc[5]=0;   
            crc[4]=0;   
            crc[3]=0;   
            crc[2]=0;   
            crc[1]=0x01;   
            crc[0]=0x07;   
       
            /*Set maximum bit position at 47 ( six bytes byte5...byte0,MSbit=47)*/   
            BitPosition=47;   
       
            /*Set shift position at 0*/   
            shift=0;   
       
            /*Find first "1" in the transmited message beginning from the MSByte byte5*/   
            i=5;   
            j=0;   
            while((pec&(0x80>>j))==0 && i>0)   
            {   
                BitPosition--;   
                if(j<7)   
                {   
                    j++;   
                }   
                else   
                {   
                    j=0x00;   
                    i--;   
                }   
            }/*End of while */   
       
            /*Get shift value for pattern value*/   
            shift=BitPosition-8;   
       
            /*Shift pattern value */   
            while(shift)   
            {   
                for(i=5; i<0xFF; i--)   
                {   
                    if((crc[i-1]&0x80) && (i>0))   
                    {   
                        temp=1;   
                    }   
                    else   
                    {   
                        temp=0;   
                    }   
                    crc<<=1;   
                    crc+=temp;   
                }/*End of for*/   
                shift--;   
            }/*End of while*/   
       
            /*Exclusive OR between pec and crc*/   
            for(i=0; i<=5; i++)   
            {   
                pec ^=crc;   
            }/*End of for*/   
        }   
        while(BitPosition>8); /*End of do-while*/   
       
        return pec[0];   
    }

  • 2019-4-5 21:08

    记得先写0x00在写新值

2019-4-5 21:04:08 评论

举报

撰写答案

你正在撰写答案

如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。

您需要登录后才可以回帖 登录/注册

声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容图片侵权或者其他问题,请联系本站作侵删。 侵权投诉
快速回复 返回顶部 返回列表
关注微信公众号

电子发烧友网

电子发烧友论坛

社区合作
刘勇
联系电话:15994832713
邮箱地址:liuyong@huaqiu.com
社区管理
elecfans短短
微信:elecfans_666
邮箱:users@hauqiu.com
关闭

站长推荐 上一条 /6 下一条

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