<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > PIC:讀寫24LCxx系列的EEPROM的實例C語言程序

          PIC:讀寫24LCxx系列的EEPROM的實例C語言程序

          作者: 時間:2011-05-06 來源:網(wǎng)絡(luò) 收藏

          //*
          //***********************************************
          void EE_SEQU_Read(unsigned char ctrl,unsigned char addr,unsigned char length,unsigned char *dptr)
          {
          IdleI2C(); // ensure module is idle
          StartI2C(); // Start condition
          I2C_Done(); // Wait Start condition completed

          本文引用地址:http://www.ex-cimer.com/article/172809.htm

          WriteI2C(ctrl); // Write Control to
          while(SSPCON2bits.ACKSTAT); // test for ACK condition, if received
          I2C_Done(); // Clear SSPIF flag

          WriteI2C(addr); // Write Address to
          while(SSPCON2bits.ACKSTAT); // test for ACK condition, if received
          I2C_Done(); // Clear SSPIF flag

          RestartI2C(); // initiate Restart condition
          I2C_Done();

          WriteI2C(ctrl+1); // Write Control to
          while(SSPCON2bits.ACKSTAT); // Test for ACK condition, if received
          I2C_Done(); // Clear SSPIF flag

          while (length!=0)
          {
          *dptr=ReadI2C(); // Enable I2C Receiver Store EEPROM data to Point buffer
          I2C_Done();
          dptr++;
          length--;

          if (length==0) NotAckI2C();
          else AckI2C(); // Continue read next data, send a acknowledge to EEPROM

          I2C_Done();
          }

          StopI2C(); // send STOP condition
          I2C_Done(); // wait until stop condition is over
          }

          //***********************************************
          //* Check I2C action that is completed *
          //***********************************************
          void I2C_Done(void)
          {
          while (!PIR1bits.SSPIF); // Completed the action when the SSPIF is Hi.
          PIR1bits.SSPIF=0; // Clear SSPIF
          }

          //************************************************
          //* Initial I2C Master Mode with 7 bits Address *
          //* Clock Speed : 100KHz @4MHz *
          //************************************************
          void Initialize_I2C_Master(void)
          {
          OpenI2C(MASTER,SLEW_ON);
          SSPADD= 9;
          }

          c語言相關(guān)文章:c語言教程



          上一頁 1 2 3 下一頁

          評論


          相關(guān)推薦

          技術(shù)專區(qū)

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();