Advertisement
Guest User

Untitled

a guest
Apr 3rd, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     mov r1, #001        ; send 1
  2.     call serial_send
  3.  
  4. ; 9600 in PAL: (2.5us per cycle)
  5. ; 1 bit = 104.2 usec = 42 clocks
  6. ; 1.5 bits = 156.3 usec = 63 clocks
  7. serial_send
  8.     mov r1, #08h        ; eight bits
  9. send_startbit
  10.     orl P1,#00000001b   ; output 1
  11.     mov r2,#a0      ; cycles to wait (x2)
  12. wait_start
  13.     djnz    r2,wait_start   ; decrement jump not zero
  14. nextbit
  15.     mov r2,#50      ; cycles to wait (x2)
  16.     rrc a       ; rotate into carry
  17.     jc  send_1      ; jump carry
  18. send_0
  19.     anl P1,#11111110b   ; output 0
  20.     jmp wait96
  21. send_1
  22.     orl P1,#00000001b   ; output 1
  23.     nop
  24. wait96
  25.     djnz    r2,wait96
  26.     djnz    r0,nextbit
  27. send_end
  28.     anl P1,#11111110b
  29.     ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement