📄 resetcounter.lst
字号:
C51 COMPILER V7.07 RESETCOUNTER 10/27/2003 16:10:06 PAGE 1
C51 COMPILER V7.07, COMPILATION OF MODULE RESETCOUNTER
OBJECT MODULE PLACED IN ResetCounter.OBJ
COMPILER INVOKED BY: e:\Keil\C51\BIN\C51.EXE ResetCounter.c MODDP2 DEBUG OBJECTEXTEND
stmt level source
1 #include <stdio.h>
2 #include <reg1210.h>
3 #include "rom1210.h"
4
5 // define the page we want to modify
6 #define PAGE_START 0x0400
7 #define PAGE_SIZE 0x80
8
9 // define a pointer to this page
10 char xdata * pFlashPage;
11
12 // define a RAM area as a buffer to hold one page
13 char xdata Buffer[PAGE_SIZE];
14
15 int main()
16 {
17 1 char Result;
18 1 unsigned char i;
19 1
20 1 pFlashPage = (char xdata * ) PAGE_START;
21 1
22 1 // before writing the flash, we have to initialize
23 1 // the usec and msec SFRs because the flash programming
24 1 // routines rely on these SFRs
25 1 USEC = 12-1; // assume a 12 MHz clock
26 1 MSEC = 12000-1;
27 1
28 1 // copy the page from FLASH to RAM
29 1 for(i=0;i<PAGE_SIZE;i++)
30 1 Buffer[i] = *pFlashPage++;
31 1 // increment the counter
32 1 Buffer[0] += 1;
33 1
34 1 // now erase the page
35 1 page_erase(PAGE_START, 0xff, DATA_FLASH);
36 1
37 1 Result = 0;
38 1 // and write the modified contents back into flash
39 1 for(i=0;i<PAGE_SIZE;i++)
40 1 Result |= write_flash_chk (PAGE_START+i, Buffer[i], DATA_FLASH);
41 1
42 1 // synchronize baud rate
43 1 autobaud();
44 1 printf("Writing flash returned %d\n", (int)Result);
45 1
46 1 // re-read the counter
47 1 pFlashPage = (char xdata *) PAGE_START;
48 1 printf("Reset counter is now %d\n", (int)(*pFlashPage));
49 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 167 ----
CONSTANT SIZE = 52 ----
XDATA SIZE = 128 ----
C51 COMPILER V7.07 RESETCOUNTER 10/27/2003 16:10:06 PAGE 2
PDATA SIZE = ---- ----
DATA SIZE = 2 2
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 + -