Close

Integrating the RC2014 WIFI Module

A project log for MSX COMPATIBLE BOARDS FOR RC2014

Create a series of boards designed for the RC2014 bus to achieve MSX/MSX2 compatiblity

dean-nethertonDean Netherton 09/11/2021 at 23:560 Comments

Over the last couple of weekends I have manage to get the RC2014 ESP8266 WIFI Module working in MSX-DOS.

I now have a 'WIFI' modem integrated into the serial communication.  Finally, my RC2014 no longer needs to be 'connected' to my main PC - it can reach out through the Internet all on its own.

I have been writing my own custom firmware for ESP8266 to give the MSX/RC2014 kit all it needs.

At the moment, I can:

I needed to modify the WIFI Module to allow hardware flow control - otherwise the ESP8266 will overwhelm the RC2014's receive buffer.  This required adding a couple of resistors to map the 5V RTS from the SIO/2 to the 3.3V CTS/GPIO13 line.  Flow control is only needed in the one direction - from ESP8266 to SIO/2.  When transmitting from the SIO/2 to the ESP8266, the ESP8266 will easily keep up at the 19200 baud rate.

The RC2014 WIFI module provides a great prototyping area to make this modification so easy:

I have never used an ESP8266 before, so had to learn a few things - I used the Arduino Core library - making it very easy for me to code for the chip.

But I did struggle with a few things:

  1. The RX line needs to be open drain - if the internal pull up resistor is active, then the on-board voltage divider of the WIFI module will not work.  The Arduino Core, by default, enables the internal pull up - and there seems to be no interface to change this.
  2. Arduino Core also does not have any functions to flip the ESP8266 into using hardware flow control for the serial lines.

I solves these problems by directly manipulating the relevant ESP8266 registers.

To disable the internal pull up resister of the RX line:

void setRXOpenDrain() {
  GPC(RX_PIN) = (GPC(RX_PIN) & (0xF << GPCI)); // SOURCE(GPIO) | DRIVER(NORMAL) | INT_TYPE(UNCHANGED) | WAKEUP_ENABLE(DISABLED)
  GPEC = (1 << RX_PIN);                        // Disable
  GPF(RX_PIN) = GPFFS(GPFFS_BUS(RX_PIN));      // Set mode to BUS (RX0, TX0, TX1, SPI, HSPI or CLK depending in the pin)
}

And for flipping hardware flow control on and off:

void setCTSFlowControlOn() {
 pinMode(CTSPin, FUNCTION_4); // make pin U0CTS
 U0C0 |= (1 << UCTXHFE); // Set bit to activate Hardware flow control
}

void setCTSFlowControlOff() {
 pinMode(CTSPin, FUNCTION_4); // make pin U0CTS
 U0C0 &= ~(1 << UCTXHFE); // Reset bit to deactivate hardware flow control
}

The full code for the ESP8266 can be found at: https://github.com/vipoo/yellow-msx-esp8266-wifi-module

And an xmodem serial and TCP/IP client I wrote in nodejs can be found at: https://github.com/vipoo/xmodem-cli

And the main project is still at: https://github.com/vipoo/yellow-msx-series-for-rc2014

Discussions