C51 COMPILER V9.60.0.0   EFLASH                                                            12/04/2020 11:25:07 PAGE 1   


C51 COMPILER V9.60.0.0, COMPILATION OF MODULE EFLASH
OBJECT MODULE PLACED IN .\Out_Files\eflash.obj
COMPILER INVOKED BY: D:\Keil_C51\C51\BIN\C51.EXE UM800x\driver\eflash.c COMPACT OMF2 OPTIMIZE(9,SIZE) BROWSE MOD517(NOAU
                    -) INCDIR(.\APP;.\Common;.\UM800x\driver;.\UM800x\system) DEBUG PRINT(.\Out_Files\eflash.lst) OBJECT(.\Out_Files\eflash.o
                    -bj)

line level    source

   1          /***********************************************************************
   2           * Copyright (c)  2017 - 2020, Unicmicro Co.,Ltd .
   3           * All rights reserved.
   4           * Filename    : eflash.c
   5           * Description : eflash driver source file
   6           * Author(s)   : Dan
   7           * version     : V1.0
   8           * Modify date : 2020-07-16
   9           ***********************************************************************/
  10          #include  "eflash.h"
  11          
  12          
  13          void FLASH_IRQHandler(void) interrupt 11
  14          {
  15   1              if((OINTUS &0x01) == 0x01)              //写/擦除完成中断
  16   1              {
  17   2                      OINTUS |= 0x01;         
  18   2              }
  19   1              if((OINTUS&0x02) == 0x02)               //Nvr0区发生操作错误
  20   1              {
  21   2                      OINTUS |= 0x02;
  22   2              }
  23   1              if((OINTUS&0x04) == 0x04)               //Nvr1区发生操作错误
  24   1              {
  25   2                      OINTUS |= 0x04; 
  26   2              }
  27   1              if((OINTUS&0x08) == 0x08)               //boot区发生操作错误
  28   1              {
  29   2                      OINTUS |= 0x08;
  30   2              }
  31   1              if((OINTUS&0x10) == 0x10)               //写/擦操作错误
  32   1              {
  33   2                      OINTUS |= 0x10;
  34   2              }
  35   1              if((OINTUS&0x20) == 0x20)               //VDD电压过低
  36   1              {
  37   2                      OINTUS |= 0x20;
  38   2              
  39   2              }
  40   1      
  41   1      }
  42          
  43          
  44          void eflash_init(void)  
  45          {       
  46   1              OPSET |= (0<<3);                        //RD_WAIT = 0
  47   1              OUS = 0x07;                                     //for 16mhz
  48   1              
  49   1              OINTUS = 0x3f;                          //清除所有中断标志位
  50   1              OINTEN = 0x00;                          //关闭所有中断功能
  51   1                      
  52   1      }
  53          
C51 COMPILER V9.60.0.0   EFLASH                                                            12/04/2020 11:25:07 PAGE 2   

  54          
  55          void eflash_write_byte(UINT16 addr,UINT8 value)  
  56          {
  57   1              OPSET |= EFC_WRITE_MODE;        //使能写模式
  58   1              
  59   1              OADR = addr;
  60   1              ODATA = value;
  61   1              OCTRL |= (0x1<<3);                              //PUMP_SEL = 6.75v
  62   1              OCTRL |= (1<<6);                                        //PUMP_EN=1
  63   1              while(!(OCTRL & (1<<1)));       //wait for PUMP OK;
  64   1              OCTRL |= (1<<7);                                        //VPPO_EN = 1
  65   1              while((OCTRL & (1<<7)));        //wait for VPPO_EN = 0
  66   1              OCTRL &= (1<<6);                                        //PUMP_EN=0
  67   1      
  68   1              OPSET &= ~EFC_WRITE_MODE;       //关闭写模式
  69   1              
  70   1      }
  71          
  72          void eflash_write_word(UINT16 addr,UINT16 value)         
  73          {
  74   1              UINT8 i;
  75   1              OPSET |= EFC_WRITE_MODE;   //使能写模式
  76   1              
  77   1              for(i=0 ;i<2;i++)
  78   1              {
  79   2                      OADR = addr + i;
  80   2                      ODATA = value >> (i*8);
  81   2                      OCTRL |= (0x1<<3);                              //PUMP_SEL = 6.75v
  82   2                      OCTRL |= (1<<6);                                        //PUMP_EN=1
  83   2                      while(!(OCTRL & (1<<1)));       //wait for PUMP OK
  84   2                      OCTRL |= (1<<7);                                        //VPPO_EN = 1
  85   2                      while((OCTRL & (1<<7)));        //wait for VPPO_EN = 0
  86   2                      
  87   2                      OCTRL &= (1<<6);                                        //PUMP_EN=0
  88   2              }
  89   1              OPSET &= ~EFC_WRITE_MODE;   //关闭写模式
  90   1      }
  91          
  92          void eflash_write_dword(UINT16 addr,UINT32 value)        
  93          {
  94   1              UINT8 i;
  95   1              OPSET |= EFC_WRITE_MODE;    //使能写模式
  96   1              
  97   1              for(i=0 ;i<4;i++)
  98   1              {
  99   2                      OADR = addr + i;
 100   2                      ODATA = value >> (i*8);
 101   2                      OCTRL |= (0x1<<3);                              //PUMP_SEL = 6.75v
 102   2                      OCTRL |= (1<<6);                                        //PUMP_EN=1
 103   2                      while(!(OCTRL & (1<<1)));       //wait for PUMP OK
 104   2                      OCTRL |= (1<<7);                                        //VPPO_EN = 1
 105   2                      while((OCTRL & (1<<7)));        //wait for VPPO_EN = 0
 106   2                      OCTRL &= (1<<6);                                        //PUMP_EN=0
 107   2              }
 108   1              OPSET &= ~EFC_WRITE_MODE;   //关闭写模式
 109   1      }
 110          
 111          void eflash_erase_page(UINT16 page_addr)        
 112          {
 113   1              OPSET &= ~EFC_WRITE_MODE;
 114   1              OPSET |= EFC_PAGE_ERASE_MODE;  //开启page擦除模式
 115   1              
C51 COMPILER V9.60.0.0   EFLASH                                                            12/04/2020 11:25:07 PAGE 3   

 116   1              OADR = page_addr;
 117   1              OCTRL |= (0x1<<3);                              //PUMP_SEL = 6.75v
 118   1              OCTRL |= (1<<6);                                        //PUMP_EN=1
 119   1              while(!(OCTRL & (1<<1)));       //wait for PUMP OK
 120   1              OCTRL |= (1<<7);                                        //VPPO_EN = 1
 121   1              while((OCTRL & (1<<7)));        //wait for VPPO_EN = 0
 122   1              OCTRL &= (1<<6);                                        //PUMP_EN=0
 123   1              
 124   1              OPSET &= ~EFC_PAGE_ERASE_MODE; //关闭page擦除模式
 125   1      }
 126          
 127          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    326    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----      10
   DATA SIZE        =   ----    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
   EDATA SIZE       =   ----    ----
   HDATA SIZE       =   ----    ----
   XDATA CONST SIZE =   ----    ----
   FAR CONST SIZE   =   ----    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)
