在线看毛片网站电影-亚洲国产欧美日韩精品一区二区三区,国产欧美乱夫不卡无乱码,国产精品欧美久久久天天影视,精品一区二区三区视频在线观看,亚洲国产精品人成乱码天天看,日韩久久久一区,91精品国产91免费

<menu id="6qfwx"><li id="6qfwx"></li></menu>
    1. <menu id="6qfwx"><dl id="6qfwx"></dl></menu>

      <label id="6qfwx"><ol id="6qfwx"></ol></label><menu id="6qfwx"></menu><object id="6qfwx"><strike id="6qfwx"><noscript id="6qfwx"></noscript></strike></object>
        1. <center id="6qfwx"><dl id="6qfwx"></dl></center>

            新聞中心

            EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > MSP430單片機(jī)FLASH讀寫操作例子

            MSP430單片機(jī)FLASH讀寫操作例子

            作者: 時(shí)間:2016-11-22 來源:網(wǎng)絡(luò) 收藏
            //******************************************************************************
            //MSP430F149
            // M. Mitchell
            // Texas Instruments Inc.
            // Feb 2005
            // Built with IAR Embedded Workbench Version: 3.21A
            //******************************************************************************

            #include 430x14x.h>

            char value; // 8-bit value to write to segment A

            // Function prototypes
            void write_SegA (char value);
            void copy_A2B (void);

            void main(void)
            {
            WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
            FCTL2 = FWKEY + FSSEL0 + FN0; // MCLK/2 for Flash Timing Generator
            value = 0; // Initialize value

            while(1) // Repeat forever
            {
            write_SegA(value++); // Write segment A, increment value
            copy_A2B(); // Copy segment A to B
            _NOP(); // SET BREAKPOINT HERE
            }
            }

            void write_SegA (char value)
            {
            char *Flash_ptr; // Flash pointer
            unsigned int i;

            Flash_ptr = (char *) 0x1080; // Initialize Flash pointer
            FCTL1 = FWKEY + ERASE; // Set Erase bit
            FCTL3 = FWKEY; // Clear Lock bit
            *Flash_ptr = 0; // Dummy write to erase Flash segment

            FCTL1 = FWKEY + WRT; // Set WRT bit for write operation

            for (i=0; i<128; i++)
            {
            *Flash_ptr++ = value;// Write value to flash
            }

            FCTL1 = FWKEY; // Clear WRT bit
            FCTL3 = FWKEY + LOCK; // Set LOCK bit
            }


            void copy_A2B (void)
            {
            char *Flash_ptrA; // Segment A pointer
            char *Flash_ptrB; // Segment B pointer
            unsigned int i;

            Flash_ptrA = (char *) 0x1080; // Initialize Flash segment A pointer
            Flash_ptrB = (char *) 0x1000; // Initialize Flash segment B pointer
            FCTL1 = FWKEY + ERASE; // Set Erase bit
            FCTL3 = FWKEY; // Clear Lock bit
            *Flash_ptrB = 0; // Dummy write to erase Flash segment B
            FCTL1 = FWKEY + WRT; // Set WRT bit for write operation

            for (i=0; i<128; i++)
            {
            *Flash_ptrB++ = *Flash_ptrA++; // Copy value segment A to segment B
            }

            FCTL1 = FWKEY; // Clear WRT bit
            FCTL3 = FWKEY + LOCK; // Set LOCK bit
            }


            關(guān)鍵詞: MSP430單片機(jī)FLASH讀

            評論


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

            關(guān)閉