serial_software

Software RS232 library

Author Stef Mientki, Copyright © 2002..2006, all rights reserved.
Adapted-by Sebastien Lelong, Albert Faber, Joep Suijs (on behalf of Tijs van Roon),
Compiler 2.4o

Description

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()


Dependencies

No dependency found



Summary

Global variables/contants

Procedures

Functions


API details

Global variables/contants

Procedures

  • 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.
    

Functions

  • 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.
    


Related samples

Here are the list of samples which use this library:

12f61512f615_print_large_number2.jal
16f7316f73_serial_software.jal
16f7316f73_serial_sw_echo.jal
16f87716f877_serial_sw_echo.jal
16f87716f877_serial_software.jal
16f877a16f877a_serial_sw_echo.jal
16f877a16f877a_serial_software.jal
16f8816f88_serial_software.jal
16f8816f88_serial_sw_echo.jal
18f45218f452_serial_software.jal
18f45218f452_serial_sw_echo.jal
18f455018f4550_serial_software.jal
18f455018f4550_serial_sw_echo.jal
18f455018f4550_fat32_small_sd_card.jal
18f455018f4550_fat32_sd_card.jal
18f455018f4550_23k256.jal
18f455018f4550_sd_card.jal
18f462018f4620_network_webserver_enc28j60.jal
18f462018f4620_network_udp_client.jal
18f462018f4620_serial_software.jal
18f462018f4620_network_tcp_client.jal
18f462018f4620_network_ping.jal
18f462018f4620_network_slip_isr_ping_udp.jal
18f462018f4620_network_tcp_server.jal
18f462018f4620_network_udp_server.jal
18f462018f4620_network_all_in_one.jal
18f462018f4620_serial_sw_echo.jal
18f67j5018f67j50_serial_software.jal
18f67j5018f67j50_serial_sw_echo.jal