FMUSER Wirless Transmit Video And Audio More Easier !

[email protected] WhatsApp +8618078869184
Language

    How to write data for Flash memory

     

    The Flash memory module of the MSP430 Flash type single-chip microcomputer is divided into several segments according to different capacities, of which information storage segmenga and segmentb have 128 bytes, and other segments have 512 bytes. The address of SegmentB is: 0x01000H to 0x107F, the address of Segmenta is: 0x01080H to 0x010ffH. The addresses of other segments are different from 0xffff, and each 512 bytes are assigned. When the Flash memory is written, each bit can only be turned "0" by "1", and cannot be "0" to "1", so when we have data to be saved to the Flash memory, you must first The segment performs the entire erase operation, and the erase operation makes the corresponding segment Flash memory into full "1". Below is a subroutine that erases the flash segment, and after configuring the necessary registers, write the data in the segment, and erase a segment. Void Flash_CLR (INT * PTR) { _Dint (); // off interrupt FCTL3 = 0x0a500; // * Lock = 0 unlock FCTL1 = 0x0a502; // * ERASE = 1 enable erasure * ((Int *) PTR) = 0; // * Erase segment } Flash memory can be written according to byte or by word. // byte writing Void Flash_Write_INT8 (INT8_T * PTR, INT8_T VALUE) { _Dint (); FCTL3 = 0x0a500; // Lock = 0 unlock FCTL1 = 0x0A540; // Write = 1 enable written * (INT8_T *) PTR) = value; // Write data } // word writing Void Flash_Write_INT16 (INT16_T * PTR, INT16_T VALUE) { _Dint (); FCTL3 = 0x0a500; / * Lock = 0 * / FCTL1 = 0x0A540; / * Write = 1 * / * ((Int16_t *) PTR) = value; / * Program the Flash * / } Flash memory can be written continuously / / Write the specified number of data by byte Void Flash_Memcpy (Char * Ptr, Char * from, INT LEN) { _Dint (); FCTL3 = 0x0a500; / * Lock = 0 * / FCTL1 = 0x0A540; / * Write = 1 * / While (len) { * PTR ++ = * from ++; Len -; } } In our application, you can save the data to be saved in a custom structure, for example: Typedef struct setup { FLOAT GAIN_CH0; // 0 channel gain FLOAT GAIN_CH1; // 1 channel gain FLOAT GAIN_CH2; // 2 channel gain ... CHAR INIT_FLAG; // Initialization marker, constant to 0xAA; } Setup; We define a setup structure, store the gain of three AD channels, and other information to be saved, the role of init_flag is whether the parameters of the flag flash have been properly initialized, when we set the flash parameter, set the init_flag The fixed value, for example, set to 0xaah, check the init_flag when the program starts running, when the value of the init_flag is 0xaah, indicating that the parameters have been initialized. Use flash parameters: Define a setup type pointer variable in the program, access the parameters in Flash by this pointer. E.g: #Define segmenta 0x1080 Float Temp; Setup * p_setup_flash = (setup *) Segmenta IF (p_setup_flash- "init_flag == 0xAA) { Temp = p_setup_flash- "gain_CH0; } Modify FLASH information: Since Flash cannot be directly modified as RAM, you can copy Flash information to the RAM. After modifying the corresponding parameters, re-saved to the Flash memory before you first erase the Flash storage area. E.g: Setup * p_setup; Setup buf; // Temporary variable P_setup = (setup *) segmenta // pointing to Flash Memcpy (Char *) BUF, (char *) p_setup_flash, sizeof (setup)); // Copy to RAM P_setup = // Pointing RAM P_setup- "GAIN_CH0 = 1.02; // Modify parameters Flash_memcpy ((char *) p_setup_flash, (char *) BUF, SIZEOF (SETUP)); // Copy to Flash, Technology Zone How to write data for Flash memory Deep interpretation STM32 data preservation and destruction Enterprise SATA Solid State Drive Based on 64-layer 3D NAND Technology Big data will bring big changes to fundamentally enhance storage performance DS1991 features, working principle encryption code protection memory area reading

     

     

     

     

    List all Question

    Nickname

    Email

    Questions

    Our other product:

    Professional FM Radio Station Equipment Package

     



     

    Hotel IPTV Solution

     


      Enter email  to get a surprise

      fmuser.org

      es.fmuser.org
      it.fmuser.org
      fr.fmuser.org
      de.fmuser.org
      af.fmuser.org ->Afrikaans
      sq.fmuser.org ->Albanian
      ar.fmuser.org ->Arabic
      hy.fmuser.org ->Armenian
      az.fmuser.org ->Azerbaijani
      eu.fmuser.org ->Basque
      be.fmuser.org ->Belarusian
      bg.fmuser.org ->Bulgarian
      ca.fmuser.org ->Catalan
      zh-CN.fmuser.org ->Chinese (Simplified)
      zh-TW.fmuser.org ->Chinese (Traditional)
      hr.fmuser.org ->Croatian
      cs.fmuser.org ->Czech
      da.fmuser.org ->Danish
      nl.fmuser.org ->Dutch
      et.fmuser.org ->Estonian
      tl.fmuser.org ->Filipino
      fi.fmuser.org ->Finnish
      fr.fmuser.org ->French
      gl.fmuser.org ->Galician
      ka.fmuser.org ->Georgian
      de.fmuser.org ->German
      el.fmuser.org ->Greek
      ht.fmuser.org ->Haitian Creole
      iw.fmuser.org ->Hebrew
      hi.fmuser.org ->Hindi
      hu.fmuser.org ->Hungarian
      is.fmuser.org ->Icelandic
      id.fmuser.org ->Indonesian
      ga.fmuser.org ->Irish
      it.fmuser.org ->Italian
      ja.fmuser.org ->Japanese
      ko.fmuser.org ->Korean
      lv.fmuser.org ->Latvian
      lt.fmuser.org ->Lithuanian
      mk.fmuser.org ->Macedonian
      ms.fmuser.org ->Malay
      mt.fmuser.org ->Maltese
      no.fmuser.org ->Norwegian
      fa.fmuser.org ->Persian
      pl.fmuser.org ->Polish
      pt.fmuser.org ->Portuguese
      ro.fmuser.org ->Romanian
      ru.fmuser.org ->Russian
      sr.fmuser.org ->Serbian
      sk.fmuser.org ->Slovak
      sl.fmuser.org ->Slovenian
      es.fmuser.org ->Spanish
      sw.fmuser.org ->Swahili
      sv.fmuser.org ->Swedish
      th.fmuser.org ->Thai
      tr.fmuser.org ->Turkish
      uk.fmuser.org ->Ukrainian
      ur.fmuser.org ->Urdu
      vi.fmuser.org ->Vietnamese
      cy.fmuser.org ->Welsh
      yi.fmuser.org ->Yiddish

       
  •  

    FMUSER Wirless Transmit Video And Audio More Easier !

  • Contact

    Address:
    No.305 Room HuiLan Building No.273 Huanpu Road Guangzhou China 510620

    E-mail:
    [email protected]

    Tel / WhatApps:
    +8618078869184

  • Categories

  • Newsletter

    FIRST OR FULL NAME

    E-mail

  • paypal solution  Western UnionBank OF China
    E-mail:[email protected]   WhatsApp:+8618078869184   Skype:sky198710021 Chat with me
    Copyright 2006-2020 Powered By www.fmuser.org

    Contact Us