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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
12/10/03 09:39
Read: times


 
#60286 - RE: how many second ??
Responding to: ???'s previous message
giri anto:
In your program, the use of the SP as a pointer into memory to fill in data into a sequence of RAM is a rather unconventional scheme. Some people will argue that this is an illegal way to use the stack. Now while this is not strictly true it is a far better technique to use a MOV @Rx, A type instruction for the movement of data into a buffer. Under normal design circumstances the stack via SP should be used for temporary storage only wherein whatever gets pushed gets soon popped back off the stack.

In your program youe code appears to have several problems. One of them is that each time you do the PUSH ACC the SP is INCREMENTED so your data gathering loop would be filling in the RAM with data starting at 020H and going up past 07FH. It will also try to continue to put data into the RAM at addresses in sequence from 080H through 0FFH, but depending on whether your microcontroller has 128 byte RAM or 256 byte RAM these will either be storing the data correctly OR the pushes into this area may be sending data into the atmosphere someplace. The code would continue then to push into address 000H and 001H and 002H and in the process destroy the contents of registers R0, R1, R2 and so on. Since your program loops use register R2, the next loop will destroy the data that was placed at address 002H. (Note that R2 == memory at 0002H).

There is another problem within your inner loop where you are trying to accumulate 8 bits together. You repeatedly move data into the B register in the CON_IN: loop. Maybe this code really wants to look more like below purging the use of the B register all together:

START_IN : 
     CLR    A
     MOV    R2, #08H
CON_IN: 
     MOV    C, P0.0 
     RLC    A
     DJNZ   R2, CON_IN 

There is another scheme for doing this that can even eliminate the use of the R2 register as a bit counter. The A register is initialized to 001H and then each shift left of A can have a check of the C flag to see when the loop has been done 8 times. That simplified code could look like:

START_IN : 
     MOV    A, #001H
CON_IN: 
     MOV    C, P0.0 
     RLC    A
     JNC    CON_IN 


Michael Karas



List of 15 messages in thread
TopicAuthorDate
how many second ??            01/01/70 00:00      
   RE: how many second ??            01/01/70 00:00      
      RE: how many second ??            01/01/70 00:00      
         RE: how many second ??            01/01/70 00:00      
         RE: how many second ??            01/01/70 00:00      
            RE: how many second ??            01/01/70 00:00      
               RE: how many second ??            01/01/70 00:00      
                  RE: how many second ??            01/01/70 00:00      
                  RE: how many second ??            01/01/70 00:00      
                     RE: how many second ??            01/01/70 00:00      
                     RE: how many second ??            01/01/70 00:00      
   RE: how many second ??            01/01/70 00:00      
      RE: how many second ??            01/01/70 00:00      
         RE: how many second ??            01/01/70 00:00      
   RE: how many second ??            01/01/70 00:00      

Back to Subject List