diff options
author | 2019-05-26 21:17:35 -0400 | |
---|---|---|
committer | 2019-05-26 21:17:35 -0400 | |
commit | c9bf74de4e93a135751b679a85b2692e98c8274a (patch) | |
tree | 87f4fdd0a3f7b82c4f313182e36537d24dc62cbe | |
parent | 8c401055b8d9ed2fd916bd04a082e3bb68ec7db4 (diff) |
mc68340: correct MC68340 baud rate calculation [R. Belmont]
-rw-r--r-- | src/devices/machine/mc68681.cpp | 71 | ||||
-rw-r--r-- | src/devices/machine/mc68681.h | 3 |
2 files changed, 74 insertions, 0 deletions
diff --git a/src/devices/machine/mc68681.cpp b/src/devices/machine/mc68681.cpp index 87f1c31ce07..5d321796ff3 100644 --- a/src/devices/machine/mc68681.cpp +++ b/src/devices/machine/mc68681.cpp @@ -70,6 +70,9 @@ static const int baud_rate_ACR_0_X_1[] = { 75, 110, 134, 150, 3600, 14400, 28800 static const int baud_rate_ACR_1[] = { 75, 110, 134, 150, 300, 600, 1200, 2000, 2400, 4800, 1800, 9600, 19200, 0, 0, 0 }; /* xr68c681 X=0 */ static const int baud_rate_ACR_1_X_1[] = { 50, 110, 134, 200, 3600, 14400, 28800, 57600, 115200, 4800, 7200, 9600, 38400, 0, 0, 0 }; +static const int baud_rate_ACR_0_340[] = { 50, 110, 134, 200, 300, 600, 1200, 1050, 2400, 4800, 7200, 9600, 38400, 76800, 0, 0 }; /* xr68c681 ACR:7=0 */ +static const int baud_rate_ACR_1_340[] = { 75, 110, 134, 150, 300, 600, 1200, 2000, 2400, 4800, 1800, 9600, 19200, 38400, 0, 0 }; /* xr68c681 ACR:7=1 */ + #define INT_INPUT_PORT_CHANGE 0x80 #define INT_DELTA_BREAK_B 0x40 #define INT_RXRDY_FFULLB 0x20 @@ -1007,6 +1010,74 @@ int duart_base_device::calc_baud(int ch, bool rx, uint8_t data) return baud_rate; } +int mc68340_duart_device::calc_baud(int ch, bool rx, uint8_t data) +{ + int baud_rate; + + if (BIT(ACR, 7) == 0) + { + baud_rate = baud_rate_ACR_0_340[data & 0x0f]; + + if (ch == 0) + { + if ((data & 0xf) == 0xe) + { + baud_rate = ip3clk/16; + } + else if ((data & 0xf) == 0xf) + { + baud_rate = ip3clk; + } + } + else if (ch == 1) + { + if ((data & 0xf) == 0xe) + { + baud_rate = ip5clk/16; + } + else if ((data & 0xf) == 0xf) + { + baud_rate = ip5clk; + } + } + } + else + { + baud_rate = baud_rate_ACR_1_340[data & 0x0f]; + + if (ch == 0) + { + if ((data & 0xf) == 0xe) + { + baud_rate = ip3clk/16; + } + else if ((data & 0xf) == 0xf) + { + baud_rate = ip3clk; + } + } + else if (ch == 1) + { + if ((data & 0xf) == 0xe) + { + baud_rate = ip5clk/16; + } + else if ((data & 0xf) == 0xf) + { + baud_rate = ip5clk; + } + } + } + + if ((baud_rate == 0) && ((data & 0xf) != 0xd)) + { + LOG("Unsupported transmitter clock: channel %d, clock select = %02x\n", ch, data); + } + + //printf("%s ch %d setting baud to %d\n", tag(), ch, baud_rate); + return baud_rate; +} + int xr68c681_device::calc_baud(int ch, bool rx, uint8_t data) { int baud_rate; diff --git a/src/devices/machine/mc68681.h b/src/devices/machine/mc68681.h index aa92ec598f6..480fad6aba7 100644 --- a/src/devices/machine/mc68681.h +++ b/src/devices/machine/mc68681.h @@ -242,6 +242,9 @@ public: protected: virtual void device_add_mconfig(machine_config &config) override; mc68340_duart_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock); + +private: + virtual int calc_baud(int ch, bool rx, uint8_t data) override; }; class xr68c681_device : public mc68681_device |