• [Infineon]XMC4000系列


    同系列芯片包含如下子类:XMC4800, XMC4700, XMC4500, XMC4400, XMC4300, XMC4200, XMC4100

    1 片内Flash概述

    该系列芯片片内最高有2MB PFLASH,PFLASH映射如下:

    1.1 PFLASH擦除状态为‘0’。

    1.2 Page:256bytes,PFALSH的最小组成单位。

    1.3 Word-Line:由两个Page组成。

    1.4 Physical Sector:最大的擦除单元,大小为64KB~256KB。

    1.5 Logical Sector:同一个Phiscal Sector可划分为多个Logical Sector,也可不划分。每个Physical Sector由若干个Word_line组成。

    1.6 Secotr: 如果一个Physical Sector被划分,指其中的一个Logical Sector;如果没有被划分,指整个Physical Sector。

    1.7 UCB(USER CONFIGURATION BLOCK):配置区,包含保护设置及其他配置数据。

     A “UCB” is a specific logical sector contained in the configuration sector. It contains the protection settings and other data configured by the user. The “UCBs” are the only part of the configuration sector that can be programmed and erased by the user. 

    Command Sequence Definitions

    2.1 The parameter “addr” can be one of the following:
    CCCCH: The “addr” must point into the bank that performs the operation. The last 16 address bits must match CCCCH. It is ecommended to use as address the base address of the bank incremented by CCCCH.
    PA: Absolute start address of the Flash page.
    UCPA: Absolute start address of a user configuration block page.
    SA: Absolute start address of a Flash sector. Allowed are the PFLASH sectors Sx.
    PSA: Absolute start address of a physical sector. Allowed are the PFLASH physical sectors PSx.
    UCBA: Absolute start address of a user configuration block.
    2.2 The parameter “data” can be one of the following:
    WD: 32-bit write data to be loaded into the page assembly buffer.
    xxYY: 8-bit write data as part of a command cycle. Only the byte “YY” is used for command interpretation. The higher order bytes “xx” are ignored.
    xx5y: Specific case for “YY”. The “y” can be “0H” for selecting the PFLASH bank.
    UL: User protection level (xxx0H or xxx1H for user levels 0 and 1).
    PWx: 32-bit password.

    3 操作函数

    3.1 编程PFLASH

     1 /*----------------------------------------------
     2 addr:absolute start address of the Flash page
     3 sz: byte number per page ,should be 256
     4 buf: data buf to be programmed
     5 ----------------------------------------------*/
     6 void ProgramPage (unsigned int addr, unsigned int sz, unsigned int *buf)
     7 {
     8     unsigned int i;
     9     //0.Clear Status
    10     WriteIO(FLASH_NoCACHE + 0x5554,0xF5);
    11     //1.enter page mode
    12     WriteIO(FLASH_NoCACHE + 0x5554,0x50);
    13     //2.Load Page Command
    14   while (sz) {
    15     WriteIO(FLASH_NoCACHE + 0x55F0, *buf);buf ++;
    16     WriteIO(FLASH_NoCACHE + 0x55F4, *buf);  buf ++;         
    17     sz  -= 8;
    18   }
    19   //3.Write Page
    20   
    21   WriteIO(FLASH_NoCACHE + 0x5554,0xAA);                   // Start Write Page Command
    22   WriteIO(FLASH_NoCACHE + 0xAAA8,0x55);
    23   WriteIO(FLASH_NoCACHE + 0x5554,0xA0);
    24   WriteIO(addr,0xAA);
    25   //4.Wait until Write Page completed
    26   for(i=0;i<1000;i++)
    27   {
    28       ReadIO(FLASH0_FSR);
    29       if((nRev_Data&FSR_PBUSY)!=FSR_PBUSY) break;
    30       
    31       if(i==900) Fail(nRev_Data,0,0xab,0);
    32       
    33   }
    34      //5.Check for Error
    35      if((nRev_Data&FSR_ERR)!=0) 
    36      {
    37          Fail(nRev_Data,0,0xab,0);
    38      }
    39 }
    ProgramPage

    3.2 擦除Logical Secotr,注意第十五行代码0x30--erase logical sector;0x40--erase physical sector

     1 /*
     2 *addr: start address of logical sector
     3 */
     4 void EraseLogicalSector(unsigned int addr)
     5 {
     6     unsigned int i;
     7     //0.Clear Status
     8     WriteIO(FLASH_NoCACHE + 0x5554,0xF5);
     9     //2.Erase Sector    
    10   WriteIO(FLASH_NoCACHE + 0x5554,0xAA);                   // Start Block Erase Command
    11   WriteIO(FLASH_NoCACHE + 0xAAA8,0x55);
    12   WriteIO(FLASH_NoCACHE + 0x5554,0x80);
    13   WriteIO(FLASH_NoCACHE + 0x5554,0xAA);
    14   WriteIO(FLASH_NoCACHE + 0xAAA8,0x55);
    15   WriteIO(addr,0x30); // erase logical sector
    16     //3.Wait until Erase completed
    17     for(i=0;i<155000;i++)
    18   {
    19       ReadIO(FLASH0_FSR);
    20       if((nRev_Data&FSR_PBUSY)!=FSR_PBUSY) break;
    21       
    22       if(i==154900) Fail(nRev_Data,0,0xcb,0);      
    23   }
    24      //4.Check for Error
    25      if((nRev_Data&FSR_ERR)!=0) 
    26      {
    27          Fail(nRev_Data,0,0xde,0);
    28      }
    29 }
    EraseLogicalSector
  • 相关阅读:
    JavaScript 常见面试题
    textarea 元素的 placeholder 属性不显示
    CSS 画一个八卦
    CSS 画一个心
    JS判断客户端是否是iOS或者Android端
    前端面试题(一)
    选中文字改变默认颜色
    红包雨的实现
    template 的使用
    函数和入参
  • 原文地址:https://www.cnblogs.com/yangjiguang/p/6026674.html
Copyright © 2020-2023  润新知