| Author | Stef Mientki, Copyright © 2002..2020, all rights reserved. |
| Adapted-by | Sebastien Lelong, Albert Faber, Joep Suijs (on behalf of Tijs van Roon), |
| Compiler | 2.5r4 |
Software RS232 library
Library supports software RS232 send and receive procedure on any IO-pin.
Both the inverted and non-inverted routines are available,
so it should fit any hardware.
Baudrate can be set between 110 and 230_400 (for 20 Mhz Xtal),
for lower Xtal frequencies the maximum baudrate will be equally lower.
Baudrates are optimized, so even the high baudrates shouldn't be a problem
(my [Stef] standard = 115_200 Baud, which has never given me any problems).
Interrupts are disabled during transmissions.
Default parameters are 8 databits, 2 stopbits, no parity, no handshake.
.
To use this serial_software library in a user program:
.
1. The following aliases must be defined:
serial_sw_tx_pin is pin_xy (any output pin)
serial_sw_rx_pin is pin_xy (any input pin)
.
2. the following constants must be defined by the user program:
serial_sw_baudrate = 110 .. 240_000
.
3. The following constants may [optionally] be defined by the user program:
serial_sw_invert = FALSE | TRUE (default: TRUE)
serial_sw_databits = 5 .. 8 (default: 8)
serial_sw_stopbits = 1 | 2 (default: 2)
.
4. Include serial_software
.
5. Set the selected serial_sw_tx_pin for output and
set the serial_sw_rx_pin for input.
.
6. serial_sw_init()
No dependency found
const serial_sw_bit_time = (1_000_000/serial_sw_baudrate) - ((13 * serial_sw_instruction_time) / 100)
const serial_sw_instruction_time = 400_000_000 / target_clock
serial_sw_data'put(byte in data)
serial_sw_write(byte in data)
serial_sw_init()
serial_sw_read_wait(byte out data)
const serial_sw_bit_time = (1_000_000/serial_sw_baudrate) - ((13 * serial_sw_instruction_time) / 100)
No documentation found
const serial_sw_instruction_time = 400_000_000 / target_clock
calculate instruction execution time in 10ns units
serial_sw_data'put(byte in data)
Here the serial_sw_write procedure is declared as a pseudo variable
so you can use it in the following way:
{{{
serial_sw_write = 0x33
}}}
serial_sw_write(byte in data)
Transmit a character. Interrupts will be disabled during this routine, but restored afterwards. Also here the code is doubled (inverting and non-inverting) and selection is done by a compiler-directive.
serial_sw_init()
Initialize the library The only action needed is to set the transmit pin high or low, (depending on serial_sw_invert definition).
serial_sw_read_wait(byte out data)
Wait until a character is received. Interrupts will be disabled during this routine, but restored afterwards. Also here the code is doubled (inverting and non-inverting) and selection is done by a compiler-directive.
serial_sw_data'get() return byte
Here the serial_sw_read_wait procedure is declared as a pseudo variable
so you can use it in the following way
{{{
Data = serial_sw_write
}}}
serial_sw_read(byte out data) return bit
Wait until a character is received or time out is reached. Interrupts will be disabled during this routine, but restored afterwards. Also here the code is doubled (inverting and non-inverting) and selection is done by a compiler-directive.