⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 protect.lst

📁 ADuC7020/26是ADI模拟公司开发的ARM7TDMI内核
💻 LST
📖 第 1 页 / 共 3 页
字号:
ARM COMPILER V2.42,  protect                                                               10/12/07  17:51:27  PAGE 1   


ARM COMPILER V2.42, COMPILATION OF MODULE protect
OBJECT MODULE PLACED IN protect.OBJ
COMPILER INVOKED BY: c:\Keil\ARM\BIN\CA.exe protect.c THUMB DEBUG TABS(4) 

stmt  level    source

    1          /*********************************************************************
    2          
    3           Author        : ADI - Apps            www.analog.com/MicroConverter
    4          
    5           Date          : Sept. 2005
    6          
    7           File          : protect.c
    8          
    9           Hardware      : Applicable to ADuC702x rev H or I silicon
   10                           Currently targetting ADuC7026.
   11          
   12           Description   : In this example page 120 to 123 (@ 8F000h) are erased, and 
   13                           10 integers are written beginning at 8F000h. 
   14                           Write protection on pages 120 to 123 is set and data 
   15                           is read back and send through the UART at 9600 bps 
   16          
   17                          1) Protect = 0. see on Hyperterminal the Flash/EE memory content: 00A to 001
   18                          2) Protect = 1. see on Hyperterminal the Flash/EE memory content: 001 to 00A
   19                          3) Protect = 0. see on Hyperterminal error message
   20                          4) use ARMWSD to unprotect the Flash: mass erase command in the configure panel
   21          
   22                  
   23          *********************************************************************/
   24          #include <ADuC7026.h>
   25          #define PROTECT 0
   26          
   27          extern int write (int file, char * ptr, int len);   // Function used to write string
   28          void delay (int length);
   29          void erase_page(unsigned short int addr);
   30          void save(unsigned short int addr, unsigned char data);
   31          void protect_page(unsigned int addr);
   32          unsigned short load(unsigned short int addr);
   33          void senddata(short);
   34          char hex2ascii(char);
   35          unsigned char ERROR;
   36          unsigned char status;
   37          
   38          int main(void)   
   39          {
   40   1          unsigned char count = 0;
   41   1          unsigned int i = 0;
   42   1          char output[7] = "Error\n";
   43   1          ERROR = 0;
   44   1      
   45   1          GP1CON = 0x011;             // Setup tx & rx pins on P1.0 and P1.1
   46   1      
   47   1         // Start setting up UART at 9600bps
   48   1          COMCON0 = 0x80;             // Setting DLAB
   49   1          COMDIV0 = 0x88;             // updated for rev H
   50   1          COMDIV1 = 0x00;
   51   1          COMCON0 = 0x07;             // Clearing DLAB
   52   1      
   53   1          GP4DAT = 0x04000000;        // configure P4.2 as output
   54   1          FEEMOD = 0x8;               // bit 3 should be set to allow erase/write command
   55   1      
   56   1      if (PROTECT){                   // if it is not protected yet
   57   2      
   58   2          erase_page(0xF000);         // erase page 120-123
   59   2      
ARM COMPILER V2.42,  protect                                                               10/12/07  17:51:27  PAGE 2   

   60   2          for (i=0;i<10;i++) {
   61   3              count ++;               // save numbers
   62   3              save(0xF000+2*i, count);
   63   3          }
   64   2      
   65   2          for (i=0;i<10;i++){         // Output Data
   66   3              senddata (load(0xF000+2*i));
   67   3          } 
   68   2      
   69   2          protect_page(0xBFFFFFFF);    // protect pages 120-123
   70   2          RSTSTA = 0x02;               // software reset
   71   2      } 
   72   1      else{
   73   2      
   74   2          erase_page(0xF000);         // erase page 120-123
   75   2      
   76   2          count = 0xA;
   77   2      
   78   2          if (ERROR){
   79   3              write(0,output,7);      // Output Error message
   80   3          }
   81   2          else{
   82   3              for (i=0;i<10;i++){          // Save data
   83   4                  save(0xF000+2*i, count);
   84   4                  count --;
   85   4              }
   86   3      
   87   3              for (i=0;i<10;i++){                // Output Data
   88   4                  senddata (load(0xF000+2*i));
   89   4              } 
   90   3          }    
   91   2      
   92   2          while (1){
   93   3              GP4DAT ^= 0x00040000;       // complement P4.2
   94   3              delay(100000);
   95   3          }
   96   2          
   97   2          }
   98   1      
   99   1          return 0;
  100   1      }
  101          
  102          void delay (int length) {       // delay
  103   1          while (length >= 0)
  104   1              length--;
  105   1      }
  106          
  107          void protect_page(unsigned int addr){
  108   1          FEEADR = 0x1234;                    // Key
  109   1          FEEDAT = 0xA5A5;                    // Key
  110   1          FEEPRO = addr;
  111   1          FEEMOD = 0x48;
  112   1          FEECON = 0x0C;
  113   1          status = FEESTA&0x03;
  114   1          while (!(status)) status = FEESTA&0x03;
  115   1          if ((status&0x02)==0x02) ERROR = 1;
  116   1          return;                             // return 
  117   1      } 
  118          
  119          
  120          unsigned short load(unsigned short int addr){
  121   1          FEEADR = addr;
  122   1          FEECON = 0x01;              // single read command
  123   1          status = FEESTA&0x03;
  124   1          while (!(status)) status = FEESTA&0x03;
  125   1          if ((status&0x02)==0x02) ERROR = 1;
ARM COMPILER V2.42,  protect                                                               10/12/07  17:51:27  PAGE 3   

  126   1          return (FEEDAT);        
  127   1      } 
  128          
  129          
  130          void save(unsigned short int addr, unsigned char data){
  131   1          FEEADR = addr;              // set data address
  132   1          FEEDAT = data;              // set data value
  133   1          FEECON = 0x02;              // single Write command
  134   1          status = FEESTA&0x03;
  135   1          while (!(status)) status = FEESTA&0x03;
  136   1          if ((status&0x02)==0x02) ERROR = 1;
  137   1          return;
  138   1      }
  139          
  140          void erase_page(unsigned short int addr){
  141   1          FEEADR = addr;              // set data address
  142   1          FEECON = 0x05;              // erase page command
  143   1          status = FEESTA&0x03;
  144   1          while (!(status)) status = FEESTA&0x03;
  145   1          if ((status&0x02)==0x02) ERROR = 1;
  146   1          return;
  147   1      }
  148          
  149          void senddata(short to_send){
  150   1          while(!(0x020==(COMSTA0 & 0x020))){}
  151   1              COMTX = 0x0A;                       // output LF 
  152   1          while(!(0x020==(COMSTA0 & 0x020))){}
  153   1              COMTX = 0x0D;                       // output CR 
  154   1          while(!(0x020==(COMSTA0 & 0x020))){}
  155   1              COMTX = hex2ascii ((to_send >> 8) & 0x0F);
  156   1          while(!(0x020==(COMSTA0 & 0x020))){}
  157   1              COMTX = hex2ascii ((to_send >> 4) & 0x0F);                      
  158   1          while(!(0x020==(COMSTA0 & 0x020))){}
  159   1              COMTX = hex2ascii (to_send & 0x0F);                         
  160   1      }
  161          
  162          
  163          char hex2ascii(char toconv){
  164   1          if (toconv<0x0A) toconv += 0x30;
  165   1          else toconv += 0x37;
  166   1          return (toconv);
  167   1      }
  168          
  169          
ARM COMPILER V2.42,  protect                                                               10/12/07  17:51:27  PAGE 4   

ASSEMBLY LISTING OF GENERATED OBJECT CODE



*** EXTERNALS:
 EXTERN CODE16 (write?T)
 EXTERN NUMBER (__startup)



*** PUBLICS:
 PUBLIC         delay?T
 PUBLIC         erase_page?T
 PUBLIC         save?T
 PUBLIC         protect_page?T
 PUBLIC         load?T
 PUBLIC         senddata?T
 PUBLIC         hex2ascii?T
 PUBLIC         main
 PUBLIC         ERROR
 PUBLIC         status



*** DATA SEGMENT '?DT0?protect':
 00000000          ERROR:
 00000000            DS          1
 00000001          status:
 00000001            DS          1

*** DATA SEGMENT '?CON?protect':
 00000000          ?tpl?0001:
 00000000           BEGIN_INIT
 00000000            DB          'Error',0x0A,0x00
 00000007           END_INIT



*** CODE SEGMENT '?PR?main?protect':
   38: int main(void)   
 00000000  B500      PUSH        {LR}
 00000002  B082      SUB         R13,#0x8
   39: {
 00000004            ; SCOPE-START
   40:     unsigned char count = 0;
 00000004  2500      MOV         R5,#0x0
 00000006  ---- Variable 'count' assigned to Register 'R5' ----
   41:     unsigned int i = 0;
 00000006  2400      MOV         R4,#0x0
 00000008  ---- Variable 'i' assigned to Register 'R4' ----
   42:     char output[7] = "Error\n";
 00000008  4800      LDR         R1,=?tpl?0001 ; ?tpl?0001
 0000000A  A800      ADD         R0,R13,#0x0
 0000000C  2207      MOV         R2,#0x7
 0000000E          L_82:
 0000000E  780B      LDRB        R3,[R1,#0x0]
 00000010  7003      STRB        R3,[R0,#0x0]
 00000012  1C49      ADD         R1,R1,#0x1
 00000014  1C40      ADD         R0,R0,#0x1
 00000016  1E52      SUB         R2,R2,#0x1
 00000018  D1F9      BNE         L_82  ; T=0x0000000E
   43:     ERROR = 0;
 0000001A  2100      MOV         R1,#0x0
 0000001C  4800      LDR         R0,=ERROR ; ERROR
 0000001E  7001      STRB        R1,[R0,#0x0] ; ERROR
   45:     GP1CON = 0x011;             // Setup tx & rx pins on P1.0 and P1.1
 00000020  2111      MOV         R1,#0x11
 00000022  4800      LDR         R0,=0xFFFFF404
 00000024  6001      STR         R1,[R0,#0x0]

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -