MOD-RS485-ISO firmware for PIC16LF18324
---------------------------------------

1. Description

MOD-RS485-ISO is an isolated RS485/RS422 interface board based on the
TI ISO35T/ISO35TDW transceiver and a PIC16LF18324 controller. The board is
connected to host boards through UEXT. The PIC provides an I2C control
interface while the UART data path can be used as a transparent RS485 port.

Firmware 0x06 keeps the compatible register map but changes the default pass
mode behavior so the board works like a normal 2-wire half-duplex RS485 adapter
for Modbus RTU and similar libraries.

2. Ready-to-flash HEX

The current experimental ready-to-flash HEX is placed in this folder:

MOD-RS485-ISO_PIC16LF18324_FW0x06_BUILD0x02_XC8-3.10.hex

When firmware changes are made, rebuild the MPLAB X project and copy the final
HEX to the top level of this MOD-RS485_FIRMWARE_V6 folder with the firmware
revision and build in the file name. This avoids users accidentally flashing
an obsolete HEX from another folder.

3. Toolchain

Recommended build tools:

* MPLAB X IDE 6.20 or newer
* MPLAB XC8 compiler 3.10 or newer
* Microchip PIC16F1xxxx_DFP 1.24.387 or newer

Command-line XC8 3.x builds require a DFP path. Example:

xc8-cc -mcpu=PIC16LF18324 -mdfp=<path-to-PIC16F1xxxx_DFP>/xc8 ...

The legacy source was built with XC8 1.x. This revision is written and checked
with XC8 3.10.

4. Modes

The device has two modes of operation:

* Pass mode, register 0x23 = 0x00

  This is the default mode. UEXT TXD is passed through the PIC CLC hardware to
  ISO35 D, and ISO35 R is passed back to UEXT RXD. The PIC also controls ISO35
  DE automatically. In build 0x02, TX edges are detected by CLC1 interrupt,
  firmware raises DE on RC3, and Timer0 releases DE after the configured idle
  timeout.

  The baudrate register is used only for DE timing in pass mode. Data is still
  passed by CLC hardware, not buffered by firmware.

* Bridge mode, register 0x23 = 0x01

  The host sends and receives RS485 data over I2C FIFOs. This mode is kept for
  compatibility and low-rate control use, but pass mode is recommended for
  Modbus RTU and other normal UART libraries.

Changing mode is saved to EEPROM and applied after a watchdog reset because the
PIC uses one-way PPS locking.

5. Default settings

address:  0x22
mode:     0x00, pass mode
control:  0x03, RX enabled + TX enabled with automatic DE timing
baudrate: 0x0C, 9600 bps timing profile

Close PROG during reset to restore these defaults.

6. Control register, address 0x24

bit0 RX_ENABLE
  1 enables the ISO35 receiver path from RS485 to host.

bit1 TX_ENABLE
  1 enables the host-to-RS485 transmit path.

bit2 TX_FORCE
  1 forces ISO35 DE high whenever TX_ENABLE is also set. This restores the old
  always-transmitting behavior and is intended for RS422/full-duplex style use.
  Leave this bit clear for 2-wire half-duplex RS485.

Default control is 0x03. In firmware 0x06 that means automatic direction, not
forced DE.

Control changes are volatile by default and are not written to EEPROM on every
I2C write. To persist the current control register, write 0xA5 to register
0x2B.

7. Supported baudrate timing profiles

The old enum values are retained, but firmware 0x06 accepts only common
RS485/Modbus rates:

0x05 - 300 bps
0x06 - 600 bps
0x07 - 1200 bps
0x09 - 2400 bps
0x0A - 4800 bps
0x0C - 9600 bps
0x0D - 14400 bps
0x0E - 19200 bps
0x0F - 38400 bps
0x10 - 57600 bps
0x12 - 115200 bps

Unsupported baud writes are ignored and STATUS_UNSUPPORTED_BR is set until a
valid baudrate is written.

8. Registers

0x20 Device ID, read-only, 0x25
0x21 Firmware, read-only, 0x06
0x22 I2C address, writable when PROG is closed
0x23 Mode, 0x00 pass or 0x01 bridge
0x24 Control bitfield
0x25 Baudrate timing profile
0x26 TX FIFO, bridge mode
0x27 RX FIFO, bridge mode
0x28 RX FIFO byte count, extension register
0x29 TX FIFO free space, extension register
0x2A Status bitfield, extension register
0x2B Save command, write 0xA5 to persist current control
0x2C Firmware build marker, firmware 0x06+, read-only

The original 0x20 through 0x27 registers remain compatible with previous
firmware releases.

9. Status register, address 0x2A

bit0 RX_AVAILABLE
bit1 TX_SPACE
bit2 DRIVER_ENABLED
bit3 PASS_MODE
bit4 UNSUPPORTED_BR

10. Hardware test checklist

Recommended first tests on the bench:

* Restore defaults with PROG closed during reset.
* With A-Y and B-Z jumpers closed, send a 9600 bps byte on UEXT TXD.
* Check that ISO35 DE rises when transmission starts and releases before the
  Modbus 3.5-character response window.
* At idle, status register 0x2A should normally read 0x0A. Status 0x0E means
  DE is still enabled while idle and two boards can corrupt the bus.
* Do not paste long text from both terminals at the same time when testing
  2-wire half-duplex mode. Both drivers will transmit together and the RS485
  bus will collide. A protocol such as Modbus RTU must provide turn-taking.
* Terminal newline behavior is application-specific. PuTTY, Arduino Serial
  Monitor, and other serial terminals can send or display CR and LF
  differently. The firmware does not translate line endings; transparent mode
  passes 0x0D, 0x0A, and all other bytes unchanged.
* In the Arduino examples, the PC terminal baud is separate from the RS485 bus
  baud. Keep PuTTY/Arduino Serial Monitor at the sketch's USB serial baud
  and change the sketch's RS485 UART baud/profile on all boards to test
  another bus rate.
* The main Arduino examples are named Transparent, ModbusMaster,
  ModbusSlave, and FullDuplex. They default to Olimex ESP32-PoE-ISO pins, but
  the configuration block at the top of each sketch can be changed for other
  Arduino-compatible host boards. Boards with Serial1 can use the board's
  hardware UART; boards such as Olimexino-328 can use SoftwareSerial if the
  selected pins are wired to the MOD-RS485-ISO UART.
* The ModbusMaster Arduino example requires the Arduino ModbusMaster library.
  Install it from Arduino IDE Library Manager before compiling that example.
* For the included Modbus test, program one host board with the ModbusMaster
  example and the other with the ModbusSlave example. Do not run two masters.
  The examples force the PIC-controlled DE signal before each complete Modbus
  frame, wait for the PIC status bit to confirm DE, release it after the host
  UART flush, and drain possible local echo before releasing the bus.
* Confirm UEXT RXD follows ISO35 R when RX_ENABLE is set.
* For full-duplex/RS422-style testing, run the FullDuplex Arduino example,
  leave Z-B and Y-A open, use two differential pairs, and confirm control 0x07
  forces DE high.
* Test pass-mode Modbus at 9600, 19200, 38400, 57600, and 115200 bps.

11. Release history

This publication folder contains only the current experimental firmware:

18 JUN 2026 - firmware 0x06 build 0x02 uses firmware-controlled DE on RC3,
              keeps the compatible command/register interface, and was rebuilt
              with MPLAB X 6.20 and XC8 3.10 for publication.

12. Support

https://www.olimex.com/
support@olimex.com
