First Serial Communication Program! :D
tholberton
Posts: 41
I just finished writing this program in asm for talking to a computer with standard serial board settings - 9600,1n8.
I was pretty excited when I finally saw "1"'s come pouring out of the serial port haha
Any suggestions or comments are welcome
I was pretty excited when I finally saw "1"'s come pouring out of the serial port haha
org 0 serial_interface mov dira,tx mov n_data_bits,#8 waitpeq inp,inp 'wait until send button is pressed mov outa,tx 'send start bit mov time_t,cnt add time_t,delay_t waitcnt time_t,delay_t :main_loop 'send data ror data_t,#1 wc muxc outa,tx waitcnt time_t,delay_t djnz n_data_bits,#:main_loop wz or outa,tx 'send stop bit waitcnt time_t,delay_t xor outa,tx waitcnt time_t,delay_t mov n_data_bits,#8 'restart counter and start again jmp #:main_loop data_t long $0000_0031 inp long $0001_0000 tx long $4000_0000 rx long $8000_0000 delay_t long 8333 n_data_bits res 1 time_t res 1 fit
Any suggestions or comments are welcome
Comments
This may help for a reference:
http://en.wikipedia.org/wiki/File:Rs232_oscilloscope_trace.svg
Try something like this...
I'm aware of the 3 empty bytes. I'm planning on revising this for receiving data from a device.
I think when the desired result is a low bit and not just a change of a bit's state, it makes more sense to use "andn" since it doesn't require the bit start high to end up low.