Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
04/17/08 12:51
Modified:
  04/17/08 13:05

Read: times


 
#153606 - Re: this is why it\'s always better
Responding to: ???'s previous message
Here under is my test programm to test the erase block function.
It begin with a baudrate detect. After the 'U' char is reiceived, block 0 is erased and then a 'm' is sent back to RS232.
When the flash is not blank and SP has 4Eh, the erase function won't return. But when initialising SP to 20h, all is working.
The erase function also return if the flash is allready erased.

SP is set to 4Eh, because 31 variables are declared from RAM address 30h. The complier (Keil) was calculating it.
I've included the asm code generated by compiler since C and asm are mixed.


    80: ?C_STARTUP:     LJMP STARTUP1 
C:0x0000    020007   LJMP     STARTUP1(C:0007)
    20:           JMP   0x7000 
    21: ; #pragma endasm 
    22: ;  
    23: ; } 
    24:                         ; SOURCE LINE # 7 
C:0x0003    027000   LJMP     BOOT(C:7000)
    25:         RET      
C:0x0006    22       RET      
   139:                 MOV     SP,#?STACK-1 
C:0x0007    75814E   MOV      SP(0x81),#0x4E
   140:                 LJMP    ?C_START 
C:0x000A    02000D   LJMP     main(C:000D)
     5: main() 
C:0x000D    80F4     SJMP     asmBoot(C:0003)


   120:         ORL     AUXR1,#ENBOOT        ; enable boot 
   121:  
   122:  
   123: ; Détecte et configure le baudrate 
   124: ; La mesure utilise T2 qui à une horloge de fosc/2 
   125: Detect: 
C:0x7000    43A220   ORL      AUXR1(0xA2),#0x20
   126:         MOV      TMOD,#0x02 
C:0x7003    758902   MOV      TMOD(0x89),#0x02
   127:         MOV      T2CON,#0x30 
C:0x7006    75C830   MOV      T2CON(0xC8),#0x30
   128:         CLR      A 
C:0x7009    E4       CLR      A
   129:         MOV      TH2,A 
C:0x700A    F5CD     MOV      TH2(0xCD),A
   130:         MOV      TL2,A 
C:0x700C    F5CC     MOV      TL2(0xCC),A
   131:         JNB      RXD,$ 
C:0x700E    30B0FD   JNB      RXD(0xB0.0),C:700E
   132:         JB       RXD,$ 
C:0x7011    20B0FD   JB       RXD(0xB0.0),C:7011
   133:         SETB     TR2 
C:0x7014    D2CA     SETB     TR2(0xC8.2)
   134:         JNB      RXD,$ 
C:0x7016    30B0FD   JNB      RXD(0xB0.0),C:7016
   135:         CLR      TR2 
   136: ; Charge le Timer avec 65536 - tm/16 
C:0x7019    C2CA     CLR      TR2(0xC8.2)
   137:         MOV      A,TL2 
C:0x701B    E5CC     MOV      A,TL2(0xCC)
   138:         SWAP     A 
   139:         ; Arrondi au demi; le carry contient l'incrément si un arrondi supérieur est nécessaire 
C:0x701D    C4       SWAP     A
   140:         RLC      A      ; Mémorise l'arrondi 
C:0x701E    33       RLC      A
   141:         RR       A 
C:0x701F    03       RR       A
   142:         ANL      A,#0x0F 
C:0x7020    540F     ANL      A,#0x0F
   143:         MOV      R0,A 
C:0x7022    F8       MOV      R0,A
   144:         MOV      A,TH2 
C:0x7023    E5CD     MOV      A,TH2(0xCD)
   145:         SWAP     A 
C:0x7025    C4       SWAP     A
   146:         ANL      A,#0xF0 
C:0x7026    54F0     ANL      A,#B(0xF0)
   147:         ORL      A,R0 
C:0x7028    48       ORL      A,R0
   148:         ADDC     A,#0   ; Ajoute le carry 
C:0x7029    3400     ADDC     A,#0x00
   149:         MOV      R0,A 
C:0x702B    F8       MOV      R0,A
   150:         MOV      A,TH2 
C:0x702C    E5CD     MOV      A,TH2(0xCD)
   151:         SWAP     A 
C:0x702E    C4       SWAP     A
   152:         ANL      A,#0x0F 
C:0x702F    540F     ANL      A,#0x0F
   153:         ADDC     A,#0   ; Ajoute le report de l'addition précédente 
C:0x7031    3400     ADDC     A,#0x00
   154:         MOV      R1,A 
   155:         ; compl. à 2 
C:0x7033    F9       MOV      R1,A
   156:         CLR      C 
C:0x7034    C3       CLR      C
   157:         CLR      A 
C:0x7035    E4       CLR      A
   158:         SUBB     A,R0 
C:0x7036    98       SUBB     A,R0
   159:         MOV      TL2,A 
C:0x7037    F5CC     MOV      TL2(0xCC),A
   160:         MOV      RCAP2L,A 
C:0x7039    F5CA     MOV      RCAP2L(0xCA),A
   161:         CLR      A 
C:0x703B    E4       CLR      A
   162:         SUBB     A,R1 
C:0x703C    99       SUBB     A,R1
   163:         MOV      TH2,A 
C:0x703D    F5CD     MOV      TH2(0xCD),A
   164:         MOV      RCAP2H,A 
C:0x703F    F5CB     MOV      RCAP2H(0xCB),A
   165:         SETB     TR2 
C:0x7041    D2CA     SETB     TR2(0xC8.2)
   166:         MOV      SCON,#0x52      
   167:  
   168: Wait_Uchar: 
   169: ; Attend le 1er caractère 
C:0x7043    759852   MOV      SCON(0x98),#0x52
   170:         JNB      RI,$ 
C:0x7046    3098FD   JNB      RI(0x98.0),WAIT_UCHAR(C:7046)
   171:         CLR      RI 
C:0x7049    C298     CLR      RI(0x98.0)
   172:         MOV      A,SBUF 
   173:         ; Dans la valeur recue, les 2 LSB n'on pas été pris car on les a déjà utilisé pour la detection du baudrate 
C:0x704B    E599     MOV      A,SBUF(0x99)
   174:         CLR      C 
C:0x704D    C3       CLR      C
   175:         RLC      A 
C:0x704E    33       RLC      A
   176:         SETB     C 
C:0x704F    D3       SETB     C
   177:         RLC      A 
   178: ; Renvoie le caractère 
C:0x7050    33       RLC      A
   179:         JNB      TI,$ 
C:0x7051    3099FD   JNB      TI(0x98.1),C:7051
   180:         CLR      TI 
C:0x7054    C299     CLR      TI(0x98.1)
   181:         MOV      SBUF,A 
   182:  
   183: ; Check to see if uppercase "U" 
C:0x7056    F599     MOV      SBUF(0x99),A
   184:         CJNE     A,#'U',Not_U1  ; Check to see if uppercase "U" 
C:0x7058    B45502   CJNE     A,#0x55,NOT_U1(C:705D)
   185:         JMP      Intel_Hex 
   186: Not_U1: 
   187: ; On teste encore un caractère car avec des débits élevés, on manque partiellement le premier 
C:0x705B    801A     SJMP     INTEL_HEX(C:7077)
   188:         JNB      RI,$ 
C:0x705D    3098FD   JNB      RI(0x98.0),NOT_U1(C:705D)
   189:         CLR      RI 
C:0x7060    C298     CLR      RI(0x98.0)
   190:         MOV      A,SBUF 
   191: ; Renvoie le caractère 
C:0x7062    E599     MOV      A,SBUF(0x99)
   192:         JNB      TI,$ 
C:0x7064    3099FD   JNB      TI(0x98.1),C:7064
   193:         CLR      TI 
C:0x7067    C299     CLR      TI(0x98.1)
   194:         MOV      SBUF,A 
C:0x7069    F599     MOV      SBUF(0x99),A
   195:         CJNE     A,#'U',Not_U   ; Check to see if uppercase "U" 
C:0x706B    B45502   CJNE     A,#0x55,NOT_U(C:7070)
   196:         JMP      Intel_Hex 
   197: Not_U: 
   198: ; Dans ce cas on recommence la détection 
C:0x706E    8007     SJMP     INTEL_HEX(C:7077)
   199:         MOV      SCON,#0 
C:0x7070    759800   MOV      SCON(0x98),#0x00
   200:         CLR      TR2 
C:0x7073    C2CA     CLR      TR2(0xC8.2)
   201:         JMP      Detect 
   202:  
   203:  
   204: ;***** Intel Hex File Load routine ***** 
   205: ;This routine loads an Intel Hex formatted file into  
   206: ;the buffer memory. The hex file is received as a series 
   207: ;of ASCII characters on the serial input line of the 
   208: ;serial port. A record type of 00H is considered to be 
   209: ;a data field. Any other type of record is considered 
   210: ;to be an End-of-File marker. This routine also calculates 
   211: ;the checksum on the field as it is received and compares 
   212: ;this calculated checksum with the checksum field received 
   213: ;in the record. 
   214: Intel_Hex: 
C:0x7075    808C     SJMP     DETECT(C:7003)
   215: ORL AUXR1,#20h  ; ENBOOT bit determines whether the BOOTROM is enabled 
C:0x7077    43A220   ORL      AUXR1(0xA2),#0x20
   216: MOV R0,#11      ; R0 = osc freq (integer) 
C:0x707A    780B     MOV      R0,#0x0B
   217: MOV R1,#01h 
C:0x707C    7901     MOV      R1,#0x01
   218: MOV DPH,#0      ;block code, block 0, 0k to 8k, 00H 
C:0x707E    758300   MOV      DPH(0x83),#0x00
   219: MOV DPL,#0 
C:0x7081    758200   MOV      DPL(0x82),#0x00
   220: LCALL 0FFF0h 
   221:  
C:0x7084    12FFF0   LCALL    C:FFF0
   222: MOV A,#'m' 
C:0x7087    746D     MOV      A,#0x6D
   223: call CO 
C:0x7089    118D     ACALL    CO(C:708D)
   224: jmp $ 
   225:  
   226:  
   227: ;***** console output routine ***** 
   228: ;Outputs character in the ACC to  
   229: ;the serial output line. 
   230: CO: 
C:0x708B    80FE     SJMP     C:708B
   231:         JNB      TI,$ 
C:0x708D    3099FD   JNB      TI(0x98.1),CO(C:708D)
   232:         CLR      TI 
C:0x7090    C299     CLR      TI(0x98.1)
   233:         MOV      SBUF,A 
C:0x7092    F599     MOV      SBUF(0x99),A
   234:         RET 
   235:  
   236: ;***** console input routine ***** 
   237: ;Waits until character has been received 
   238: ;and then returns char in ACC. 
   239: CI: 
C:0x7094    22       RET      
   240:         JNB      RI,$ 
C:0x7095    3098FD   JNB      RI(0x98.0),CI(C:7095)
   241:         CLR      RI 
C:0x7098    C298     CLR      RI(0x98.0)
   242:         MOV      A,SBUF 
C:0x709A    E599     MOV      A,SBUF(0x99)
   243:         RET 
C:0x709C    22       RET      




List of 15 messages in thread
TopicAuthorDate
IAP for P89C51RC2FA            01/01/70 00:00      
   Do you have disabled interrupts?            01/01/70 00:00      
      Re: Do you have disabled interrupts?            01/01/70 00:00      
   can you live with 'programming' as is and REprogra            01/01/70 00:00      
   IAP for P89C51RC2FA            01/01/70 00:00      
      constant?            01/01/70 00:00      
         Re: constant?            01/01/70 00:00      
            this is why it's always better...            01/01/70 00:00      
               Re: this is why it\'s always better            01/01/70 00:00      
                  Hummm....            01/01/70 00:00      
                     RE: quick erase            01/01/70 00:00      
                        can you please try an experiment            01/01/70 00:00      
                           Re: can you please try an experiment            01/01/70 00:00      
            what exactly are the symptoms?            01/01/70 00:00      
               Re: what exactly are the symptoms?            01/01/70 00:00      

Back to Subject List