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

📄 at45db041d.lis

📁 用ATMEGA16的硬件SPI驱动AT45DB041D
💻 LIS
📖 第 1 页 / 共 5 页
字号:
                        .even
 020C           _DF_Program_Sector_Protection_Register::
 020C 0E940000          xcall push_xgset300C
 0210 5801              movw R10,R16
 0212 2497              sbiw R28,4
 0214                   .dbline -1
 0214                   .dbline 281
 0214           ; }
 0214           ; /************************************************************
 0214           ; *设置扇区保护
 0214           ; *注意:会改变BUFFER1中的内容
 0214           ; *Sector_Protection_Register:数组中的0~7字节对对应0~7个扇区(0xFF:写保护)(0x00:擦除保护)
 0214           ; 
 0214           ; The Sector Protection Register can be reprogrammed while the sector protection enabled or dis-
 0214           ; abled. Being able to reprogram the Sector Protection Register with the sector protection enabled
 0214           ; allows the user to temporarily disable the sector protection to an individual sector rather than
 0214           ; disabling sector protection completely
 0214           ; ************************************************************/
 0214           ; void DF_Program_Sector_Protection_Register(unsigned char *Sector_Protection_Register)
 0214           ; {
 0214                   .dbline 282
 0214           ;   unsigned char Program_Sector_Protection_Command[4]={0x3D,0x2A,0x7F,0xFC};//设置扇区保护操作码
 0214 80E0              ldi R24,<L77
 0216 90E0              ldi R25,>L77
 0218 FE01              movw R30,R28
 021A 04E0              ldi R16,4
 021C 10E0              ldi R17,0
 021E FA93              st -y,R31
 0220 EA93              st -y,R30
 0222 9A93              st -y,R25
 0224 8A93              st -y,R24
 0226 0E940000          xcall asgncblk
 022A                   .dbline 285
 022A           ;   unsigned char i;
 022A           ; 
 022A           ;   DF_Check_Busy_State();
 022A 56DF              xcall _DF_Check_Busy_State
 022C                   .dbline 286
 022C           ;   Enable_DFLASH();
 022C 30DF              xcall _Enable_DFLASH
 022E                   .dbline 287
 022E           ;   for(i=0;i<4;i++)
 022E 4427              clr R20
 0230 08C0              xjmp L81
 0232           L78:
 0232                   .dbline 288
 0232           ;   {
 0232                   .dbline 289
 0232           ;       SPI_Write_Byte(Program_Sector_Protection_Command[i]);//写设置扇区保护操作码
 0232 CE01              movw R24,R28
 0234 E42F              mov R30,R20
 0236 FF27              clr R31
 0238 E80F              add R30,R24
 023A F91F              adc R31,R25
 023C 0081              ldd R16,z+0
 023E 0ADF              xcall _SPI_Write_Byte
 0240                   .dbline 290
 0240           ;   }
 0240           L79:
 0240                   .dbline 287
 0240 4395              inc R20
 0242           L81:
 0242                   .dbline 287
 0242 4430              cpi R20,4
 0244 B0F3              brlo L78
 0246           X16:
 0246                   .dbline 291
 0246           ;   for(i=0;i<8;i++)
 0246 4427              clr R20
 0248 07C0              xjmp L85
 024A           L82:
 024A                   .dbline 292
 024A           ;   {
 024A                   .dbline 293
 024A           ;       SPI_Write_Byte(Sector_Protection_Register[i]);//写设置扇区保护数据
 024A E42F              mov R30,R20
 024C FF27              clr R31
 024E EA0D              add R30,R10
 0250 FB1D              adc R31,R11
 0252 0081              ldd R16,z+0
 0254 FFDE              xcall _SPI_Write_Byte
 0256                   .dbline 294
 0256           ;   }
 0256           L83:
 0256                   .dbline 291
 0256 4395              inc R20
 0258           L85:
 0258                   .dbline 291
 0258 4830              cpi R20,8
 025A B8F3              brlo L82
 025C           X17:
 025C                   .dbline 295
 025C           ;   Disable_DFLASH();
 025C 20DF              xcall _Disable_DFLASH
 025E                   .dbline -2
 025E           L76:
 025E                   .dbline 0 ; func end
 025E 2496              adiw R28,4
 0260 0C940000          xjmp pop_xgset300C
 0264                   .dbsym l Program_Sector_Protection_Command 0 A[4:4]c
 0264                   .dbsym r i 20 c
 0264                   .dbsym r Sector_Protection_Register 10 pc
 0264                   .dbend
                        .area lit(rom, con, rel)
 0010           L87:
 0010 3200              .byte 50,0
 0012 0000              .byte 0,0
                        .area text(rom, con, rel)
 0264                   .dbfile E:\item\car\AT45DB041D\AT45DB041D.c
 0264                   .dbfunc e DF_Read_Sector_Protection_Register _DF_Read_Sector_Protection_Register fV
 0264           ; Read_Sector_Protection_Register_Command -> y+0
 0264           ;              i -> R20
 0264           ; Sector_Protection_Register -> R10,R11
                        .even
 0264           _DF_Read_Sector_Protection_Register::
 0264 0E940000          xcall push_xgset300C
 0268 5801              movw R10,R16
 026A 2497              sbiw R28,4
 026C                   .dbline -1
 026C                   .dbline 308
 026C           ; }
 026C           ; /************************************************************
 026C           ; *读取扇区保护寄存器内容(返回8个字节,对应8个扇区的情况)
 026C           ; ---------------------------------------
 026C           ; |Sector Number |0 (0a, 0b)  |1 to 7   |
 026C           ; ---------------------------------------
 026C           ; |Protected       |            | FFH     |
 026C           ; ----------------   See PDF  -----------
 026C           ; |Unprotected   |            | 00H       |
 026C           ; ---------------------------------------
 026C           ; ************************************************************/
 026C           ; void DF_Read_Sector_Protection_Register(unsigned char *Sector_Protection_Register)
 026C           ; {
 026C                   .dbline 309
 026C           ;   unsigned char Read_Sector_Protection_Register_Command[4]={0x32,0,0,0};
 026C 80E0              ldi R24,<L87
 026E 90E0              ldi R25,>L87
 0270 FE01              movw R30,R28
 0272 04E0              ldi R16,4
 0274 10E0              ldi R17,0
 0276 FA93              st -y,R31
 0278 EA93              st -y,R30
 027A 9A93              st -y,R25
 027C 8A93              st -y,R24
 027E 0E940000          xcall asgncblk
 0282                   .dbline 312
 0282           ;   unsigned char i;
 0282           ; 
 0282           ;   DF_Check_Busy_State();
 0282 2ADF              xcall _DF_Check_Busy_State
 0284                   .dbline 313
 0284           ;   Enable_DFLASH();
 0284 04DF              xcall _Enable_DFLASH
 0286                   .dbline 315
 0286           ; 
 0286           ;   for(i=0;i<4;i++)//write
 0286 4427              clr R20
 0288 08C0              xjmp L91
 028A           L88:
 028A                   .dbline 316
 028A           ;   {
 028A                   .dbline 317
 028A           ;     SPI_Write_Byte(Read_Sector_Protection_Register_Command[i]);
 028A CE01              movw R24,R28
 028C E42F              mov R30,R20
 028E FF27              clr R31
 0290 E80F              add R30,R24
 0292 F91F              adc R31,R25
 0294 0081              ldd R16,z+0
 0296 DEDE              xcall _SPI_Write_Byte
 0298                   .dbline 318
 0298           ;   }
 0298           L89:
 0298                   .dbline 315
 0298 4395              inc R20
 029A           L91:
 029A                   .dbline 315
 029A 4430              cpi R20,4
 029C B0F3              brlo L88
 029E           X18:
 029E                   .dbline 319
 029E           ;   for(i=0;i<8;i++)//read
 029E 4427              clr R20
 02A0 08C0              xjmp L95
 02A2           L92:
 02A2                   .dbline 320
 02A2           ;   {
 02A2                   .dbline 321
 02A2           ;     Sector_Protection_Register[i] = SPI_Read_Byte(0);
 02A2 0027              clr R16
 02A4 EFDE              xcall _SPI_Read_Byte
 02A6 E42F              mov R30,R20
 02A8 FF27              clr R31
 02AA EA0D              add R30,R10
 02AC FB1D              adc R31,R11
 02AE 0083              std z+0,R16
 02B0                   .dbline 322
 02B0           ;   }
 02B0           L93:
 02B0                   .dbline 319
 02B0 4395              inc R20
 02B2           L95:
 02B2                   .dbline 319
 02B2 4830              cpi R20,8
 02B4 B0F3              brlo L92
 02B6           X19:
 02B6                   .dbline 323
 02B6           ;   Disable_DFLASH();
 02B6 F3DE              xcall _Disable_DFLASH
 02B8                   .dbline -2
 02B8           L86:
 02B8                   .dbline 0 ; func end
 02B8 2496              adiw R28,4
 02BA 0C940000          xjmp pop_xgset300C
 02BE                   .dbsym l Read_Sector_Protection_Register_Command 0 A[4:4]c
 02BE                   .dbsym r i 20 c
 02BE                   .dbsym r Sector_Protection_Register 10 pc
 02BE                   .dbend
                        .area lit(rom, con, rel)
 0014           L97:
 0014 0000              .byte 0,0
 0016 0000              .byte 0,0
 0018 0000              .byte 0,0
 001A 0000              .byte 0,0
 001C           L98:
 001C 0101              .byte 1,1
 001E 0101              .byte 1,1
 0020 0101              .byte 1,1
 0022 0101              .byte 1,1
                        .area text(rom, con, rel)
 02BE                   .dbfile E:\item\car\AT45DB041D\AT45DB041D.c
 02BE                   .dbfunc e DF_Cancel_Sector_Protection _DF_Cancel_Sector_Protection fc
 02BE           ; Sector_Protection_Register_for_Write -> y+8
 02BE           ;              j -> R20
 02BE           ; Sector_Protection_Register_for_Read -> y+0
 02BE           ;              i -> R22,R23
                        .even
 02BE           _DF_Cancel_Sector_Protection::
 02BE 0E940000          xcall push_xgsetF000
 02C2 6097              sbiw R28,16
 02C4                   .dbline -1
 02C4                   .dbline 330
 02C4           ; }
 02C4           ; /************************************************************
 02C4           ; *取消所有扇区保护
 02C4           ; *返回1表示成功取消扇区所以保护
 02C4           ; ************************************************************/
 02C4           ; unsigned char DF_Cancel_Sector_Protection(void)
 02C4           ; {
 02C4                   .dbline 331
 02C4           ;   unsigned char Sector_Protection_Register_for_Write[8]={0,0,0,0,0,0,0,0};//写入0为去保护
 02C4 80E0              ldi R24,<L97
 02C6 90E0              ldi R25,>L97
 02C8 FE01              movw R30,R28
 02CA 3896              adiw R30,8
 02CC 08E0              ldi R16,8
 02CE 10E0              ldi R17,0
 02D0 FA93              st -y,R31
 02D2 EA93              st -y,R30
 02D4 9A93              st -y,R25
 02D6 8A93              st -y,R24
 02D8 0E940000          xcall asgncblk
 02DC                   .dbline 332
 02DC           ;   unsigned char Sector_Protection_Register_for_Read[8]={1,1,1,1,1,1,1,1};//防止默认值为0
 02DC 80E0              ldi R24,<L98
 02DE 90E0              ldi R25,>L98
 02E0 FE01              movw R30,R28
 02E2 08E0              ldi R16,8
 02E4 10E0              ldi R17,0
 02E6 FA93              st -y,R31
 02E8 EA93              st -y,R30
 02EA 9A93              st -y,R25
 02EC 8A93              st -y,R24
 02EE 0E940000          xcall asgncblk
 02F2                   .dbline 334
 02F2           ;   unsigned int i;
 02F2           ;   unsigned char j=1;
 02F2 41E0              ldi R20,1
 02F4                   .dbline 336
 02F4           ;   //使能扇区保护
 02F4           ;   DF_Enable_Sector_Protection();
 02F4 2EDF              xcall _DF_Enable_Sector_Protection
 02F6                   .dbline 339
 02F6           ;   //设置扇区保护
 02F6           ; 
 02F6           ;   DF_Program_Sector_Protection_Register(Sector_Protection_Register_for_Write);
 02F6 8E01              movw R16,R28
 02F8 085F              subi R16,248  ; offset = 8
 02FA 1F4F              sbci R17,255
 02FC 87DF              xcall _DF_Program_Sector_Protection_Register
 02FE                   .dbline 341
 02FE           ;   //读取扇区保护寄存器内容
 02FE           ;   DF_Read_Sector_Protection_Register(Sector_Protection_Register_for_Read);
 02FE 8E01              movw R16,R28
 0300 B1DF              xcall _DF_Read_Sector_Protection_Register
 0302                   .dbline 343
 0302           ;   //判断扇区保护寄存器内容
 0302           ;   for(i=0;i<8;i++)
 0302 6627              clr R22
 0304 7727              clr R23
 0306 0AC0              xjmp L102
 0308           L99:
 0308                   .dbline 344
 0308           ;   {
 0308                   .dbline 345
 0308           ;     if(Sector_Protection_Register_for_Read[i]!=0) j++;
 0308 CE01              movw R24,R28
 030A FB01              movw R30,R22
 030C E80F              add R30,R24
 030E F91F              adc R31,R25
 0310 2080              ldd R2,z+0
 0312 2220              tst R2
 0314 09F0              breq L103
 0316           X20:
 0316                   .dbline 345
 0316 4395              inc R20

⌨️ 快捷键说明

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