diff --git a/src/devices/machine/i8256.cpp b/src/devices/machine/i8256.cpp index 6cf474e78ddb1..107810c96b470 100644 --- a/src/devices/machine/i8256.cpp +++ b/src/devices/machine/i8256.cpp @@ -248,7 +248,18 @@ void i8256_device::device_reset() m_status = 0x30; // TRE and TBE - m_timer->adjust(attotime::from_hz(16000), 0, attotime::from_hz(16000)); + reset_timer(); +} + +void i8256_device::reset_timer() +{ + int divider = 64; //default is 16kHz from the datasheet, it may later be changed to a slower one + if (BIT(m_command1, I8256_CMD1_FRQ)) + { + divider = 1024; + } + const attotime time = attotime::from_hz((clock() / SYS_CLOCK_DIVIDER[(m_command2 & 0x30 >> 4)]) / divider); + m_timer->adjust(time, 0, time); } TIMER_CALLBACK_MEMBER(i8256_device::timer_check) @@ -261,9 +272,13 @@ TIMER_CALLBACK_MEMBER(i8256_device::timer_check) if (m_timers[i] == 0 && BIT(m_interrupts,timer_interrupt[i])) // If the interrupt is enabled { m_current_interrupt_level = timer_interrupt[i]; - m_out_int_cb(1); // it occurs when the counter changes from 1 to 0. + m_out_int_cb(ASSERT_LINE); // it occurs when the counter changes from 1 to 0. } } + else + { + m_out_int_cb(CLEAR_LINE); + } } } @@ -335,10 +350,7 @@ void i8256_device::write(offs_t offset, u8 data) { m_command1 = data; - if (BIT(m_command1,I8256_CMD1_FRQ)) - m_timer->adjust(attotime::from_hz(1000), 0, attotime::from_hz(1000)); - else - m_timer->adjust(attotime::from_hz(16000), 0, attotime::from_hz(16000)); + reset_timer(); if (BIT(m_command1,I8256_CMD1_8086)) LOG("I8256 Enabled 8086 mode\n"); @@ -621,7 +633,7 @@ void i8256_device::receive_character(uint8_t ch) { LOG("I8256: receive_character %02x\n", ch); - m_rx_data = ch; + m_rx_buffer = ch; LOG("status RX READY test %02x\n", m_status); // char has not been read and another has arrived! diff --git a/src/devices/machine/i8256.h b/src/devices/machine/i8256.h index b498e4ae9f0ae..6ea705874e6a5 100644 --- a/src/devices/machine/i8256.h +++ b/src/devices/machine/i8256.h @@ -112,6 +112,7 @@ class i8256_device : public device_t, public device_serial_interface TIMER_CALLBACK_MEMBER(timer_check); + void reset_timer(); void receive_clock(); void sync1_rxc(); void sync2_rxc();