Open TG9541 opened 3 years ago
This works with the latest deferred BUSCTRL
:
\ STM8EF-MODBUS eForth RS485 bus control for RS485 board RelayX8
\res MCU: STM8S103
\res export PD_ODR PD_DDR PD_CR1
#require ]B!
NVM
\ Set RS485 Driver to "RX"
: rx ( -- )
[ 0 PD_ODR 7 ]B!
;
\ Set RS485 Driver to "TX"
: tx ( -- )
[ 1 PD_ODR 7 ]B!
;
\ Initialize GPIO and RS485 Driver
: CTRL ( -- )
BUSrx
[ 1 PD_DDR 7 ]B!
[ 1 PD_CR1 7 ]B!
;
' rx is BUSrx
' tx is BUStx
' ctrl is BUSctrl
RAM
A MODBUS board with the name "modbus_relay8 v1.2" arrived a few days ago: It has an STM8S103K3T6C, an LM2596-5V switching power supply (7..30V, 2-3A), 8 relays and 8 insulated inputs. The usual price is at $15.
I made a Gist with Forth code for I/O based on SWIMCOM. GPIOs for I/O are documented in the code.
Other GPIOs traced so far are: