Flash.s43
上传用户:xhjmsc
上传日期:2019-09-13
资源大小:389k
文件大小:27k
源码类别:

传真(Fax)编程

开发平台:

C/C++

  1.         NAME Flash
  2.         RTMODEL "__double_size", "32"
  3.         RTMODEL "__pic", "no"
  4.         RTMODEL "__reg_r4", "free"
  5.         RTMODEL "__reg_r5", "free"
  6.         RTMODEL "__rt_version", "1"
  7.         RSEG CSTACK:DATA:SORT:NOROOT(1)
  8.         EXTERN COLUMN_ADDRESS_LOW
  9.         EXTERN COLUMN_ADDRESS_HIGH
  10.         EXTERN ROW_ADDRESS_LOW
  11.         EXTERN ROW_ADDRESS_HIGH
  12.         EXTERN COMMAND_VAL
  13.         EXTERN ADDRESS_VALUE
  14.         EXTERN FLASH_STATUS
  15.         EXTERN aucUartRxBuf
  16.         EXTERN ATcmdDelay
  17.         FUNCTION ATcmdDelay,0202H
  18.         EXTERN FLASH_READ_DATA
  19.         EXTERN ?longjmp_r4
  20.         EXTERN ?longjmp_r5
  21.         EXTERN ?setjmp_r4
  22.         EXTERN ?setjmp_r5
  23.         PUBWEAK ?setjmp_save_r4
  24.         PUBWEAK ?setjmp_save_r5
  25.         PUBLIC ADDRESS_LATCH_INTO
  26.         FUNCTION ADDRESS_LATCH_INTO,0203H
  27.         LOCFRAME CSTACK, 2, STACK
  28.         PUBLIC COMMAND_LATCH_INTO
  29.         FUNCTION COMMAND_LATCH_INTO,0203H
  30.         LOCFRAME CSTACK, 2, STACK
  31.         PUBLIC ERASE_ONE_BLOCK
  32.         FUNCTION ERASE_ONE_BLOCK,021203H
  33.         LOCFRAME CSTACK, 4, STACK
  34.         PUBLIC FLASH_READ_ID
  35.         FUNCTION FLASH_READ_ID,021203H
  36.         LOCFRAME CSTACK, 2, STACK
  37.         PUBLIC Flash_Reset
  38.         FUNCTION Flash_Reset,021203H
  39.         LOCFRAME CSTACK, 4, STACK
  40.         PUBWEAK P2IN
  41.         PUBWEAK P2OUT
  42.         PUBWEAK P5DIR
  43.         PUBWEAK P5IN
  44.         PUBWEAK P5OUT
  45.         PUBLIC PROGRAM_256_BYTE
  46.         FUNCTION PROGRAM_256_BYTE,021203H
  47.         LOCFRAME CSTACK, 8, STACK
  48.         PUBLIC PROGRAM_ONE_PAGE
  49.         FUNCTION PROGRAM_ONE_PAGE,021203H
  50.         LOCFRAME CSTACK, 8, STACK
  51.         PUBLIC READ_256_BYTE
  52.         FUNCTION READ_256_BYTE,021203H
  53.         LOCFRAME CSTACK, 6, STACK
  54.         PUBLIC READ_ONE_DATA
  55.         FUNCTION READ_ONE_DATA,0203H
  56.         LOCFRAME CSTACK, 2, STACK
  57.         PUBLIC READ_STATUS
  58.         FUNCTION READ_STATUS,021203H
  59.         LOCFRAME CSTACK, 2, STACK
  60.         PUBLIC ZERO_ADDRESS
  61.         FUNCTION ZERO_ADDRESS,0203H
  62.         LOCFRAME CSTACK, 2, STACK
  63.         
  64.         CFI Names cfiNames0
  65.         CFI StackFrame CFA SP DATA
  66.         CFI Resource PC:16, SP:16, SR:16, R4:16, R5:16, R6:16, R7:16, R8:16
  67.         CFI Resource R9:16, R10:16, R11:16, R12:16, R13:16, R14:16, R15:16
  68.         CFI EndNames cfiNames0
  69.         
  70.         CFI Common cfiCommon0 Using cfiNames0
  71.         CFI CodeAlign 2
  72.         CFI DataAlign 2
  73.         CFI ReturnAddress PC CODE
  74.         CFI CFA SP+2
  75.         CFI PC Frame(CFA, -2)
  76.         CFI SR Undefined
  77.         CFI R4 SameValue
  78.         CFI R5 SameValue
  79.         CFI R6 SameValue
  80.         CFI R7 SameValue
  81.         CFI R8 SameValue
  82.         CFI R9 SameValue
  83.         CFI R10 SameValue
  84.         CFI R11 SameValue
  85.         CFI R12 Undefined
  86.         CFI R13 Undefined
  87.         CFI R14 Undefined
  88.         CFI R15 Undefined
  89.         CFI EndCommon cfiCommon0
  90.         
  91. // E:projectFaxProgramVson_Bryan_Fax_Conexant_070423filesFlash.c
  92. //    1 //Flash model HY27UF081G2M
  93. //    2 
  94. //    3 #include "includeH.h"
  95.         ASEGN DATA16_AN:DATA:NOROOT,028H
  96. // unsigned char const volatile __data P2IN
  97. P2IN:
  98.         DS8 1
  99.         ASEGN DATA16_AN:DATA:NOROOT,029H
  100. // unsigned char volatile __data P2OUT
  101. P2OUT:
  102.         DS8 1
  103.         ASEGN DATA16_AN:DATA:NOROOT,030H
  104. // unsigned char const volatile __data P5IN
  105. P5IN:
  106.         DS8 1
  107.         ASEGN DATA16_AN:DATA:NOROOT,031H
  108. // unsigned char volatile __data P5OUT
  109. P5OUT:
  110.         DS8 1
  111.         ASEGN DATA16_AN:DATA:NOROOT,032H
  112. // unsigned char volatile __data P5DIR
  113. P5DIR:
  114.         DS8 1
  115. //    4 
  116. //    5 
  117. //    6 //***********************************************************************************
  118. //    7 /*
  119. //    8 void FlashPageCopy(void)
  120. //    9 {
  121. //   10          unsigned char ucFlashSttsOverflowCnt=0;
  122. //   11          COMMAND_VAL=0x00; //#0X00 //00H READ1 0-527BYTE
  123. //   12  COMMAND_LATCH_INTO();
  124. //   13 //ADDRESS
  125. //   14  ADDRESS_VALUE=COLUMN_ADDRESS_LOW; //#0X00
  126. //   15  ADDRESS_LATCH_INTO();
  127. //   16 
  128. //   17  ADDRESS_VALUE=COLUMN_ADDRESS_HIGH; //#0X00
  129. //   18  ADDRESS_LATCH_INTO();
  130. //   19 
  131. //   20  ADDRESS_VALUE=ROW_ADDRESS_LOW; //#0X00
  132. //   21  ADDRESS_LATCH_INTO();
  133. //   22 
  134. //   23  ADDRESS_VALUE=ROW_ADDRESS_HIGH; //#0X00
  135. //   24  ADDRESS_LATCH_INTO();
  136. //   25  FLASH_CON_PORT_OUT &=~ ALE;
  137. //   26 
  138. //   27  COMMAND_VAL=0X35;
  139. //   28  COMMAND_LATCH_INTO();
  140. //   29  //ATcmdDelay();
  141. //   30  while((FLASH_CON_PORT_IN & RB)==0);
  142. //   31    
  143. //   32          COMMAND_VAL=0x85;
  144. //   33  COMMAND_LATCH_INTO();
  145. //   34 
  146. //   35 //ADDRESS
  147. //   36  ADDRESS_VALUE=COLUMN_ADDRESS_LOW; //#0X00
  148. //   37  ADDRESS_LATCH_INTO();
  149. //   38 
  150. //   39  ADDRESS_VALUE=COLUMN_ADDRESS_HIGH; //#0X00
  151. //   40  ADDRESS_LATCH_INTO();
  152. //   41 
  153. //   42  ADDRESS_VALUE=ROW_ADDRESS_LOW; //#0X00
  154. //   43  ADDRESS_LATCH_INTO();
  155. //   44 
  156. //   45  ADDRESS_VALUE=ROW_ADDRESS_HIGH; //#0X00
  157. //   46  ADDRESS_LATCH_INTO();
  158. //   47 
  159. //   48  FLASH_CON_PORT_OUT &=~ ALE;
  160. //   49 
  161. //   50  COMMAND_VAL=cFlashWriteInitiateCmd; //10H INITIATES PROGRAM
  162. //   51  COMMAND_LATCH_INTO();
  163. //   52 
  164. //   53  READ_STATUS();
  165. //   54  ucFlashSttsOverflowCnt=0;
  166. //   55  if(FLASH_STATUS==1&&(ucFlashSttsOverflowCnt++)<2)
  167. //   56  {
  168. //   57  ;
  169. //   58  }
  170. //   59 }
  171. //   60 */
  172. //   61 //***********************************************************************************
  173.         RSEG CODE:CODE:SORT:NOROOT(1)
  174. //   62 void ZERO_ADDRESS(void)
  175. ZERO_ADDRESS:
  176.         CFI Block cfiBlock0 Using cfiCommon0
  177.         CFI Function ZERO_ADDRESS
  178. //   63 {
  179. //   64  COLUMN_ADDRESS_LOW=0X00;
  180. MOV.B #0x0, &COLUMN_ADDRESS_LOW
  181. //   65  COLUMN_ADDRESS_HIGH=0X00;
  182. MOV.B #0x0, &COLUMN_ADDRESS_HIGH
  183. //   66  ROW_ADDRESS_LOW=0X00;
  184. MOV.B #0x0, &ROW_ADDRESS_LOW
  185. //   67  ROW_ADDRESS_HIGH=0X00;
  186. MOV.B #0x0, &ROW_ADDRESS_HIGH
  187. //   68 }
  188. RET
  189.         CFI EndBlock cfiBlock0
  190. //   69 
  191.         RSEG CODE:CODE:NOROOT(1)
  192. //   70 void ERASE_ONE_BLOCK(void)
  193. ERASE_ONE_BLOCK:
  194.         CFI Block cfiBlock1 Using cfiCommon0
  195.         CFI Function ERASE_ONE_BLOCK
  196. //   71 {
  197.         FUNCALL ERASE_ONE_BLOCK, Flash_Reset
  198.         LOCFRAME CSTACK, 4, STACK
  199.         FUNCALL ERASE_ONE_BLOCK, COMMAND_LATCH_INTO
  200.         LOCFRAME CSTACK, 4, STACK
  201.         FUNCALL ERASE_ONE_BLOCK, ADDRESS_LATCH_INTO
  202.         LOCFRAME CSTACK, 4, STACK
  203.         FUNCALL ERASE_ONE_BLOCK, ADDRESS_LATCH_INTO
  204.         LOCFRAME CSTACK, 4, STACK
  205.         FUNCALL ERASE_ONE_BLOCK, COMMAND_LATCH_INTO
  206.         LOCFRAME CSTACK, 4, STACK
  207.         FUNCALL ERASE_ONE_BLOCK, READ_STATUS
  208.         LOCFRAME CSTACK, 4, STACK
  209. PUSH.W R10
  210.         CFI R10 Frame(CFA, -4)
  211.         CFI CFA SP+4
  212. //   72                 unsigned int wGeneralCount = 0;
  213. MOV.W #0x0, R10
  214. //   73 //COMMAND
  215. //   74  Flash_Reset();
  216. CALL #Flash_Reset
  217. //   75 
  218. //   76  COMMAND_VAL=0X60;
  219. MOV.B #0x60, &COMMAND_VAL
  220. //   77  COMMAND_LATCH_INTO();
  221. CALL #COMMAND_LATCH_INTO
  222. //   78 
  223. //   79 //ADDRESS
  224. //   80  /* ADDRESS_VALUE=COLUMN_ADDRESS_LOW; //#0X00
  225. //   81  ADDRESS_LATCH_INTO();
  226. //   82 
  227. //   83  ADDRESS_VALUE=COLUMN_ADDRESS_HIGH; //#0X00
  228. //   84  ADDRESS_LATCH_INTO();                 */ //a bug of Sep. 15
  229. //   85 
  230. //   86  ADDRESS_VALUE=ROW_ADDRESS_LOW; //#0X00
  231. MOV.B &ROW_ADDRESS_LOW, &ADDRESS_VALUE
  232. //   87  ADDRESS_LATCH_INTO();
  233. CALL #ADDRESS_LATCH_INTO
  234. //   88 
  235. //   89  ADDRESS_VALUE=ROW_ADDRESS_HIGH; //#0X00
  236. MOV.B &ROW_ADDRESS_HIGH, &ADDRESS_VALUE
  237. //   90  ADDRESS_LATCH_INTO();
  238. CALL #ADDRESS_LATCH_INTO
  239. //   91  FLASH_CON_PORT_OUT &=~ ALE;
  240. BIC.B #0x2, &0x29
  241. //   92 
  242. //   93  COMMAND_VAL=0XD0;
  243. MOV.B #0xd0, &COMMAND_VAL
  244. //   94  COMMAND_LATCH_INTO();
  245. CALL #COMMAND_LATCH_INTO
  246. //   95  //delay1ms();
  247. //   96 
  248. //   97  READ_STATUS();
  249. CALL #READ_STATUS
  250. //   98  while(wGeneralCount++<0xffff) //Jan. 18, 2007
  251. ??ERASE_ONE_BLOCK_0:
  252. MOV.W R10, R14
  253. MOV.W #0x1, R10
  254. ADD.W R14, R10
  255. CMP.W #0xffff, R14
  256. JEQ ??ERASE_ONE_BLOCK_1
  257. //   99  {if (FLASH_STATUS==0) break;}
  258. CMP.B #0x0, &FLASH_STATUS
  259. JNE ??ERASE_ONE_BLOCK_0
  260. //  100 
  261. //  101 }
  262. ??ERASE_ONE_BLOCK_1:
  263. POP.W R10
  264.         CFI R10 SameValue
  265.         CFI CFA SP+2
  266. RET
  267.         CFI EndBlock cfiBlock1
  268. //  102 
  269. //  103 //***********************************************************************************
  270. //  104 
  271.         RSEG CODE:CODE:NOROOT(1)
  272. //  105 void PROGRAM_ONE_PAGE(unsigned char ucFlashWriteData)
  273. PROGRAM_ONE_PAGE:
  274.         CFI Block cfiBlock2 Using cfiCommon0
  275.         CFI Function PROGRAM_ONE_PAGE
  276. //  106 {
  277.         FUNCALL PROGRAM_ONE_PAGE, COMMAND_LATCH_INTO
  278.         LOCFRAME CSTACK, 8, STACK
  279.         FUNCALL PROGRAM_ONE_PAGE, ADDRESS_LATCH_INTO
  280.         LOCFRAME CSTACK, 8, STACK
  281.         FUNCALL PROGRAM_ONE_PAGE, ADDRESS_LATCH_INTO
  282.         LOCFRAME CSTACK, 8, STACK
  283.         FUNCALL PROGRAM_ONE_PAGE, ADDRESS_LATCH_INTO
  284.         LOCFRAME CSTACK, 8, STACK
  285.         FUNCALL PROGRAM_ONE_PAGE, ADDRESS_LATCH_INTO
  286.         LOCFRAME CSTACK, 8, STACK
  287.         FUNCALL PROGRAM_ONE_PAGE, COMMAND_LATCH_INTO
  288.         LOCFRAME CSTACK, 8, STACK
  289.         FUNCALL PROGRAM_ONE_PAGE, READ_STATUS
  290.         LOCFRAME CSTACK, 8, STACK
  291. PUSH.W R10
  292.         CFI R10 Frame(CFA, -4)
  293.         CFI CFA SP+4
  294. PUSH.W R11
  295.         CFI R11 Frame(CFA, -6)
  296.         CFI CFA SP+6
  297. PUSH.W R8
  298.         CFI R8 Frame(CFA, -8)
  299.         CFI CFA SP+8
  300. MOV.B R12, R10
  301. //  107     unsigned int wByteCount;
  302. //  108     unsigned char ucFlashSttsOverflowCnt=0;
  303. MOV.B #0x0, R8
  304. //  109 //COMMAND
  305. //  110  COMMAND_VAL=cFlashWriteCmd;
  306. MOV.B #0x80, &COMMAND_VAL
  307. //  111  COMMAND_LATCH_INTO();
  308. CALL #COMMAND_LATCH_INTO
  309. //  112 
  310. //  113 //ADDRESS
  311. //  114  ADDRESS_VALUE=0;//COLUMN_ADDRESS_LOW; //#0X00
  312. MOV.B #0x0, &ADDRESS_VALUE
  313. //  115  ADDRESS_LATCH_INTO();
  314. CALL #ADDRESS_LATCH_INTO
  315. //  116 
  316. //  117  ADDRESS_VALUE=0;//COLUMN_ADDRESS_HIGH; //#0X00
  317. MOV.B #0x0, &ADDRESS_VALUE
  318. //  118  ADDRESS_LATCH_INTO();
  319. CALL #ADDRESS_LATCH_INTO
  320. //  119 
  321. //  120  ADDRESS_VALUE=ROW_ADDRESS_LOW; //#0X00
  322. MOV.B &ROW_ADDRESS_LOW, &ADDRESS_VALUE
  323. //  121  ADDRESS_LATCH_INTO();
  324. CALL #ADDRESS_LATCH_INTO
  325. //  122 
  326. //  123  ADDRESS_VALUE=ROW_ADDRESS_HIGH; //#0X00
  327. MOV.B &ROW_ADDRESS_HIGH, &ADDRESS_VALUE
  328. //  124  ADDRESS_LATCH_INTO();
  329. CALL #ADDRESS_LATCH_INTO
  330. //  125 
  331. //  126  FLASH_CON_PORT_OUT &=~ ALE;
  332. BIC.B #0x2, &0x29
  333. //  127  //CALL DELAY_100US
  334. //  128  //for(wGeneralCnt=0;wGeneralCnt<0xff;wGeneralCnt++); //delay
  335. //  129 
  336. //  130  DATA_PORT_OUT_INITIAL;
  337. MOV.B #0xff, &0x32
  338. //  131  for(wByteCount=0;wByteCount<2112;wByteCount++)
  339. MOV.W #0x0, R11
  340. ??PROGRAM_ONE_PAGE_0:
  341. CMP.W #0x840, R11
  342. JC ??PROGRAM_ONE_PAGE_1
  343. //  132  {
  344. //  133  //FLASH_WRITE_DATA=0x55;
  345. //  134  //WRITE_ONE_DATA();
  346. //  135  FLASH_CON_PORT_OUT&=~WE;
  347. BIC.B #0x1, &0x29
  348. //  136    DATA_PORT_OUT=ucFlashWriteData;
  349. MOV.B R10, &0x31
  350. //  137    FLASH_CON_PORT_OUT |= WE;
  351. BIS.B #0x1, &0x29
  352. //  138  }
  353. ADD.W #0x1, R11
  354. JMP ??PROGRAM_ONE_PAGE_0
  355. //  139 
  356. //  140  COMMAND_VAL=cFlashWriteInitiateCmd; //10H INITIATES PROGRAM
  357. ??PROGRAM_ONE_PAGE_1:
  358. MOV.B #0x10, &COMMAND_VAL
  359. //  141  COMMAND_LATCH_INTO();
  360. CALL #COMMAND_LATCH_INTO
  361. //  142 
  362. //  143  READ_STATUS();
  363. CALL #READ_STATUS
  364. //  144  ucFlashSttsOverflowCnt=0;
  365. MOV.B #0x0, R8
  366. //  145  if(FLASH_STATUS==1&&(ucFlashSttsOverflowCnt++)<2)
  367. CMP.B #0x1, &FLASH_STATUS
  368. JNE ??PROGRAM_ONE_PAGE_2
  369. ADD.B #0x1, R8
  370. //  146  {
  371. //  147  ;// Dec. 02,2006
  372. //  148  //ERASE_ONE_BLOCK();
  373. //  149  //PROGRAM_ONE_PAGE();
  374. //  150  }
  375. //  151 }
  376. ??PROGRAM_ONE_PAGE_2:
  377. POP.W R8
  378.         CFI R8 SameValue
  379.         CFI CFA SP+6
  380. POP.W R11
  381.         CFI R11 SameValue
  382.         CFI CFA SP+4
  383. POP.W R10
  384.         CFI R10 SameValue
  385.         CFI CFA SP+2
  386. RET
  387.         CFI EndBlock cfiBlock2
  388. //  152 
  389. //  153 //***********************************************************************************
  390. //  154 //***********************************************************************************
  391.         RSEG CODE:CODE:NOROOT(1)
  392. //  155 void PROGRAM_256_BYTE(void)
  393. PROGRAM_256_BYTE:
  394.         CFI Block cfiBlock3 Using cfiCommon0
  395.         CFI Function PROGRAM_256_BYTE
  396. //  156 {
  397.         FUNCALL PROGRAM_256_BYTE, COMMAND_LATCH_INTO
  398.         LOCFRAME CSTACK, 8, STACK
  399.         FUNCALL PROGRAM_256_BYTE, ADDRESS_LATCH_INTO
  400.         LOCFRAME CSTACK, 8, STACK
  401.         FUNCALL PROGRAM_256_BYTE, ADDRESS_LATCH_INTO
  402.         LOCFRAME CSTACK, 8, STACK
  403.         FUNCALL PROGRAM_256_BYTE, ADDRESS_LATCH_INTO
  404.         LOCFRAME CSTACK, 8, STACK
  405.         FUNCALL PROGRAM_256_BYTE, ADDRESS_LATCH_INTO
  406.         LOCFRAME CSTACK, 8, STACK
  407.         FUNCALL PROGRAM_256_BYTE, COMMAND_LATCH_INTO
  408.         LOCFRAME CSTACK, 8, STACK
  409.         FUNCALL PROGRAM_256_BYTE, READ_STATUS
  410.         LOCFRAME CSTACK, 8, STACK
  411. PUSH.W R10
  412.         CFI R10 Frame(CFA, -4)
  413.         CFI CFA SP+4
  414. PUSH.W R11
  415.         CFI R11 Frame(CFA, -6)
  416.         CFI CFA SP+6
  417. PUSH.W R8
  418.         CFI R8 Frame(CFA, -8)
  419.         CFI CFA SP+8
  420. //  157     unsigned int wGeneralCnt=0;
  421. MOV.W #0x0, R10
  422. //  158     unsigned char ucFlashSttsOverflowCnt=0,ucRxIndex=0;
  423. MOV.B #0x0, R11
  424. MOV.B #0x0, R8
  425. //  159 //COMMAND
  426. //  160  COMMAND_VAL=0X80;
  427. MOV.B #0x80, &COMMAND_VAL
  428. //  161  COMMAND_LATCH_INTO();
  429. CALL #COMMAND_LATCH_INTO
  430. //  162 
  431. //  163 //ADDRESS
  432. //  164  ADDRESS_VALUE=COLUMN_ADDRESS_LOW; //#0X00
  433. MOV.B &COLUMN_ADDRESS_LOW, &ADDRESS_VALUE
  434. //  165  ADDRESS_LATCH_INTO();
  435. CALL #ADDRESS_LATCH_INTO
  436. //  166 
  437. //  167  ADDRESS_VALUE=COLUMN_ADDRESS_HIGH; //#0X00
  438. MOV.B &COLUMN_ADDRESS_HIGH, &ADDRESS_VALUE
  439. //  168  ADDRESS_LATCH_INTO();
  440. CALL #ADDRESS_LATCH_INTO
  441. //  169 
  442. //  170  ADDRESS_VALUE=ROW_ADDRESS_LOW; //#0X00
  443. MOV.B &ROW_ADDRESS_LOW, &ADDRESS_VALUE
  444. //  171  ADDRESS_LATCH_INTO();
  445. CALL #ADDRESS_LATCH_INTO
  446. //  172 
  447. //  173  ADDRESS_VALUE=ROW_ADDRESS_HIGH; //#0X00
  448. MOV.B &ROW_ADDRESS_HIGH, &ADDRESS_VALUE
  449. //  174  ADDRESS_LATCH_INTO();
  450. CALL #ADDRESS_LATCH_INTO
  451. //  175 
  452. //  176  FLASH_CON_PORT_OUT &=~ ALE;
  453. BIC.B #0x2, &0x29
  454. //  177  //CALL DELAY_100US
  455. //  178  for(wGeneralCnt=0;wGeneralCnt<0xff;wGeneralCnt++);
  456. MOV.W #0x0, R10
  457. ??PROGRAM_256_BYTE_0:
  458. CMP.W #0xff, R10
  459. JC ??PROGRAM_256_BYTE_2
  460. ADD.W #0x1, R10
  461. JMP ??PROGRAM_256_BYTE_0
  462. //  179  DATA_PORT_OUT_INITIAL;
  463. ??PROGRAM_256_BYTE_2:
  464. MOV.B #0xff, &0x32
  465. //  180  for(ucRxIndex=0;ucRxIndex<255;ucRxIndex++)
  466. MOV.B #0x0, R8
  467. ??PROGRAM_256_BYTE_1:
  468. CMP.B #0xff, R8
  469. JC ??PROGRAM_256_BYTE_3
  470. //  181  {
  471. //  182  FLASH_CON_PORT_OUT&=~WE;
  472. BIC.B #0x1, &0x29
  473. //  183    DATA_PORT_OUT=aucUartRxBuf[ucRxIndex];
  474. MOV.B R8, R14
  475. AND.W #0xff, R14
  476. MOV.B aucUartRxBuf(R14), &0x31
  477. //  184    FLASH_CON_PORT_OUT |= WE; //LATCH INTO ONE DATA
  478. BIS.B #0x1, &0x29
  479. //  185  }
  480. ADD.B #0x1, R8
  481. JMP ??PROGRAM_256_BYTE_1
  482. //  186 
  483. //  187  COMMAND_VAL=0X10; //10H INITIATES PROGRAM
  484. ??PROGRAM_256_BYTE_3:
  485. MOV.B #0x10, &COMMAND_VAL
  486. //  188  COMMAND_LATCH_INTO();
  487. CALL #COMMAND_LATCH_INTO
  488. //  189 
  489. //  190  READ_STATUS();
  490. CALL #READ_STATUS
  491. //  191  ucFlashSttsOverflowCnt=0;
  492. MOV.B #0x0, R11
  493. //  192  if(FLASH_STATUS==1&&(ucFlashSttsOverflowCnt++)<2)
  494. CMP.B #0x1, &FLASH_STATUS
  495. JNE ??PROGRAM_256_BYTE_4
  496. ADD.B #0x1, R11
  497. //  193  {
  498. //  194  ;// Dec. 02,2006
  499. //  195  //ERASE_ONE_BLOCK();
  500. //  196  //PROGRAM_ONE_PAGE();
  501. //  197  }
  502. //  198 }
  503. ??PROGRAM_256_BYTE_4:
  504. POP.W R8
  505.         CFI R8 SameValue
  506.         CFI CFA SP+6
  507. POP.W R11
  508.         CFI R11 SameValue
  509.         CFI CFA SP+4
  510. POP.W R10
  511.         CFI R10 SameValue
  512.         CFI CFA SP+2
  513. RET
  514.         CFI EndBlock cfiBlock3
  515. //  199 //***********************************************************************************
  516.         RSEG CODE:CODE:NOROOT(1)
  517. //  200 void READ_256_BYTE(void)
  518. READ_256_BYTE:
  519.         CFI Block cfiBlock4 Using cfiCommon0
  520.         CFI Function READ_256_BYTE
  521. //  201 {
  522.         FUNCALL READ_256_BYTE, Flash_Reset
  523.         LOCFRAME CSTACK, 6, STACK
  524.         FUNCALL READ_256_BYTE, COMMAND_LATCH_INTO
  525.         LOCFRAME CSTACK, 6, STACK
  526.         FUNCALL READ_256_BYTE, ADDRESS_LATCH_INTO
  527.         LOCFRAME CSTACK, 6, STACK
  528.         FUNCALL READ_256_BYTE, ADDRESS_LATCH_INTO
  529.         LOCFRAME CSTACK, 6, STACK
  530.         FUNCALL READ_256_BYTE, ADDRESS_LATCH_INTO
  531.         LOCFRAME CSTACK, 6, STACK
  532.         FUNCALL READ_256_BYTE, ADDRESS_LATCH_INTO
  533.         LOCFRAME CSTACK, 6, STACK
  534.         FUNCALL READ_256_BYTE, COMMAND_LATCH_INTO
  535.         LOCFRAME CSTACK, 6, STACK
  536.         FUNCALL READ_256_BYTE, ATcmdDelay
  537.         LOCFRAME CSTACK, 6, STACK
  538. PUSH.W R10
  539.         CFI R10 Frame(CFA, -4)
  540.         CFI CFA SP+4
  541. PUSH.W R11
  542.         CFI R11 Frame(CFA, -6)
  543.         CFI CFA SP+6
  544. //  202                 int wByteCnt=0;
  545. MOV.W #0x0, R10
  546. //  203  unsigned char ucRxCnt=0;
  547. MOV.B #0x0, R11
  548. //  204 //COMMAND
  549. //  205  Flash_Reset();
  550. CALL #Flash_Reset
  551. //  206  COMMAND_VAL=0x00; //#0X00 //00H READ1 0-527BYTE
  552. MOV.B #0x0, &COMMAND_VAL
  553. //  207  COMMAND_LATCH_INTO();
  554. CALL #COMMAND_LATCH_INTO
  555. //  208 //ADDRESS
  556. //  209  ADDRESS_VALUE=COLUMN_ADDRESS_LOW; //#0X00
  557. MOV.B &COLUMN_ADDRESS_LOW, &ADDRESS_VALUE
  558. //  210  ADDRESS_LATCH_INTO();
  559. CALL #ADDRESS_LATCH_INTO
  560. //  211 
  561. //  212  ADDRESS_VALUE=COLUMN_ADDRESS_HIGH; //#0X00
  562. MOV.B &COLUMN_ADDRESS_HIGH, &ADDRESS_VALUE
  563. //  213  ADDRESS_LATCH_INTO();
  564. CALL #ADDRESS_LATCH_INTO
  565. //  214 
  566. //  215  ADDRESS_VALUE=ROW_ADDRESS_LOW; //#0X00
  567. MOV.B &ROW_ADDRESS_LOW, &ADDRESS_VALUE
  568. //  216  ADDRESS_LATCH_INTO();
  569. CALL #ADDRESS_LATCH_INTO
  570. //  217 
  571. //  218  ADDRESS_VALUE=ROW_ADDRESS_HIGH; //#0X00
  572. MOV.B &ROW_ADDRESS_HIGH, &ADDRESS_VALUE
  573. //  219  ADDRESS_LATCH_INTO();
  574. CALL #ADDRESS_LATCH_INTO
  575. //  220  FLASH_CON_PORT_OUT &=~ ALE;
  576. BIC.B #0x2, &0x29
  577. //  221 
  578. //  222  COMMAND_VAL=0X30;
  579. MOV.B #0x30, &COMMAND_VAL
  580. //  223  COMMAND_LATCH_INTO();
  581. CALL #COMMAND_LATCH_INTO
  582. //  224  ATcmdDelay();
  583. CALL #ATcmdDelay
  584. //  225  while((FLASH_CON_PORT_IN & RB)==0);
  585. ??READ_256_BYTE_0:
  586. BIT.B #0x20, &0x28
  587. JNC ??READ_256_BYTE_0
  588. //  226 
  589. //  227  DATA_PORT_IN_INITIAL;
  590. MOV.B #0x0, &0x32
  591. //  228  for(wByteCnt=0,ucRxCnt=0;wByteCnt<256;wByteCnt++)
  592. MOV.W #0x0, R10
  593. MOV.B #0x0, R11
  594. ??READ_256_BYTE_1:
  595. CMP.W #0x100, R10
  596. JGE ??READ_256_BYTE_2
  597. //  229  {
  598. //  230              FLASH_CON_PORT_OUT &=~ RE; //RE IS LOW,ENABLE READ DATA
  599. BIC.B #0x10, &0x29
  600. //  231      aucUartRxBuf[ucRxCnt++]=DATA_PORT_IN;
  601. MOV.B R11, R14
  602. AND.W #0xff, R14
  603. MOV.B &0x30, aucUartRxBuf(R14)
  604. ADD.B #0x1, R11
  605. //  232      FLASH_CON_PORT_OUT |= RE;
  606. BIS.B #0x10, &0x29
  607. //  233  }
  608. ADD.W #0x1, R10
  609. JMP ??READ_256_BYTE_1
  610. //  234 
  611. //  235 }
  612. ??READ_256_BYTE_2:
  613. POP.W R11
  614.         CFI R11 SameValue
  615.         CFI CFA SP+4
  616. POP.W R10
  617.         CFI R10 SameValue
  618.         CFI CFA SP+2
  619. RET
  620.         CFI EndBlock cfiBlock4
  621. //  236 //***********************************************************************************
  622. //  237 
  623. //  238 /***********************************************************************************
  624. //  239 void READ_ONE_PAGE(void)
  625. //  240 {
  626. //  241                 int wByteCnt=0;
  627. //  242  unsigned char ucRxCnt=0;
  628. //  243 //COMMAND
  629. //  244  COMMAND_VAL=0x00; //#0X00 //00H READ1 0-527BYTE
  630. //  245  COMMAND_LATCH_INTO();
  631. //  246 //ADDRESS
  632. //  247  ADDRESS_VALUE=COLUMN_ADDRESS_LOW; //#0X00
  633. //  248  ADDRESS_LATCH_INTO();
  634. //  249 
  635. //  250  ADDRESS_VALUE=COLUMN_ADDRESS_HIGH; //#0X00
  636. //  251  ADDRESS_LATCH_INTO();
  637. //  252 
  638. //  253  ADDRESS_VALUE=ROW_ADDRESS_LOW; //#0X00
  639. //  254  ADDRESS_LATCH_INTO();
  640. //  255 
  641. //  256  ADDRESS_VALUE=ROW_ADDRESS_HIGH; //#0X00
  642. //  257  ADDRESS_LATCH_INTO();
  643. //  258  FLASH_CON_PORT_OUT &=~ ALE;
  644. //  259 
  645. //  260  COMMAND_VAL=0X30;
  646. //  261  COMMAND_LATCH_INTO();
  647. //  262  ATcmdDelay();
  648. //  263  while((FLASH_CON_PORT_IN & RB)==0);
  649. //  264  for(wByteCnt=0,ucRxCnt=0;wByteCnt<2048;wByteCnt++)
  650. //  265  {
  651. //  266              READ_ONE_DATA();
  652. //  267              aucUartRxBuf[ucRxCnt++]=FLASH_READ_DATA;
  653. //  268  }
  654. //  269 }
  655. //  270 ***********************************************************************************/
  656. //  271 
  657. //  272 //***********************************************************************************
  658.         RSEG CODE:CODE:NOROOT(1)
  659. //  273 void READ_STATUS(void)
  660. READ_STATUS:
  661. ??READ_STATUS_0:
  662.         CFI Block cfiBlock5 Using cfiCommon0
  663.         CFI Function READ_STATUS
  664. //  274 {
  665. //  275  //CALL DELAY_50US
  666. //  276  while((FLASH_CON_PORT_IN & RB)==0); //FLASH_CON_PORT,RB,$ //CHECK BUSY
  667.         FUNCALL READ_STATUS, COMMAND_LATCH_INTO
  668.         LOCFRAME CSTACK, 2, STACK
  669.         FUNCALL READ_STATUS, READ_ONE_DATA
  670.         LOCFRAME CSTACK, 2, STACK
  671. BIT.B #0x20, &0x28
  672. JNC ??READ_STATUS_0
  673. //  277 
  674. //  278  COMMAND_VAL=0X70;
  675. MOV.B #0x70, &COMMAND_VAL
  676. //  279 
  677. //  280  COMMAND_LATCH_INTO();
  678. CALL #COMMAND_LATCH_INTO
  679. //  281 
  680. //  282  DATA_PORT_IN_INITIAL;
  681. MOV.B #0x0, &0x32
  682. //  283  READ_ONE_DATA(); //WHEN READY,READ STATUS
  683. CALL #READ_ONE_DATA
  684. //  284  FLASH_STATUS=FLASH_READ_DATA & 0x01; //0 OK 1 error
  685. MOV.B &FLASH_READ_DATA, R14
  686. AND.B #0x1, R14
  687. MOV.B R14, &FLASH_STATUS
  688. //  285  //if((READ_DATA_VALUE&0x01)==0)
  689. //  286  // FLASH_STATUS=0; //0 OK 1 error
  690. //  287 }
  691. RET
  692.         CFI EndBlock cfiBlock5
  693. //  288 
  694. //  289 //***********************************************************************************/
  695. //  290 
  696.         RSEG CODE:CODE:NOROOT(1)
  697. //  291 void FLASH_READ_ID(void)
  698. FLASH_READ_ID:
  699.         CFI Block cfiBlock6 Using cfiCommon0
  700.         CFI Function FLASH_READ_ID
  701. //  292 {
  702. //  293  COMMAND_VAL=0X90;
  703.         FUNCALL FLASH_READ_ID, COMMAND_LATCH_INTO
  704.         LOCFRAME CSTACK, 2, STACK
  705.         FUNCALL FLASH_READ_ID, ADDRESS_LATCH_INTO
  706.         LOCFRAME CSTACK, 2, STACK
  707.         FUNCALL FLASH_READ_ID, READ_ONE_DATA
  708.         LOCFRAME CSTACK, 2, STACK
  709.         FUNCALL FLASH_READ_ID, READ_ONE_DATA
  710.         LOCFRAME CSTACK, 2, STACK
  711.         FUNCALL FLASH_READ_ID, READ_ONE_DATA
  712.         LOCFRAME CSTACK, 2, STACK
  713.         FUNCALL FLASH_READ_ID, READ_ONE_DATA
  714.         LOCFRAME CSTACK, 2, STACK
  715. MOV.B #0x90, &COMMAND_VAL
  716. //  294  COMMAND_LATCH_INTO();
  717. CALL #COMMAND_LATCH_INTO
  718. //  295 
  719. //  296  ADDRESS_VALUE=0X00;
  720. MOV.B #0x0, &ADDRESS_VALUE
  721. //  297  ADDRESS_LATCH_INTO();
  722. CALL #ADDRESS_LATCH_INTO
  723. //  298  FLASH_CON_PORT_OUT &=~ ALE;
  724. BIC.B #0x2, &0x29
  725. //  299 
  726. //  300  DATA_PORT_IN_INITIAL;
  727. MOV.B #0x0, &0x32
  728. //  301  READ_ONE_DATA();
  729. CALL #READ_ONE_DATA
  730. //  302  while (!(FLASH_READ_DATA==0xad));
  731. ??FLASH_READ_ID_0:
  732. CMP.B #0xad, &FLASH_READ_DATA
  733. JNE ??FLASH_READ_ID_0
  734. //  303 
  735. //  304  READ_ONE_DATA();
  736. CALL #READ_ONE_DATA
  737. //  305  while (!(FLASH_READ_DATA==0xf1));
  738. ??FLASH_READ_ID_1:
  739. CMP.B #0xf1, &FLASH_READ_DATA
  740. JNE ??FLASH_READ_ID_1
  741. //  306  READ_ONE_DATA();
  742. CALL #READ_ONE_DATA
  743. //  307  READ_ONE_DATA();
  744. BR #READ_ONE_DATA
  745.         CFI EndBlock cfiBlock6
  746. //  308 }
  747. //  309 //***********************************************************************************
  748. //  310 
  749.         RSEG CODE:CODE:NOROOT(1)
  750. //  311 void Flash_Reset(void) //flash reset
  751. Flash_Reset:
  752.         CFI Block cfiBlock7 Using cfiCommon0
  753.         CFI Function Flash_Reset
  754. //  312 { 
  755.         FUNCALL Flash_Reset, COMMAND_LATCH_INTO
  756.         LOCFRAME CSTACK, 4, STACK
  757. PUSH.W R10
  758.         CFI R10 Frame(CFA, -4)
  759.         CFI CFA SP+4
  760. //  313  int i;
  761. //  314  COMMAND_VAL=0XFF; //reset command
  762. MOV.B #0xff, &COMMAND_VAL
  763. //  315  COMMAND_LATCH_INTO();
  764. CALL #COMMAND_LATCH_INTO
  765. //  316  for (i=0;i<3000;i++); //delay 
  766. MOV.W #0x0, R10
  767. ??Flash_Reset_0:
  768. CMP.W #0xbb8, R10
  769. JGE ??Flash_Reset_1
  770. ADD.W #0x1, R10
  771. JMP ??Flash_Reset_0
  772. //  317 }
  773. ??Flash_Reset_1:
  774. POP.W R10
  775.         CFI R10 SameValue
  776.         CFI CFA SP+2
  777. RET
  778.         CFI EndBlock cfiBlock7
  779. //  318 
  780. //  319 //***********************************************************************************
  781.         RSEG CODE:CODE:SORT:NOROOT(1)
  782. //  320 void COMMAND_LATCH_INTO(void) //FLASH CONTROL PORT
  783. COMMAND_LATCH_INTO:
  784.         CFI Block cfiBlock8 Using cfiCommon0
  785.         CFI Function COMMAND_LATCH_INTO
  786. //  321 {
  787. //  322 
  788. //  323  FLASH_CON_PORT_OUT |= CLE; //COMMAND LATCH ENABLE
  789. BIS.B #0x4, &0x29
  790. //  324  FLASH_CON_PORT_OUT &= ~(CE|WE); //CHIP ENABLE WRITE ENABLE
  791. AND.B #0xf6, &0x29
  792. //  325 
  793. //  326  DATA_PORT_OUT_INITIAL; //MCU OUTPUT,FLASH READ COMMAND
  794. MOV.B #0xff, &0x32
  795. //  327 
  796. //  328  DATA_PORT_OUT=COMMAND_VAL; //DATA SETUP
  797. MOV.B &COMMAND_VAL, &0x31
  798. //  329 
  799. //  330  FLASH_CON_PORT_OUT |= WE; //LATCH INTO THE COMMAND
  800. BIS.B #0x1, &0x29
  801. //  331                 FLASH_CON_PORT_OUT&= ~CLE;
  802. BIC.B #0x4, &0x29
  803. //  332 }
  804. RET
  805.         CFI EndBlock cfiBlock8
  806. //  333 //********************************************************
  807. //  334 
  808.         RSEG CODE:CODE:SORT:NOROOT(1)
  809. //  335 void ADDRESS_LATCH_INTO(void)
  810. ADDRESS_LATCH_INTO:
  811.         CFI Block cfiBlock9 Using cfiCommon0
  812.         CFI Function ADDRESS_LATCH_INTO
  813. //  336 {
  814. //  337  FLASH_CON_PORT_OUT |= ALE;
  815. BIS.B #0x2, &0x29
  816. //  338  FLASH_CON_PORT_OUT &=~ (CLE|WE);
  817. AND.B #0xfa, &0x29
  818. //  339  DATA_PORT_OUT_INITIAL; //MCU OUTPUT,FLASH READ ADDRESS
  819. MOV.B #0xff, &0x32
  820. //  340  DATA_PORT_OUT=ADDRESS_VALUE;
  821. MOV.B &ADDRESS_VALUE, &0x31
  822. //  341 
  823. //  342  FLASH_CON_PORT_OUT |= WE; //LATCH INTO THE ADDRESS
  824. BIS.B #0x1, &0x29
  825. //  343  //FLASH_CON_PORT_OUT &=~ ALE;
  826. //  344 
  827. //  345 }
  828. RET
  829.         CFI EndBlock cfiBlock9
  830. //  346 /********************************************************
  831. //  347 void WRITE_ONE_DATA(void)
  832. //  348 {
  833. //  349  FLASH_CON_PORT_OUT&=~WE;
  834. //  350  //DATA_PORT_OUT_INITIAL; //MCU OUTPUT,MCU WRITE A DATA TO FLASH
  835. //  351  DATA_PORT_OUT=FLASH_WRITE_DATA;
  836. //  352  FLASH_CON_PORT_OUT |= WE; //LATCH INTO ONE DATA
  837. //  353 
  838. //  354 }
  839. //  355 
  840. //  356 ********************************************************/
  841.         RSEG CODE:CODE:SORT:NOROOT(1)
  842. //  357 void READ_ONE_DATA(void)
  843. READ_ONE_DATA:
  844.         CFI Block cfiBlock10 Using cfiCommon0
  845.         CFI Function READ_ONE_DATA
  846. //  358 {
  847. //  359  FLASH_CON_PORT_OUT &=~ RE; //RE IS LOW,ENABLE READ DATA
  848. BIC.B #0x10, &0x29
  849. //  360 
  850. //  361  //DATA_PORT_IN_INITIAL; //MCU INPUT,MCU READ A DATA
  851. //  362  FLASH_READ_DATA=DATA_PORT_IN;
  852. MOV.B &0x30, &FLASH_READ_DATA
  853. //  363  FLASH_CON_PORT_OUT |= RE;
  854. BIS.B #0x10, &0x29
  855. //  364 }
  856. RET
  857.         CFI EndBlock cfiBlock10
  858.         RSEG CODE:CODE:NOROOT(1)
  859. ?setjmp_save_r4:
  860. REQUIRE ?setjmp_r4
  861. REQUIRE ?longjmp_r4
  862.         RSEG CODE:CODE:NOROOT(1)
  863. ?setjmp_save_r5:
  864. REQUIRE ?setjmp_r5
  865. REQUIRE ?longjmp_r5
  866.         END
  867. // 
  868. // 692 bytes in segment CODE
  869. //   5 bytes in segment DATA16_AN
  870. // 
  871. // 692 bytes of CODE memory
  872. //   0 bytes of DATA memory (+ 5 bytes shared)
  873. //
  874. //Errors: none
  875. //Warnings: none