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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
David Prentice
01/30/12 15:20
Read: 598 times
Wormshill
England


 
#185737 - Design your subroutine(s)
Responding to: Andy Neil'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      Dave McNamara      01/27/12 15:42      
   Look at this      Michael Karas      01/27/12 18:46      
      Using 8051      Dave McNamara      01/28/12 03:19      
   Why ASM?      Andy Neil      01/30/12 14:43      
      Design your subroutine(s)      David Prentice      01/30/12 15:20      
   RI Flag      Dave McNamara      02/20/12 08:48      
      READ_SERIAL      Michael Karas      02/20/12 09:25      
         RI setup      Dave McNamara      02/20/12 09:57      
            are you sure?      Erik Malund      02/20/12 10:04      
               CKCON      Dave McNamara      02/20/12 10:22      
                  well, then      Erik Malund      02/20/12 11:17      
                     Correct      Dave McNamara      02/20/12 12:11      
                        RI and TI      Erik Malund      02/20/12 12:24      
                           Ok      Dave McNamara      02/20/12 12:32      
                              Diff Of TI and RI      Michael Karas      02/20/12 12:57      
                                 Uart stall      Maarten Brock      02/22/12 07:01      
                        Oscilloscope      Per Westermark      02/20/12 17:04      

Back to Subject List