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

📄 serires sub.lst

📁 本程序实现通过BDM方式访问MOTOROLA 9S12单片机EEPROM
💻 LST
📖 第 1 页 / 共 2 页
字号:
 200   2              }
 201   1      }
 202          
 203          void Write_datas()
 204          {
 205   1              uchar addrll,addrhh;
 206   1              int w_cycle;
 207   1              uint Crystal,Crystal_r;
 208   1              uint Data_Size_Write;
 209   1      //      uchar byte_h,byte_l;
 210   1              uchar back_byte_h,back_byte_l;
 211   1      
 212   1              Crystal=Baud_Config();
 213   1      
 214   1              In_datas();
 215   1              output(0xee);
 216   1      
 217   1              Crystal_r=Crystal+1;
 218   1       
 219   1              addrhh=Instruction[1];
 220   1              addrll=Instruction[2];
 221   1              Data_Size_Write=(Instruction[3])*256+Instruction[4];
 222   1      
 223   1              //Trbyte(0x90,Crystal,Crystal);
 224   1              delay10ms();
 225   1              Config_Eeprom(Crystal);
 226   1              delay100ms();
 227   1      
 228   1              for(w_cycle=0;w_cycle<Data_Size_Write;w_cycle+=4)
 229   1                      {
 230   2                      Trbyte(0xC8,Crystal,Crystal);Trbyte(addrhh,Crystal,Crystal);Trbyte(addrll,Crystal,Crystal);
 231   2                      Trbyte(0xff,Crystal,Crystal);Trbyte(0xff,Crystal,Crystal);
 232   2                      delay104us();
 233   2                      Trbyte(0xC0,Crystal,Crystal);Trbyte(0x01,Crystal,Crystal);Trbyte(0x16,Crystal,Crystal);Trbyte(0x40,Cryst
             -al,Crystal);Trbyte(0x40,Crystal,Crystal);//C0 01 16 40 40             Erase two words(fore bytes)
 234   2                      delay104us();
 235   2                      Trbyte(0xC0,Crystal,Crystal);Trbyte(0x01,Crystal,Crystal);Trbyte(0x15,Crystal,Crystal);Trbyte(0x80,Cryst
             -al,Crystal);Trbyte(0x80,Crystal,Crystal);//C0 01 15 80 80       Programme a word(two bytes)           
 236   2                      delay104us();
 237   2              do
 238   2                      {
 239   3                      delay104us();
C51 COMPILER V7.50   SERIRES_SUB                                                           07/16/2008 08:39:35 PAGE 5   

 240   3                      Trbyte(0xE0,Crystal,Crystal);Trbyte(0x01,Crystal,Crystal);Trbyte(0x15,Crystal,Crystal);back_byte_h=RecBy
             -te(Crystal_r);back_byte_l=RecByte(Crystal_r);
 241   3                      }
 242   2                      while((back_byte_l & 0x80)!=0x80);                                      //Erase 4 bytes
 243   2                      delay10ms();
 244   2      
 245   2              //      delay52us();
 246   2                      // start to write byte1
 247   2                      Trbyte(0xC8,Crystal,Crystal);Trbyte(addrhh,Crystal,Crystal);Trbyte(addrll,Crystal,Crystal);
 248   2                      Trbyte(Eeprom[w_cycle],Crystal,Crystal);Trbyte(Eeprom[w_cycle+1],Crystal,Crystal);
 249   2                      delay104us();
 250   2                      Trbyte(0xC0,Crystal,Crystal);Trbyte(0x01,Crystal,Crystal);Trbyte(0x16,Crystal,Crystal);Trbyte(0x20,Cryst
             -al,Crystal);Trbyte(0x20,Crystal,Crystal);//C0 01 16 20 20             Programme a word(two bytes)
 251   2                      delay104us();
 252   2                      Trbyte(0xC0,Crystal,Crystal);Trbyte(0x01,Crystal,Crystal);Trbyte(0x15,Crystal,Crystal);Trbyte(0x80,Cryst
             -al,Crystal);Trbyte(0x80,Crystal,Crystal);//C0 01 15 80 80       Programme a word(two bytes)           
 253   2                      delay104us();
 254   2              do
 255   2                      {
 256   3                      delay104us();
 257   3                      Trbyte(0xE0,Crystal,Crystal);Trbyte(0x01,Crystal,Crystal);Trbyte(0x15,Crystal,Crystal);back_byte_h=RecBy
             -te(Crystal_r);back_byte_l=RecByte(Crystal_r);
 258   3                      }
 259   2                      while((back_byte_l & 0x80)!=0x80);              
 260   2                      delay10ms();
 261   2                      addrll+=2;
 262   2                      if(addrll==0)             
 263   2                              {addrhh+=1;}
 264   2              
 265   2                      delay52us();
 266   2                      // start to write byte2
 267   2                      Trbyte(0xC8,Crystal,Crystal);Trbyte(addrhh,Crystal,Crystal);Trbyte(addrll,Crystal,Crystal);
 268   2                      Trbyte(Eeprom[w_cycle+2],Crystal,Crystal);Trbyte(Eeprom[w_cycle+3],Crystal,Crystal);
 269   2                      delay104us();
 270   2                      Trbyte(0xC0,Crystal,Crystal);Trbyte(0x01,Crystal,Crystal);Trbyte(0x16,Crystal,Crystal);Trbyte(0x20,Cryst
             -al,Crystal);Trbyte(0x20,Crystal,Crystal);//C0 01 16 20 20             Programme a word(two bytes)
 271   2                      delay104us();
 272   2                      Trbyte(0xC0,Crystal,Crystal);Trbyte(0x01,Crystal,Crystal);Trbyte(0x15,Crystal,Crystal);Trbyte(0x80,Cryst
             -al,Crystal);Trbyte(0x80,Crystal,Crystal);//C0 01 15 80 80       Programme a word(two bytes)           
 273   2                      delay104us();
 274   2              do
 275   2                      {
 276   3                      delay104us();
 277   3                      Trbyte(0xE0,Crystal,Crystal);Trbyte(0x01,Crystal,Crystal);Trbyte(0x15,Crystal,Crystal);back_byte_h=RecBy
             -te(Crystal_r);back_byte_l=RecByte(Crystal_r);
 278   3                      }
 279   2                      while((back_byte_l & 0x80)!=0x80);
 280   2                      delay104us();
 281   2                      addrll+=2;
 282   2                      if(addrll==0)             
 283   2                              {addrhh+=1;}
 284   2                      delay10ms();
 285   2                      }
 286   1      //      delay200ms();
 287   1              output(0x55);
 288   1              output(0xff);
 289   1      }
 290          /*
 291          void Erase_datas()
 292          {
 293                  uchar addrll,addrhh;
 294                  int w_cycle;
C51 COMPILER V7.50   SERIRES_SUB                                                           07/16/2008 08:39:35 PAGE 6   

 295                  uint Crystal,Crystal_r;
 296                  uint Data_Size_Write;
 297          //      uchar byte_h,byte_l;
 298                  uchar back_byte_h,back_byte_l;
 299          
 300                  Crystal=Baud_Config();
 301          
 302                  Crystal_r=Crystal+1;
 303           
 304                  addrhh=Instruction[1];
 305                  addrll=Instruction[2];
 306                  Data_Size_Write=(Instruction[3])*256+Instruction[4];
 307          
 308                  delay10ms();
 309                  Config_Eeprom(Crystal);
 310                  delay10ms();
 311          
 312                  for(w_cycle=0;w_cycle<Data_Size_Write;w_cycle+=4)
 313                          {
 314                          Trbyte(0xC8,Crystal,Crystal);Trbyte(addrhh,Crystal,Crystal);Trbyte(addrll,Crystal,Crystal);
 315                          Trbyte(0xff,Crystal,Crystal);Trbyte(0xff,Crystal,Crystal);
 316                          delay52us();
 317                          Trbyte(0xC0,Crystal,Crystal);Trbyte(0x01,Crystal,Crystal);Trbyte(0x16,Crystal,Crystal);Trbyte(0x40,Cryst
             -al,Crystal);Trbyte(0x40,Crystal,Crystal);//C0 01 16 40 40             Erase two words(fore bytes)
 318                          delay52us();
 319                          Trbyte(0xC0,Crystal,Crystal);Trbyte(0x01,Crystal,Crystal);Trbyte(0x15,Crystal,Crystal);Trbyte(0x80,Cryst
             -al,Crystal);Trbyte(0x80,Crystal,Crystal);//C0 01 15 80 80       Programme a word(two bytes)           
 320                          delay52us();
 321                  do
 322                          {
 323                          delay104us();
 324                          Trbyte(0xE0,Crystal,Crystal);Trbyte(0x01,Crystal,Crystal);Trbyte(0x15,Crystal,Crystal);back_byte_h=RecBy
             -te(Crystal_r);back_byte_l=RecByte(Crystal_r);
 325                          }
 326                          while((back_byte_l & 0x80)!=0x80);                                      //Erase 4 bytes
 327                          delay10ms();
 328                          addrll+=4;
 329                          if(addrll==0)             
 330                                  {addrhh+=1;}
 331          
 332                          
 333                          }
 334                  output(0x55);
 335                  output(0xff);
 336          }*/
 337          
 338          void Erase_datas()
 339          {
 340   1              uchar addrll,addrhh;
 341   1      //      int w_cycle;
 342   1              uint Crystal,Crystal_r;
 343   1              uint Data_Size_Write;
 344   1      //      uchar byte_h,byte_l;
 345   1              uchar back_byte_h,back_byte_l;
 346   1      
 347   1              Crystal=Baud_Config();
 348   1      
 349   1              Crystal_r=Crystal+1;
 350   1       
 351   1              addrhh=Instruction[1];
 352   1              addrll=Instruction[2];
 353   1              Data_Size_Write=(Instruction[3])*256+Instruction[4];
C51 COMPILER V7.50   SERIRES_SUB                                                           07/16/2008 08:39:35 PAGE 7   

 354   1      
 355   1              delay10ms();
 356   1              Config_Eeprom(Crystal);
 357   1              delay10ms();
 358   1      
 359   1      
 360   1              Trbyte(0xC8,Crystal,Crystal);Trbyte(addrhh,Crystal,Crystal);Trbyte(addrll,Crystal,Crystal);
 361   1              Trbyte(0xff,Crystal,Crystal);Trbyte(0xff,Crystal,Crystal);
 362   1              delay52us();
 363   1              Trbyte(0xC0,Crystal,Crystal);Trbyte(0x01,Crystal,Crystal);Trbyte(0x16,Crystal,Crystal);Trbyte(0x41,Crysta
             -l,Crystal);Trbyte(0x41,Crystal,Crystal);//C0 01 16 40 40              Erase two words(fore bytes)
 364   1              delay52us();
 365   1              Trbyte(0xC0,Crystal,Crystal);Trbyte(0x01,Crystal,Crystal);Trbyte(0x15,Crystal,Crystal);Trbyte(0x80,Crysta
             -l,Crystal);Trbyte(0x80,Crystal,Crystal);//C0 01 15 80 80       Programme a word(two bytes)            
 366   1              delay52us();
 367   1              do
 368   1                      {
 369   2                      delay104us();
 370   2                      Trbyte(0xE0,Crystal,Crystal);Trbyte(0x01,Crystal,Crystal);Trbyte(0x15,Crystal,Crystal);back_byte_h=RecBy
             -te(Crystal_r);back_byte_l=RecByte(Crystal_r);
 371   2                      }
 372   1                      while((back_byte_l & 0x80)!=0x80);                                      //Erase 4 bytes
 373   1       
 374   1              output(0x55);
 375   1              output(0xff);
 376   1      }


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =   2080    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   4096    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----      58
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


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

⌨️ 快捷键说明

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