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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
01/30/12 22:20
Read: times


 
#185737 - Design your subroutine(s)
Responding to: ???'s previous message
First off, you write a 'putchar' subroutine that takes a value in ACC and xmits through the UART.
Then you either:

    mov A,#0x7E
    call putchar
    mov A,#0x01
    call putchar
    ...

 


Or you write another function that will xmit N bytes starting at address in DPTR.
e.g. using your putchar subroutine.
    ...
    mov DPTR,#address    ;where your bytes live
    mov R0,#7            ;how many bytes
    call putblock
    ...
putblock:                
    ...                  ;call putchar for each byte
    ret

 


You should see many examples of this sort of subroutine. Of course you can pass your parameters in different ways. Does not have to be DPTR, ACC, R0.

Remember to test for the TX buffer being empty before you can write a byte to the UART.

Andy asked "Why ASM?"
Learning how to do this in C would mean you could do something similar with and type of chip. The 'design' process is the same.

David.

List of 17 messages in thread
TopicAuthorDate
Help. Writing Hex code from serial port to External device            01/01/70 00:00      
   Look at this            01/01/70 00:00      
      Using 8051            01/01/70 00:00      
   Why ASM?            01/01/70 00:00      
      Design your subroutine(s)            01/01/70 00:00      
   RI Flag            01/01/70 00:00      
      READ_SERIAL            01/01/70 00:00      
         RI setup            01/01/70 00:00      
            are you sure?            01/01/70 00:00      
               CKCON            01/01/70 00:00      
                  well, then            01/01/70 00:00      
                     Correct            01/01/70 00:00      
                        RI and TI            01/01/70 00:00      
                           Ok            01/01/70 00:00      
                              Diff Of TI and RI            01/01/70 00:00      
                                 Uart stall            01/01/70 00:00      
                        Oscilloscope            01/01/70 00:00      

Back to Subject List