About the read and write operation method of MSP430-Flash exceeding 64K

Publisher:不加糖的302Latest update time:2018-05-01 Source: eefocusKeywords:MSP430 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

About the read and write operation method of MSP430-Flash exceeding 64K


#include "msp430xG46x.h"  

void WriteFlashErrorNum(void);  

//----------------------------------------------------------------------  

//Function: Read data from flash, just need to give the first address and the number of data to be retrieved  

// Input: waddr is the address of the flash, length is the data length  

// Output: None  

//----------------------------------------------------------------------  

void ReadFlash(unsigned long int waddr,unsigned int length)  

{  

  unsigned char i=0;  

  if(FlashMangleFlag==0)  

  {  

    while(FCTL3 & BUSY);  

    if(length>64) length=64;  

    while(length--)  

    {  

      Internal_flashdata[i++]=__data20_read_char(waddr++);  

    }  

  }  

}  

 

//----------------------------------------------------------------------  

//Function: segment erase;  

//Date: 2006.12.13  

// Input: waddr is the address of the flash,  

// Output: None  

//----------------------------------------------------------------------  

//void EraseFlashOneBlock(unsigned long int waddr)  

void EraseFlash(unsigned long int waddr)  

{  

  if(FlashMangleFlag==0)  

  {  

    if((waddr>=0x1f400) && (waddr<0x20000))  

    {  

      while(FCTL3 & BUSY);  

      _DINT();  

      FCTL2 = FWKEY + FSSEL1 + FN4;  

      FCTL3 = FWKEY;                            // Clear Lock bit  

      FCTL1 = FWKEY + ERASE;                    // Set Erase bit  

      __data20_write_char(waddr,0);             // Dummy write to erase Flash segment  

      while(FCTL3 & BUSY);  

      FCTL3 = FWKEY + LOCK;                     // Reset LOCK bit  

      _UNITE();  

    }  

  }  

}  

 

//----------------------------------------------------------------------  

//Function: write data to flash;  

//Date: 2006.12.13  

// Input: waddr is the address of the flash, length is the data length, *buf is the pointer to the data  

// Output: None  

//----------------------------------------------------------------------  

unsigned char  WriteFlash(unsigned long int waddr,unsigned char *buf,unsigned int length)  

{  

    unsigned int i;  

    unsigned char temp,ErrorFlag = 0;  

    if(FlashMangleFlag==0)  

    {  

      if((waddr>=0x1f400) && (waddr<0x20000))  

      {  

        while(FCTL3 & BUSY);  

        _DINT();  

        FCTL2 = FWKEY + FSSEL1 + FN4;  

        FCTL3 = FWKEY;                            // Clear Lock bit  

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

        for(i=0;i

        {  

          __data20_write_char(waddr,*buf);     // Write value to flash    

          temp = __data20_read_char(waddr);    // Read one byte  

           

          if(temp!=(*buf)) // Determine whether the read data is equivalent to the written data  

          {    

            ErrorFlag = 1; //Write flash operation error flag  

            ErrorFlashNum ++ ;  

          }    

           

          waddr++;buf++;  

        }  

          

        while(FCTL3 & BUSY);  

          

        FCTL1 = FWKEY;  

        FCTL3 = FWKEY + LOCK;                     // Reset LOCK bit  

        _UNITE();  

        if(ErrorFlag == 1) WriteFlashErrorNum();  

      }  

    }  

    return ErrorFlag;  


Keywords:MSP430 Reference address:About the read and write operation method of MSP430-Flash exceeding 64K

Previous article:About the operation of internal Flash of Msp430 Flash microcontroller
Next article:MSP430 FLASH structure InfoA (1080H-10FFh) and InfoB (1000H-10FFH)

Recommended ReadingLatest update time:2024-11-15 14:32

S3C2410 NAND Flash MTD configuration
1 ./drivers/mtd/nand/s3c2410.c static void s3c2410_nand_init_chip(struct s3c2410_nand_info *info,                                    struct s3c2410_nand_mtd *nmtd,                                    struct s3c2410_nand_set *set) Change NAND_ECC_SOFT to NAND_ECC_NONE 2 ./arch/arm/plat-s3c24xx/common-smdk.c stat
[Microcontroller]
NOR and NAND Flash boot analysis
1. JZ2440 uses NOR Flash to start When NOR starts, address 0 is located in NOR Flash, corresponding to BNAK0. The CPU runs the program directly from address 0 of NOR Flash. The code can be copied directly from NOR Flash to the link address of SDRAM. NOR Flash can be read like memory, so it can be copied directly, an
[Microcontroller]
NOR and NAND Flash boot analysis
How to use JLink to indirectly program Nor and Nand Flash of S3C2410 and S3C2440 development boards
1. Briefly explain that JLink’s debugging function and Flash programming function are very powerful, but the Flash operation of S3C2410 and S3C2440 is a bit troublesome: SDRAM needs to be set when programming Nor Flash, otherwise the speed will be very slow; programming Nand Flash is only based on theory It can be ac
[Microcontroller]
How to use JLink to indirectly program Nor and Nand Flash of S3C2410 and S3C2440 development boards
Logic interface technology of low power MSP430 microcontroller in 3V and 5V mixed system
MSP430 ultra-low power microprocessor is a new type of single-chip microcomputer launched by TI. It has a 16-bit streamlined instruction structure, contains a 12-bit fast ADC/Slope ADC, contains 60K bytes of FLASH ROM, 2K bytes of RAM, and has rich on-chip resources, including ADC, PWM, several TIME, serial port, WATCH
[Microcontroller]
Logic interface technology of low power MSP430 microcontroller in 3V and 5V mixed system
msp430 button control LED light
#include "io430.h" /*        There are two ways to control the on and off of the LED light.        Method 1: Interrupt function. Method 2: Use if(P4IN&BIT2) to judge.        When writing code, try to follow the steps to avoid wasting a lot of time looking for bugs due to negligence. */ int main( void ) {   // Stop wat
[Microcontroller]
8051 MCU Basics 2: Core and Memory (RAM, Flash) Architecture
References: ① Keil Help ② "STC MCU Principles and Applications - Analysis and Design from Devices, Assembly, C to Operating Systems" by He Bin ③MCS-51 Series Microcontrollers and Their Applications (6th Edition) by Sun Yucai and Sun Huafang The 8051 microcontroller architecture mainly includes: CPU (computing uni
[Microcontroller]
8051 MCU Basics 2: Core and Memory (RAM, Flash) Architecture
JTAG, SBW, BSL description in MSP430 simulation & burning program
Whether it is simulation or burning program, MSP430 can generally be done through: JTAG, SBW, BSL interface. 1. JTAG uses boundary scan technology. There is a logic interface for JTAG inside the 430. Several registers are connected to the internal data address bus of the 430, so all resources of the 430 can be accesse
[Microcontroller]
The difference between FLASH and EEPROM
The biggest difference between FLASH and EEPROM is that FLASH operates by sector, while EEPROM operates by byte. The two have different addressing methods and different storage unit structures. FLASH has a simpler circuit structure, and the same capacity occupies a smaller chip area, so the cost is naturally lower tha
[Microcontroller]
Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号