;======================================================================= ;Assembly Language Tutorial for the SX Microcontroller ;Program 15.1 ;SSIB - by Al Williams, AWC http://www.al-williams.com/awce ;v2.0 ;======================================================================= device sx28l,oschs3 device turbo,stackx,optionx IRC_CAL IRC_SLOW reset start_point freq 10000000 ; Port Assignment: Bit variables ; int_period EQU 130 XBAUDRATE EQU 19200 ; baud rate to stamp BAUDRATE_A EQU 9600 ; Channel A baudrate BAUDRATE_B EQU 9600 ; Channel B baudrate ; Non inverted modes are best because ; the internal pull up resistors will stop all devices ; from talking, setting any of the below to 1 ; makes the handshaking reverse which means ; devices are free to send until the SSIB and/or ; Stamp wakes up which may cause you problems INVSEND EQU 0 ; inverted/true to Stamp INVRCVA EQU 0 ; inverted/true to Chan A INVRCVB EQU 0 ; inverted/true to Chan B BUFFERLIM EQU 2 ; space free in buffer before h/s off rx_pin EQU rb.2 ;UART receive input rx_pin1 EQU rb.0 tx_pin EQU ra.3 ;UART transmit output enablepin equ ra.0 enablepin1 equ ra.1 rxen_pin equ rb.1 ; handshake for buffer A rxen_pin1 equ rb.3 ; handshake for buffer B ; org 8 head ds 1 head1 ds 1 tail ds 1 tail1 ds 1 byte ds 1 tmpvar ds 1 flags DS 1 ;program flags register spare7 EQU flags.7 rx_flag1 EQU flags.6 rx_flag EQU flags.5 ;signals when byte is received spare4 EQU flags.4 spare3 EQU flags.3 spare2 EQU flags.2 spare1 EQU flags.1 spare0 EQU flags.0 watch byte,8,uhex watch head,8,uhex watch tail,8,uhex watch rx_flag,1,uhex org 10h ;bank3 variables serial = $ ;UART bank ; tx_high ds 1 ;hi byte to transmit tx_low ds 1 ;low byte to transmit tx_count ds 1 ;number of bits sent tx_divide ds 1 ;xmit timing (/16) counter rx_count ds 1 ;number of bits received rx_divide ds 1 ;receive timing counter rx_byte ds 1 ;buffer for incoming byte rx_count1 ds 1 rx_divide1 ds 1 rx_byte1 ds 1 ; baud rate bit # baud2400 = 5 baud9600 = 3 baud19200 = 2 ; above 19.2K may not be reliable ; without adjusting int speed (see text) IF XBAUDRATE=2400 baud_bit = baud2400 ;for 2400 baud start_delay = (1<