Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mov r1, #001 ; send 1
- call serial_send
- ; 9600 in PAL: (2.5us per cycle)
- ; 1 bit = 104.2 usec = 42 clocks
- ; 1.5 bits = 156.3 usec = 63 clocks
- serial_send
- mov r1, #08h ; eight bits
- send_startbit
- orl P1,#00000001b ; output 1
- mov r2,#a0 ; cycles to wait (x2)
- wait_start
- djnz r2,wait_start ; decrement jump not zero
- nextbit
- mov r2,#50 ; cycles to wait (x2)
- rrc a ; rotate into carry
- jc send_1 ; jump carry
- send_0
- anl P1,#11111110b ; output 0
- jmp wait96
- send_1
- orl P1,#00000001b ; output 1
- nop
- wait96
- djnz r2,wait96
- djnz r0,nextbit
- send_end
- anl P1,#11111110b
- ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement