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

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > msp430 FLASH 字節(jié)讀寫程序

          msp430 FLASH 字節(jié)讀寫程序

          作者: 時(shí)間:2016-11-11 來源:網(wǎng)絡(luò) 收藏
          /***** 430 FLASH 字節(jié)讀寫程序 *************************/


          430的數(shù)據(jù)RAM 與FLASH的讀寫

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

          #define FLASH_ADDRESS 0x1000 //定義FLASH信息區(qū)地址B段
          void flash_erase(unsigned char*);

          void read_flash(unsigned char *pc_byte, unsigned char *array,unsigned char amount);

          void write_flash(unsigned char *pc_byte,unsigned char *array,unsigned char amount);

          //******************************************************************************

          //FLASH段擦除

          void flash_erase(unsigned char *pc_word)

          {

          while(FCTL3 & BUSY); //如果處于忙狀態(tài),則等待

          FCTL3 = FWKEY ; //清出LOCK標(biāo)志,解鎖

          FCTL1 = FWKEY + ERASE ; //允許段擦除

          *pc_word = 0; //擦除..擦除..

          while(FCTL3 & BUSY);

          FCTL3 = FWKEY + LOCK ; //加鎖

          }

          //******************************************************************************

          //向FLASH信息區(qū)讀出指定數(shù)量的字節(jié)數(shù)據(jù)

          //unsigned int*pc_word :信息區(qū)數(shù)據(jù)指針

          //unsigned char *array :讀出數(shù)據(jù)存放數(shù)據(jù)數(shù)組,8位長

          //unsigned char amount :讀操的數(shù)量,范圍0-127

          void read_flash(unsigned char *pc_byte, unsigned char *array,unsigned char amount)

          { unsigned char i;

          for(i=0;i

          {

          *array = *pc_byte; //讀數(shù)據(jù),讀數(shù)據(jù)時(shí),flash地址自動(dòng)加 1

          array++; //接收緩沖區(qū)地址加 1

          }
          }

          //******************************************************************************

          //向FLASH信息區(qū)寫入指定數(shù)量的字節(jié)數(shù)據(jù)

          //unsigned char *pc_byte 信息區(qū)數(shù)據(jù)指針

          //unsigned char *array :讀出數(shù)據(jù)存放數(shù)據(jù)數(shù)組,8位長

          //unsigned char amount :讀操的數(shù)量,范圍0-127

          void write_flash(unsigned char *pc_byte,unsigned char *array, unsigned char amount)

          { unsigned char i;
          _DINT();

          while(FCTL3 & BUSY); //如果處于忙狀態(tài),則等待

          FCTL3 = FWKEY ; //清出LOCK標(biāo)志

          FCTL1 = FWKEY + WRT ; //寫操作,塊編程,+ BLKWRT;


          for(i=0;i

          {

          *pc_byte = *array;

          //*pc_byte = num;

          // num +=1;

          array++; //發(fā)送緩沖區(qū)地址加 1

          pc_byte++; //寫flash時(shí),地址人為加 1

          while(!(FCTL3 & WAIT)); //如果處于忙狀態(tài),則等待 ,若用軟件仿真,去掉                ?。@語句

          }

          FCTL1 = FWKEY; //寫操作完成,清除編程允許位 WRT,BLKWRT

          while(FCTL3 & BUSY);

          FCTL3 = FWKEY + LOCK;

          }


          /*

          #define RAM_ADDRESS 0x300
          __no_init volatile uchar XINHAO[3] @ 0x300; //型號(hào) 默認(rèn)201
          __no_init volatile uchar BdFlag @ 0x303; ////ff表示沒有標(biāo)定,00表示已標(biāo)定置零01表示已標(biāo)定1點(diǎn).02表示已標(biāo)定2點(diǎn).03表示已標(biāo)定3點(diǎn)
          __no_init volatile uchar EDZHI @ 0x304; //額定值
          __no_init volatile uchar CYSJ @ 0x305; //采樣時(shí)間
          __no_init volatile uchar GJSJ @ 0x306; //自動(dòng)關(guān)機(jī)時(shí)間
          __no_init volatile uchar YLDW @ 0x307; // 壓力單位
          __no_init volatile float Pyz @ 0x30A; // 置零后的皮壓值
          __no_init volatile float Bdxs[16] @ 0x310; // 標(biāo)定系數(shù)
          __no_init volatile float Bdzhi[16] @ 0x350; // 標(biāo)定值
          __no_init volatile float Bdnm[16] @ 0x390; // 標(biāo)定內(nèi)碼0X0D0


          void main(void)
          {
          volatile unsigned int i; // Use volatile to prevent removal
          // by compiler optimization

          WDTCTL = WDTPW + WDTHOLD; // Stop WDT
          FLL_CTL0 |= XCAP14PF; // Configure load caps
          for (i = 0; i < 10000; i++); // Delay for 32 kHz crystal to
          unsigned char *pc_flash; //定義字節(jié)指針變量 為字節(jié)讀寫
          pc_flash = (unsigned char *) FLASH_ADDRESS; //為指針初始化 // stabilize
          unsigned char *pc_ram; //定義字節(jié)指針變量 為字節(jié)讀寫
          pc_ram = (unsigned char *) RAM_ADDRESS; //為指針初始化

          while(1)

          {
          BdFlag = 1;
          Bdxs[0]=3.14;
          flash_erase(pc_flash); //段擦除
          write_flash(pc_flash,pc_ram ,208); //寫入指定字節(jié)數(shù)量
          read_flash(pc_flash,pc_ram,208); //再讀出剛才寫的字節(jié)
          LPM3; // Enter low power mode 3
          } */



          關(guān)鍵詞: 430FLASH字節(jié)讀

          評(píng)論


          技術(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); })();