Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions src/devices/machine/i8256.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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);
}
}
}

Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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!
Expand Down
1 change: 1 addition & 0 deletions src/devices/machine/i8256.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Loading